ezEngine Release 26.3
Loading...
Searching...
No Matches
ezAbstractObjectGraph Class Reference

An intermediate representation for serializing/deserializing reflected objects. More...

#include <AbstractObjectGraph.h>

Public Types

using FilterFunction = ezDelegate< bool(const ezAbstractObjectNode *, const ezAbstractObjectNode::Property *)>
 

Public Member Functions

void Clear ()
 
ezAbstractObjectNodeClone (ezAbstractObjectGraph &ref_cloneTarget, const ezAbstractObjectNode *pRootNode=nullptr, FilterFunction filter=FilterFunction()) const
 
ezStringView RegisterString (ezStringView sString)
 
const ezAbstractObjectNodeGetNode (const ezUuid &guid) const
 
ezAbstractObjectNodeGetNode (const ezUuid &guid)
 
const ezAbstractObjectNodeGetNodeByName (ezStringView sName) const
 
ezAbstractObjectNodeGetNodeByName (ezStringView sName)
 
ezAbstractObjectNodeAddNode (const ezUuid &guid, ezStringView sType, ezUInt32 uiTypeVersion, ezStringView sNodeName={})
 
void RemoveNode (const ezUuid &guid)
 
const ezMap< ezUuid, ezAbstractObjectNode * > & GetAllNodes () const
 
ezMap< ezUuid, ezAbstractObjectNode * > & GetAllNodes ()
 
void ReMapNodeGuids (const ezUuid &seedGuid, bool bRemapInverse=false)
 Remaps all node guids by adding the given seed, or if bRemapInverse is true, by subtracting it/ This is mostly used to remap prefab instance graphs to their prefab template graph.
 
void ReMapNodeGuidsToMatchGraph (ezAbstractObjectNode *pRoot, const ezAbstractObjectGraph &rhsGraph, const ezAbstractObjectNode *pRhsRoot)
 Tries to remap the guids of this graph to those in rhsGraph by walking in both down the hierarchy, starting at root and rhsRoot.
 
void FindTransitiveHull (const ezUuid &rootGuid, ezSet< ezUuid > &out_reachableNodes) const
 Finds everything accessible by the given root node.
 
void PruneGraph (const ezUuid &rootGuid)
 Deletes everything not accessible by the given root node.
 
void ModifyNodeViaNativeCounterpart (ezAbstractObjectNode *pRootNode, ezDelegate< void(void *, const ezRTTI *)> callback)
 Allows a node to be modified as a native object and automatically syncs changes back.
 
ezAbstractObjectNodeCopyNodeIntoGraph (const ezAbstractObjectNode *pNode)
 Allows to copy a node from another graph into this graph.
 
ezAbstractObjectNodeCopyNodeIntoGraph (const ezAbstractObjectNode *pNode, FilterFunction &ref_filter)
 
void CreateDiffWithBaseGraph (const ezAbstractObjectGraph &base, ezDeque< ezAbstractGraphDiffOperation > &out_diffResult) const
 
void ApplyDiff (ezDeque< ezAbstractGraphDiffOperation > &ref_diff)
 
void MergeDiffs (const ezDeque< ezAbstractGraphDiffOperation > &lhs, const ezDeque< ezAbstractGraphDiffOperation > &rhs, ezDeque< ezAbstractGraphDiffOperation > &ref_out) const
 

Detailed Description

An intermediate representation for serializing/deserializing reflected objects.

The AbstractObjectGraph represents objects and their properties in a type-independent way, allowing for versioning, patching, and format conversion. It serves as the core of ezEngine's serialization system and enables advanced features like:

  • Cross-format serialization (DDL, binary, JSON)
  • Type versioning and migration
  • Graph diffing and merging
  • Prefab instantiation and overrides
  • Undo/redo systems

Structure:

  • Graph contains nodes (ezAbstractObjectNode) identified by GUIDs
  • Each node has a type name, version, and properties
  • Properties store values as ezVariant (including object references)
  • References between objects are stored as GUIDs

Member Function Documentation

◆ ModifyNodeViaNativeCounterpart()

void ezAbstractObjectGraph::ModifyNodeViaNativeCounterpart ( ezAbstractObjectNode pRootNode,
ezDelegate< void(void *, const ezRTTI *)>  callback 
)

Allows a node to be modified as a native object and automatically syncs changes back.

This temporarily converts the node (and its sub-hierarchy) to native objects, calls the provided callback to allow modifications, then converts the modified objects back to the graph representation. This is useful for applying complex modifications that are easier to implement on native objects. Changes to the object hierarchy (adding/removing children) will be reflected in the graph.

◆ ReMapNodeGuidsToMatchGraph()

void ezAbstractObjectGraph::ReMapNodeGuidsToMatchGraph ( ezAbstractObjectNode pRoot,
const ezAbstractObjectGraph rhsGraph,
const ezAbstractObjectNode pRhsRoot 
)

Tries to remap the guids of this graph to those in rhsGraph by walking in both down the hierarchy, starting at root and rhsRoot.

Note that in case of array properties the remapping assumes element indices to be equal on both sides which will cause all moves inside the arrays to be lost as there is no way of recovering this information without an equality criteria. This function is mostly used to remap a graph from a native object to a graph from ezDocumentObjects to allow applying native side changes to the original ezDocumentObject hierarchy using diffs.


The documentation for this class was generated from the following files: