XII Release 0.1.0
Loading...
Searching...
No Matches
xiiDefaultStateProvider Class Referenceabstract

Interface for querying and restoring the default state of objects and containers. More...

#include <DefaultState.h>

Inheritance diagram for xiiDefaultStateProvider:
[legend]

Public Types

using SuperArray = const xiiArrayPtr<const xiiSharedPtr<xiiDefaultStateProvider>>
 Parent hierarchy of state providers.
 

Public Member Functions

virtual xiiInt32 GetRootDepth () const =0
 Returns the root depth of this provider instance.
 
virtual xiiColorGammaUB GetBackgroundColor () const =0
 Returns a color to be used in the property grid. Only the hue of the color is used. If alpha is 0, the color is ignored and no tinting of the property grid takes place.
 
virtual xiiString GetStateProviderName () const =0
 Returns the name of this state provider. Can be used to check what the outer most provider is for GUI purposes.
 
virtual xiiVariant GetDefaultValue (SuperArray superPtr, xiiObjectAccessorBase *pAccessor, const xiiDocumentObject *pObject, const xiiAbstractProperty *pProp, xiiVariant index=xiiVariant())=0
 Returns the default value of an object's property at a given index.
 
virtual xiiStatus CreateRevertContainerDiff (SuperArray superPtr, xiiObjectAccessorBase *pAccessor, const xiiDocumentObject *pObject, const xiiAbstractProperty *pProp, xiiDeque< xiiAbstractGraphDiffOperation > &out_diff)=0
 Queries an array of diff operations that can be executed to revert the object container.
 
virtual bool IsDefaultValue (SuperArray superPtr, xiiObjectAccessorBase *pAccessor, const xiiDocumentObject *pObject, const xiiAbstractProperty *pProp, xiiVariant index=xiiVariant())
 
virtual xiiStatus RevertProperty (SuperArray superPtr, xiiObjectAccessorBase *pAccessor, const xiiDocumentObject *pObject, const xiiAbstractProperty *pProp, xiiVariant index=xiiVariant())
 
virtual xiiStatus RevertObjectContainer (SuperArray superPtr, xiiObjectAccessorBase *pAccessor, const xiiDocumentObject *pObject, const xiiAbstractProperty *pProp)
 
- Public Member Functions inherited from xiiRefCounted
virtual ~xiiRefCounted ()=default
 Adds a virtual destructor.
 
- Public Member Functions inherited from xiiRefCountingImpl
 xiiRefCountingImpl ()=default
 Constructor.
 
 xiiRefCountingImpl (const xiiRefCountingImpl &rhs)
 
void operator= (const xiiRefCountingImpl &rhs)
 
xiiUInt32 AddRef () const
 Increments the reference counter. Returns the new reference count.
 
xiiUInt32 ReleaseRef () const
 Decrements the reference counter. Returns the new reference count.
 
bool IsReferenced () const
 Returns true if the reference count is greater than 0, false otherwise.
 
xiiUInt32 GetRefCount () const
 Returns the current reference count.
 

Static Public Member Functions

static bool DoesVariantMatchProperty (const xiiVariant &value, const xiiAbstractProperty *pProp, xiiVariant index=xiiVariant())
 A sanity check function that verifies that a given variant's value matches that expected of the property at the given index. If index is invalid and the property a container, the value must be an array or dictionary of the property's type.
 

Detailed Description

Interface for querying and restoring the default state of objects and containers.

The high level functions IsDefaultValue, RevertProperty, RevertObjectContainer don't need to be overwritten in most cases. Instead, just implementing the pure virtual methods is enough.

Member Typedef Documentation

◆ SuperArray

Parent hierarchy of state providers.

xiiDefaultContainerState and xiiDefaultObjectState will build a hierarchy of parent default state providers depending on the root depth of all available providers (this is like virtual function overrides but with dynamic parent classes). If a provider can't handle a request, it should forward it to the first element in the superPtr array and pass in superPtr.GetSubArray(1) to that function call. Note that generally you don't need to check for validity of the ptr as the xiiAttributeDefaultStateProvider has root depth of -1 and will thus always be the last one in line.

Member Function Documentation

◆ CreateRevertContainerDiff()

virtual xiiStatus xiiDefaultStateProvider::CreateRevertContainerDiff ( SuperArray superPtr,
xiiObjectAccessorBase * pAccessor,
const xiiDocumentObject * pObject,
const xiiAbstractProperty * pProp,
xiiDeque< xiiAbstractGraphDiffOperation > & out_diff )
pure virtual

Queries an array of diff operations that can be executed to revert the object container.

Parameters
superPtrsuperPtr Parent hierarchy of inner providers that should be called of this instance cannot handle the request. See SuperArray definition for details.
pAccessorpAccessor Accessor to be used for querying object values if necessary. Always valid.
pObjectpObject The object which is to be reverted. Always valid.
pProppProp The container property which is to be reverted. Always valid.
out_diffAn array of diff operations that should be executed via xiiDocumentObjectConverterReader::ApplyDiffToObject to revert the object / container to its default state.
Returns
If failure is returned, the operation failed and the undo transaction should be canceled.
See also
xiiDocumentObjectConverterReader::ApplyDiffToObject

Implemented in xiiAttributeDefaultStateProvider, xiiDynamicDefaultStateProvider, xiiExposedParametersDefaultStateProvider, and xiiPrefabDefaultStateProvider.

◆ GetBackgroundColor()

virtual xiiColorGammaUB xiiDefaultStateProvider::GetBackgroundColor ( ) const
pure virtual

Returns a color to be used in the property grid. Only the hue of the color is used. If alpha is 0, the color is ignored and no tinting of the property grid takes place.

Implemented in xiiAttributeDefaultStateProvider, xiiDynamicDefaultStateProvider, xiiExposedParametersDefaultStateProvider, and xiiPrefabDefaultStateProvider.

◆ GetDefaultValue()

virtual xiiVariant xiiDefaultStateProvider::GetDefaultValue ( SuperArray superPtr,
xiiObjectAccessorBase * pAccessor,
const xiiDocumentObject * pObject,
const xiiAbstractProperty * pProp,
xiiVariant index = xiiVariant() )
pure virtual

Returns the default value of an object's property at a given index.

Parameters
superPtrParent hierarchy of inner providers that should be called of this instance cannot handle the request. See SuperArray definition for details.
pAccessorAccessor to be used for querying object values if necessary. Always valid.
pObjectThe object for which the default value should be queried. Always valid.
pPropThe property for which the default value should be queried. Always valid.
indexFor containers: If the index is valid, the container element's default value is requested. If not, the entire container (either array or dictionary) is requested.
Returns
The default value. xiiReflectionUtils::GetDefaultValue is a good example what is expected to be returned.
See also
xiiReflectionUtils::GetDefaultValue, xiiDefaultStateProvider::DoesVariantMatchProperty

Implemented in xiiAttributeDefaultStateProvider, xiiDynamicDefaultStateProvider, xiiExposedParametersDefaultStateProvider, and xiiPrefabDefaultStateProvider.

◆ GetRootDepth()

virtual xiiInt32 xiiDefaultStateProvider::GetRootDepth ( ) const
pure virtual

Returns the root depth of this provider instance.

This is through how many properties and objects we needed to pass through from the object and property passed into the factory method to find the root object / property that this provider represents. For example if we have this object hierarchy: A |-children- B |-elements- C

If A is a prefab and the factory method was called for C (with no property) then we need to walk up the hierarchy via elements container, the B object, the children container and then finally A. Thus, we need 4 hops to get the the prefab root which means the root depth for this provider instance is 4.

Implemented in xiiAttributeDefaultStateProvider, xiiDynamicDefaultStateProvider, xiiExposedParametersDefaultStateProvider, and xiiPrefabDefaultStateProvider.

◆ GetStateProviderName()

virtual xiiString xiiDefaultStateProvider::GetStateProviderName ( ) const
pure virtual

Returns the name of this state provider. Can be used to check what the outer most provider is for GUI purposes.

Implemented in xiiAttributeDefaultStateProvider, xiiDynamicDefaultStateProvider, xiiExposedParametersDefaultStateProvider, and xiiPrefabDefaultStateProvider.


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