ezEngine Release 25.08
Loading...
Searching...
No Matches
ezVariantSubAccessor Class Reference

Accessor for a sub-tree on an ezVariant property. The tools foundation code uses an ezDocumentObject, one of its ezAbstractProperty and an optional ezVariant index to reference to properties. Any deeper hierarchies must be built from additional objects. This principle prevents the GUI to reference anything inside an ezVariant that stores an VariantArray or VariantDictionary as ezVariant is a pure value type and cannot store additional objects on the tool side. To work around this, this class creates a view one level deeper into an ezVariant. This is done by calling SetSubItems which for each object in the map moves the view into the sub-tree referenced by the given value of the map. More...

#include <VariantSubAccessor.h>

Inheritance diagram for ezVariantSubAccessor:

Public Member Functions

 ezVariantSubAccessor (ezObjectAccessorBase *pSource, const ezAbstractProperty *pProp)
 Constructor.
 
void SetSubItems (const ezMap< const ezDocumentObject *, ezVariant > &subItemMap)
 Sets the sub-tree indices for the selected objects.
 
const ezAbstractPropertyGetRootProperty () const
 Returns the property this accessor wraps.
 
ezInt32 GetDepth () const
 How many level deep the view is inside the property.
 
ezResult GetPath (const ezDocumentObject *pObject, ezDynamicArray< ezVariant > &out_path) const
 
virtual ezStatus GetValue (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, ezVariant &out_value, ezVariant index=ezVariant()) override
 
virtual ezStatus SetValue (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, const ezVariant &newValue, ezVariant index=ezVariant()) override
 
virtual ezStatus InsertValue (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, const ezVariant &newValue, ezVariant index=ezVariant()) override
 
virtual ezStatus RemoveValue (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, ezVariant index=ezVariant()) override
 
virtual ezStatus MoveValue (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, const ezVariant &oldIndex, const ezVariant &newIndex) override
 
virtual ezStatus GetCount (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, ezInt32 &out_iCount) override
 
virtual ezStatus GetKeys (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, ezDynamicArray< ezVariant > &out_keys) override
 
virtual ezStatus GetValues (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, ezDynamicArray< ezVariant > &out_values) override
 
virtual ezObjectAccessorBaseResolveProxy (const ezDocumentObject *&ref_pObject, const ezRTTI *&ref_pType, const ezAbstractProperty *&ref_pProp, ezDynamicArray< ezVariant > &ref_indices) override
 If this accessor is a proxy accessor, transform the input parameters into those of the source accessor. The default implementation does nothing and returns this. Usually this only needs to be implemented on ezObjectProxyAccessor derived accessors that modify the type, property, view etc of an object.
 
- Public Member Functions inherited from ezObjectProxyAccessor
 ezObjectProxyAccessor (ezObjectAccessorBase *pSource)
 
ezObjectAccessorBaseGetSourceAccessor () const
 
virtual void StartTransaction (ezStringView sDisplayString) override
 
virtual void CancelTransaction () override
 
virtual void FinishTransaction () override
 
virtual void BeginTemporaryCommands (ezStringView sDisplayString, bool bFireEventsWhenUndoingTempCommands=false) override
 
virtual void CancelTemporaryCommands () override
 
virtual void FinishTemporaryCommands () override
 
virtual const ezDocumentObjectGetObject (const ezUuid &object) override
 
virtual ezStatus AddObject (const ezDocumentObject *pParent, const ezAbstractProperty *pParentProp, const ezVariant &index, const ezRTTI *pType, ezUuid &inout_objectGuid) override
 
virtual ezStatus RemoveObject (const ezDocumentObject *pObject) override
 
virtual ezStatus MoveObject (const ezDocumentObject *pObject, const ezDocumentObject *pNewParent, const ezAbstractProperty *pParentProp, const ezVariant &index) override
 
- Public Member Functions inherited from ezObjectAccessorBase
const ezDocumentObjectManagerGetObjectManager () const
 
ezStatus GetValueByName (const ezDocumentObject *pObject, ezStringView sProp, ezVariant &out_value, ezVariant index=ezVariant())
 
ezStatus SetValueByName (const ezDocumentObject *pObject, ezStringView sProp, const ezVariant &newValue, ezVariant index=ezVariant())
 
ezStatus InsertValueByName (const ezDocumentObject *pObject, ezStringView sProp, const ezVariant &newValue, ezVariant index=ezVariant())
 
ezStatus RemoveValueByName (const ezDocumentObject *pObject, ezStringView sProp, ezVariant index=ezVariant())
 
ezStatus MoveValueByName (const ezDocumentObject *pObject, ezStringView sProp, const ezVariant &oldIndex, const ezVariant &newIndex)
 
ezStatus GetCountByName (const ezDocumentObject *pObject, ezStringView sProp, ezInt32 &out_iCount)
 
ezStatus AddObjectByName (const ezDocumentObject *pParent, ezStringView sParentProp, const ezVariant &index, const ezRTTI *pType, ezUuid &inout_objectGuid)
 
ezStatus MoveObjectByName (const ezDocumentObject *pObject, const ezDocumentObject *pNewParent, ezStringView sParentProp, const ezVariant &index)
 
ezStatus GetKeysByName (const ezDocumentObject *pObject, ezStringView sProp, ezDynamicArray< ezVariant > &out_keys)
 
ezStatus GetValuesByName (const ezDocumentObject *pObject, ezStringView sProp, ezDynamicArray< ezVariant > &out_values)
 
const ezDocumentObjectGetChildObjectByName (const ezDocumentObject *pObject, ezStringView sProp, ezVariant index)
 
ezStatus ClearByName (const ezDocumentObject *pObject, ezStringView sProp)
 
const ezAbstractPropertyFindPropertyByName (const ezDocumentObject *pObject, ezStringView sProp)
 
template<typename T >
Get (const ezDocumentObject *pObject, const ezAbstractProperty *pProp, ezVariant index=ezVariant())
 
template<typename T >
GetByName (const ezDocumentObject *pObject, ezStringView sProp, ezVariant index=ezVariant())
 
ezInt32 GetCount (const ezDocumentObject *pObject, const ezAbstractProperty *pProp)
 
ezInt32 GetCountByName (const ezDocumentObject *pObject, ezStringView sProp)
 
- Public Member Functions inherited from ezReflectedClass
virtual const ezRTTIGetDynamicRTTI () const
 
bool IsInstanceOf (const ezRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
 
template<typename T >
EZ_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.
 

Additional Inherited Members

- Static Public Member Functions inherited from ezNoBase
static const ezRTTIGetStaticRTTI ()
 
- Protected Member Functions inherited from ezObjectAccessorBase
 ezObjectAccessorBase (const ezDocumentObjectManager *pManager)
 
void FireDocumentObjectStructureEvent (const ezDocumentObjectStructureEvent &e)
 
void FireDocumentObjectPropertyEvent (const ezDocumentObjectPropertyEvent &e)
 
- Protected Attributes inherited from ezObjectProxyAccessor
ezObjectAccessorBasem_pSource = nullptr
 
- Protected Attributes inherited from ezObjectAccessorBase
const ezDocumentObjectManagerm_pConstManager
 

Detailed Description

Accessor for a sub-tree on an ezVariant property. The tools foundation code uses an ezDocumentObject, one of its ezAbstractProperty and an optional ezVariant index to reference to properties. Any deeper hierarchies must be built from additional objects. This principle prevents the GUI to reference anything inside an ezVariant that stores an VariantArray or VariantDictionary as ezVariant is a pure value type and cannot store additional objects on the tool side. To work around this, this class creates a view one level deeper into an ezVariant. This is done by calling SetSubItems which for each object in the map moves the view into the sub-tree referenced by the given value of the map.

Constructor & Destructor Documentation

◆ ezVariantSubAccessor()

ezVariantSubAccessor::ezVariantSubAccessor ( ezObjectAccessorBase pSource,
const ezAbstractProperty pProp 
)

Constructor.

Parameters
pSourceThe original accessor that is going to be proxied. By chaining this class an ezVariant can be explored deeper and deeper.
pPropThe ezVariant property that is going to be proxied. Only this property is allowed to be accessed by the accessor functions.

Member Function Documentation

◆ GetCount()

ezStatus ezVariantSubAccessor::GetCount ( const ezDocumentObject pObject,
const ezAbstractProperty pProp,
ezInt32 &  out_iCount 
)
overridevirtual

Reimplemented from ezObjectProxyAccessor.

◆ GetKeys()

ezStatus ezVariantSubAccessor::GetKeys ( const ezDocumentObject pObject,
const ezAbstractProperty pProp,
ezDynamicArray< ezVariant > &  out_keys 
)
overridevirtual

Reimplemented from ezObjectProxyAccessor.

◆ GetPath()

ezResult ezVariantSubAccessor::GetPath ( const ezDocumentObject pObject,
ezDynamicArray< ezVariant > &  out_path 
) const

Builds a path up the hierarchy of wrapped ezVariantSubAccessor objects to determine the path to the current sub-tree of the ezVariant.

Parameters
pObjectThe object for which the path should be computed
out_pathAn array of indices that has to be followed from the root of the ezVariant to each the current sub-tree view.
Returns
Returns EZ_FAILURE if pObject is not known.

◆ GetValue()

ezStatus ezVariantSubAccessor::GetValue ( const ezDocumentObject pObject,
const ezAbstractProperty pProp,
ezVariant out_value,
ezVariant  index = ezVariant() 
)
overridevirtual

Reimplemented from ezObjectProxyAccessor.

◆ GetValues()

ezStatus ezVariantSubAccessor::GetValues ( const ezDocumentObject pObject,
const ezAbstractProperty pProp,
ezDynamicArray< ezVariant > &  out_values 
)
overridevirtual

Reimplemented from ezObjectProxyAccessor.

◆ InsertValue()

ezStatus ezVariantSubAccessor::InsertValue ( const ezDocumentObject pObject,
const ezAbstractProperty pProp,
const ezVariant newValue,
ezVariant  index = ezVariant() 
)
overridevirtual

Reimplemented from ezObjectProxyAccessor.

◆ MoveValue()

ezStatus ezVariantSubAccessor::MoveValue ( const ezDocumentObject pObject,
const ezAbstractProperty pProp,
const ezVariant oldIndex,
const ezVariant newIndex 
)
overridevirtual

Reimplemented from ezObjectProxyAccessor.

◆ RemoveValue()

ezStatus ezVariantSubAccessor::RemoveValue ( const ezDocumentObject pObject,
const ezAbstractProperty pProp,
ezVariant  index = ezVariant() 
)
overridevirtual

Reimplemented from ezObjectProxyAccessor.

◆ ResolveProxy()

ezObjectAccessorBase * ezVariantSubAccessor::ResolveProxy ( const ezDocumentObject *&  ref_pObject,
const ezRTTI *&  ref_pType,
const ezAbstractProperty *&  ref_pProp,
ezDynamicArray< ezVariant > &  ref_indices 
)
overridevirtual

If this accessor is a proxy accessor, transform the input parameters into those of the source accessor. The default implementation does nothing and returns this. Usually this only needs to be implemented on ezObjectProxyAccessor derived accessors that modify the type, property, view etc of an object.

Parameters
ref_pObjectIn: proxy object, out: source object.
ref_pTypeIn: proxy type, out: source type.
ref_pPropIn: proxy property, out: source property.
ref_indicesIn: proxy indices, out: source indices. While most of the time this will be one index, e.g. an array or map index. In case of variants that can store containers in containers this can be a chain of indices into a variant hierarchy.
Returns
Returns the source accessor.

Reimplemented from ezObjectAccessorBase.

◆ SetSubItems()

void ezVariantSubAccessor::SetSubItems ( const ezMap< const ezDocumentObject *, ezVariant > &  subItemMap)

Sets the sub-tree indices for the selected objects.

Parameters
subItemMapObject to index map. Note that as this is in the ToolsFoundation it cannot use the ezPropertySelection class.

◆ SetValue()

ezStatus ezVariantSubAccessor::SetValue ( const ezDocumentObject pObject,
const ezAbstractProperty pProp,
const ezVariant newValue,
ezVariant  index = ezVariant() 
)
overridevirtual

Reimplemented from ezObjectProxyAccessor.


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