Plasma Engine  2.0
Loading...
Searching...
No Matches
DocumentObjectMirror.h
1#pragma once
2
3#include <Foundation/Containers/HybridArray.h>
4#include <Foundation/Reflection/PropertyPath.h>
5#include <Foundation/Serialization/RttiConverter.h>
6#include <ToolsFoundation/Object/DocumentObjectManager.h>
7#include <ToolsFoundation/ToolsFoundationDLL.h>
8
9
14class PL_TOOLSFOUNDATION_DLL plObjectChange
15{
16public:
17 plObjectChange() = default;
20 void operator=(plObjectChange&& rhs);
21 void operator=(plObjectChange& rhs);
22 void GetGraph(plAbstractObjectGraph& ref_graph) const;
23 void SetGraph(plAbstractObjectGraph& ref_graph);
24
25 plUuid m_Root; //< The object that is the parent of the op, namely the parent heap object we can store a pointer to.
26 plHybridArray<plPropertyPathStep, 2> m_Steps; //< Path from root to target of change.
27 plDiffOperation m_Change; //< Change at the target.
28 plDataBuffer m_GraphData; //< In case of ObjectAdded, this holds the binary serialized object graph.
29};
30PL_DECLARE_REFLECTABLE_TYPE(PL_TOOLSFOUNDATION_DLL, plObjectChange);
31
32
33class PL_TOOLSFOUNDATION_DLL plDocumentObjectMirror
34{
35public:
38
39 void InitSender(const plDocumentObjectManager* pManager);
40 void InitReceiver(plRttiConverterContext* pContext);
41 void DeInit();
42
48 void SetFilterFunction(FilterFunction filter);
49
50 void SendDocument();
51 void Clear();
52
53 void TreeStructureEventHandler(const plDocumentObjectStructureEvent& e);
54 void TreePropertyEventHandler(const plDocumentObjectPropertyEvent& e);
55
56 void* GetNativeObjectPointer(const plDocumentObject* pObject);
57 const void* GetNativeObjectPointer(const plDocumentObject* pObject) const;
58
59protected:
60 bool IsRootObject(const plDocumentObject* pParent);
61 bool IsHeapAllocated(const plDocumentObject* pParent, plStringView sParentProperty);
62 bool IsDiscardedByFilter(const plDocumentObject* pObject, plStringView sProperty) const;
63 static void CreatePath(plObjectChange& out_change, const plDocumentObject* pRoot, plStringView sProperty);
64 static plUuid FindRootOpObject(const plDocumentObject* pObject, plHybridArray<const plDocumentObject*, 8>& path);
65 static void FlattenSteps(const plArrayPtr<const plDocumentObject* const> path, plHybridArray<plPropertyPathStep, 2>& out_steps);
66
67 virtual void ApplyOp(plObjectChange& change);
68 void ApplyOp(plRttiConverterObject object, const plObjectChange& change);
69
70protected:
71 plRttiConverterContext* m_pContext;
72 const plDocumentObjectManager* m_pManager;
73 FilterFunction m_Filter;
74};
Definition AbstractObjectGraph.h:115
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
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 DocumentObjectMirror.h:34
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
An object change starts at the heap object m_Root (because we can only safely store pointers to those...
Definition DocumentObjectMirror.h:15
Definition RttiConverter.h:33
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
Definition AbstractObjectGraph.h:104
Used by plDocumentObjectManager::m_PropertyEvents.
Definition DocumentObjectManager.h:77
Used by plDocumentObjectManager::m_StructureEvents.
Definition DocumentObjectManager.h:45
Definition RttiConverter.h:13