Plasma Engine  2.0
Loading...
Searching...
No Matches
DocumentObjectBase.h
1#pragma once
2
3#include <Foundation/Strings/HashedString.h>
4#include <Foundation/Types/Uuid.h>
5#include <ToolsFoundation/Reflection/ReflectedTypeStorageAccessor.h>
6#include <ToolsFoundation/ToolsFoundationDLL.h>
7
9
10class PL_TOOLSFOUNDATION_DLL plDocumentObject
11{
12public:
14
15 = default;
16 virtual ~plDocumentObject() = default;
17
18 // Accessors
19 const plUuid& GetGuid() const { return m_Guid; }
20 const plRTTI* GetType() const { return GetTypeAccessor().GetType(); }
21
22 const plDocumentObjectManager* GetDocumentObjectManager() const { return m_pDocumentObjectManager; }
23 plDocumentObjectManager* GetDocumentObjectManager() { return m_pDocumentObjectManager; }
24
25 virtual const plIReflectedTypeAccessor& GetTypeAccessor() const = 0;
26 plIReflectedTypeAccessor& GetTypeAccessor();
27
28 // Ownership
29 const plDocumentObject* GetParent() const { return m_pParent; }
30
31 virtual void InsertSubObject(plDocumentObject* pObject, plStringView sProperty, const plVariant& index);
32 virtual void RemoveSubObject(plDocumentObject* pObject);
33
34 // Helper
35 void ComputeObjectHash(plUInt64& ref_uiHash) const;
36 const plHybridArray<plDocumentObject*, 8>& GetChildren() const { return m_Children; }
37 plDocumentObject* GetChild(const plUuid& guid);
38 const plDocumentObject* GetChild(const plUuid& guid) const;
39 plStringView GetParentProperty() const { return m_sParentProperty; }
40 const plAbstractProperty* GetParentPropertyType() const;
41 plVariant GetPropertyIndex() const;
42 bool IsOnHeap() const;
43 plUInt32 GetChildIndex(const plDocumentObject* pChild) const;
44
45private:
46 friend class plDocumentObjectManager;
47 void HashPropertiesRecursive(const plIReflectedTypeAccessor& acc, plUInt64& uiHash, const plRTTI* pType) const;
48
49protected:
50 plUuid m_Guid;
51 plDocumentObjectManager* m_pDocumentObjectManager = nullptr;
52
53 plDocumentObject* m_pParent = nullptr;
55
56 // Sub object data
57 plString m_sParentProperty;
58};
59
60class PL_TOOLSFOUNDATION_DLL plDocumentStorageObject : public plDocumentObject
61{
62public:
65 , m_ObjectPropertiesAccessor(pType, this)
66 {
67 }
68
69 virtual ~plDocumentStorageObject() = default;
70
71 virtual const plIReflectedTypeAccessor& GetTypeAccessor() const override { return m_ObjectPropertiesAccessor; }
72
73protected:
74 plReflectedTypeStorageAccessor m_ObjectPropertiesAccessor;
75};
This is the base interface for all properties in the reflection system. It provides enough informatio...
Definition AbstractProperty.h:150
Definition DocumentObjectBase.h:11
Represents to content of a document. Every document has exactly one root object under which all objec...
Definition DocumentObjectManager.h:116
Definition DocumentObjectBase.h:61
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Provides access to the properties of an plRTTI compatible data storage.
Definition IReflectedTypeAccessor.h:11
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
An plIReflectedTypeAccessor implementation that also stores the actual data that is defined in the pa...
Definition ReflectedTypeStorageAccessor.h:13
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44