Plasma Engine  2.0
Loading...
Searching...
No Matches
DocumentObjectConverter.h
1#pragma once
2
3#include <Foundation/Serialization/AbstractObjectGraph.h>
4#include <ToolsFoundation/Object/DocumentObjectManager.h>
5
7
12class PL_TOOLSFOUNDATION_DLL plDocumentObjectConverterWriter
13{
14public:
17 {
18 m_pGraph = pGraph;
19 m_pManager = pManager;
20 m_Filter = filter;
21 }
22
23 plAbstractObjectNode* AddObjectToGraph(const plDocumentObject* pObject, plStringView sNodeName = nullptr);
24
25private:
26 void AddProperty(plAbstractObjectNode* pNode, const plAbstractProperty* pProp, const plDocumentObject* pObject);
27 void AddProperties(plAbstractObjectNode* pNode, const plDocumentObject* pObject);
28
29 plAbstractObjectNode* AddSubObjectToGraph(const plDocumentObject* pObject, plStringView sNodeName);
30
31 const plDocumentObjectManager* m_pManager;
32 plAbstractObjectGraph* m_pGraph;
33 FilterFunction m_Filter;
34 plSet<const plDocumentObject*> m_QueuedObjects;
35};
36
37
38class PL_TOOLSFOUNDATION_DLL plDocumentObjectConverterReader
39{
40public:
41 enum class Mode
42 {
43 CreateOnly,
44 CreateAndAddToDocument,
45 };
47
48 plDocumentObject* CreateObjectFromNode(const plAbstractObjectNode* pNode);
49 void ApplyPropertiesToObject(const plAbstractObjectNode* pNode, plDocumentObject* pObject);
50
51 plUInt32 GetNumUnknownObjectCreations() const { return m_uiUnknownTypeInstances; }
52 const plSet<plString>& GetUnknownObjectTypes() const { return m_UnknownTypes; }
53
54 static void ApplyDiffToObject(plObjectAccessorBase* pObjectAccessor, const plDocumentObject* pObject, plDeque<plAbstractGraphDiffOperation>& ref_diff);
55
56private:
57 void AddObject(plDocumentObject* pObject, plDocumentObject* pParent, plStringView sParentProperty, plVariant index);
58 void ApplyProperty(plDocumentObject* pObject, const plAbstractProperty* pProp, const plAbstractObjectNode::Property* pSource);
59 static void ApplyDiff(plObjectAccessorBase* pObjectAccessor, const plDocumentObject* pObject, const plAbstractProperty* pProp,
61
62 Mode m_Mode;
63 plDocumentObjectManager* m_pManager;
64 const plAbstractObjectGraph* m_pGraph;
65 plSet<plString> m_UnknownTypes;
66 plUInt32 m_uiUnknownTypeInstances;
67};
Definition AbstractObjectGraph.h:115
Definition AbstractObjectGraph.h:17
This is the base interface for all properties in the reflection system. It provides enough informatio...
Definition AbstractProperty.h:150
Definition Deque.h:270
Definition DocumentObjectConverter.h:39
Writes the state of an plDocumentObject to an abstract graph.
Definition DocumentObjectConverter.h:13
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 ObjectAccessorBase.h:8
Definition Set.h:238
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
Definition AbstractObjectGraph.h:70
Definition AbstractObjectGraph.h:20