HierarchyObjectInterface Class Reference

#include <hierarchyobject.h>

Inheritance diagram for HierarchyObjectInterface:

Detailed Description

Object that allows to create hierarchical tree like structures.

An object can have siblings and branches with children. By default the children are all stored in the default branch branchId == ConstDataPtr(). But you can add as many branches to categorize and separate different flavors of children. You can do this by defining different branches like in this example:

enum class IMAGEHIERARCHY
{
MASK,
MASK
A mask for all regular flags.
Definition: assets.h:6
MAX_ELEMENTS
Definition: gfx_image.h:6
TEXTURE
Root of everything. Must not be used with AddChildren.
Definition: gfx_image.h:1
IMAGEHIERARCHY
used by ImageBaseInterface to add layers/alphas/images to the right sub tree in the hierarchy.
Definition: gfx_image.h:109
struct maxon::AssetSortData MAXON_ENUM_LIST
LAYER
Layer mode.
Definition: lib_activeobjectmanager.h:17
ALPHA
Definition: lib_birender.h:3
IMAGE
Filename Image input, one DescID.
Definition: lib_substance.h:9

You can then pass the branch to one of the functions below by replacing the default ConstDataPtr() by a different id. This example will return the first child of IMAGEHIERARCHY::IMAGE branch.

HierarchyObjectRef child = object.GetFirstChild(ConstDataPtr(IMAGEHIERARCHY::IMAGE))
@ IMAGE
Adds a subImage to a texture. Images are only allowed under Textures.

Public Member Functions

MAXON_METHOD Result< void > InsertBefore (const typename HIERARCHY::template Sibling< Interface >::type &nextSibling)
 
MAXON_METHOD Result< void > InsertAfter (const typename HIERARCHY::template Sibling< Interface >::type &prevSibling)
 
MAXON_METHOD Result< void > InsertAsFirstChildOf (const typename HIERARCHY::template Parent< Interface >::type &parent, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > InsertAsLastChildOf (const typename HIERARCHY::template Parent< Interface >::type &parent, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > InsertAsChildAt (const typename HIERARCHY::template Parent< Interface >::type &parent, Int position, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > InsertChildAsFirst (const typename HIERARCHY::template Child< Interface >::type &child, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > InsertChildAsLast (const typename HIERARCHY::template Child< Interface >::type &child, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > InsertChildAt (const typename HIERARCHY::template Child< Interface >::type &child, Int position, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > InsertChildrenAsFirst (const Block< const typename HIERARCHY::template Child< Interface >::type > &children, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > InsertChildrenAsLast (const Block< const typename HIERARCHY::template Child< Interface >::type > &children, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > InsertChildrenAt (const Block< const typename HIERARCHY::template Child< Interface >::type > &children, Int position, const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD Result< void > Replace (const typename HIERARCHY::template Sibling< Interface >::type &newObject)
 
MAXON_METHOD HierarchyObjectRef Remove ()
 
MAXON_METHOD HIERARCHY::template Child< Interface >::type RemoveChildren (const ConstDataPtr &branchId=ConstDataPtr())
 
MAXON_METHOD void RemoveAllChildren ()
 
MAXON_METHOD HIERARCHY::template Child< Interface >::type GetFirstChild (const ConstDataPtr &branchId=ConstDataPtr()) const
 
MAXON_METHOD HIERARCHY::template Child< Interface >::type GetLastChild (const ConstDataPtr &branchId=ConstDataPtr()) const
 
MAXON_METHOD HIERARCHY::template Child< Interface >::type GetChildAt (Int position, const ConstDataPtr &branchId=ConstDataPtr()) const
 
MAXON_METHOD Result< BaseArray< typename HIERARCHY::template Child< Interface >::type > > GetChildren (const ConstDataPtr &branchId=ConstDataPtr()) const
 
MAXON_METHOD Result< BaseArray< ConstDataPtr > > GetBranches () const
 
MAXON_METHOD ConstDataPtr GetBranchId () const
 
MAXON_METHOD void SetLocking (const Bool locking)
 
MAXON_METHOD Bool IsLocked () const
 
MAXON_METHOD HIERARCHY::template Parent< Interface >::type GetParent () const
 
MAXON_METHOD std::add_pointer< HierarchyObjectInterface >::type GetParentPtr () const
 
MAXON_METHOD HIERARCHY::template Sibling< Interface >::type GetNext () const
 
MAXON_METHOD HIERARCHY::template Sibling< Interface >::type GetPrev () const
 
MAXON_METHOD HIERARCHY::template Sibling< Interface >::type GetFirst () const
 
MAXON_METHOD HIERARCHY::template Sibling< Interface >::type GetLast () const
 
MAXON_METHOD void ParentChanged (Bool removed)
 
MAXON_METHOD std::add_pointer< HierarchyObjectInterface >::type FindNextLeaf (const HierarchyObjectInterface *stopAtParent) const
 
 MAXON_OBSERVABLE (Result< void >, ObservableHierarchyInsert,(const HierarchyObjectRef<> &sender, const HierarchyObjectRef<> &object, const ConstDataPtr &branchId), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (Result< void >, ObservableHierarchyRemove,(const HierarchyObjectRef<> &sender, const HierarchyObjectRef<> &object, const ConstDataPtr &branchId), ObservableCombinerRunAllComponent)
 
MAXON_METHOD void FlushBranches ()
 

Private Member Functions

 MAXON_INTERFACE (HierarchyObjectInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.hierarchyobject", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel"))
 
 MAXON_GENERIC (typename HIERARCHY=DefaultHierarchy< void >)
 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( HierarchyObjectInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.hierarchyobject"  ,
MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel")   
)
private

◆ MAXON_GENERIC()

MAXON_GENERIC ( typename HIERARCHY  = DefaultHierarchy< void >)
private

◆ InsertBefore()

MAXON_METHOD Result<void> InsertBefore ( const typename HIERARCHY::template Sibling< Interface >::type nextSibling)

Inserts this object (including its children and next siblings, if any) into the hierarchy as the previous sibling of nextSibling. Before invocation, nextSibling needs to have either a previous sibling or a parent object, which will get the ownership of this object. This object will take over the ownership of nextSibling.

This object mustn't have a parent or a previous sibling.

Parameters
[in]nextSiblingAn object which shall become the next sibling of this object.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertAfter()

MAXON_METHOD Result<void> InsertAfter ( const typename HIERARCHY::template Sibling< Interface >::type prevSibling)

Inserts this object (including its children and next siblings, if any) into the hierarchy as the next sibling of prevSibling. prevSibling gets the ownership of this object.

This object mustn't have a parent or a previous sibling.

Parameters
[in]prevSiblingAnother object of which this object shall become the next sibling.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertAsFirstChildOf()

MAXON_METHOD Result<void> InsertAsFirstChildOf ( const typename HIERARCHY::template Parent< Interface >::type parent,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert this object (including its children and next siblings, if any) as the first child of the given parent object. The parent object gets the ownership of this object.

This object mustn't have a parent or a previous sibling.

Parameters
[in]parentParent object under which the object should be inserted.
[in]branchIdDefines the branch the child belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertAsLastChildOf()

MAXON_METHOD Result<void> InsertAsLastChildOf ( const typename HIERARCHY::template Parent< Interface >::type parent,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert this object (including its children and next siblings, if any) as the last child of the given parent object. If there are already children existing in the given branch the last one will get ownership of this object. Otherwise the parent object gets the ownership of this object.

This object mustn't have a parent or a previous sibling.

Parameters
[in]parentParent object under which the object should be inserted.
[in]branchIdDefines the branch the child belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertAsChildAt()

MAXON_METHOD Result<void> InsertAsChildAt ( const typename HIERARCHY::template Parent< Interface >::type parent,
Int  position,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert this object (including its children and next siblings, if any) as a child of the given parent position. For example if you specify a position of 3 and there are already 5 children existing the object will be inserted between the previously second and third child. If you specify a position of 1 the object will be inserted as the first child.

If a next sibling exists, this object gets ownership of the next sibling. If a previous sibling exists, the previous sibling gets the ownership of this object. Otherwise the parent object gets the ownership of this object.

This object mustn't have a parent or a previous sibling.

Parameters
[in]parentParent object under which the object should be inserted.
[in]positionA child of parent which shall become the next sibling of this object, or nullptr if this object shall become the last child.
[in]branchIdDefines the branch the child belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertChildAsFirst()

MAXON_METHOD Result<void> InsertChildAsFirst ( const typename HIERARCHY::template Child< Interface >::type child,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert a child object (including its children and next siblings, if any) as the first child of this object. This object gets the ownership of the given child.

The child object mustn't have a parent or a previous sibling.

Parameters
[in]childParent object under which the object should be inserted.
[in]branchIdDefines the branch the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertChildAsLast()

MAXON_METHOD Result<void> InsertChildAsLast ( const typename HIERARCHY::template Child< Interface >::type child,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert a child object (including its children and next siblings, if any) as the last child of this object. If there are already children existing in the given branch the last one will get ownership of the given child object. Otherwise this object gets the ownership of the given child.

The child object mustn't have a parent or a previous sibling.

Parameters
[in]childParent object under which the object should be inserted.
[in]branchIdDefines the branch the child belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertChildAt()

MAXON_METHOD Result<void> InsertChildAt ( const typename HIERARCHY::template Child< Interface >::type child,
Int  position,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert a child object (including its children and next siblings, if any) as the given child position of this object. For example if you specify a position of 3 and there are already 5 children existing the child object will be inserted between the previously second and third child. If you specify a position of 1 the given child object will be inserted as the first child.

If a next sibling exists, the given child object gets ownership of the next sibling. If a previous sibling exists, the previous sibling gets the ownership of the given child object. Otherwise this object gets the ownership of the given child object.

The child object mustn't have a parent or a previous sibling.

Parameters
[in]childParent object under which the object should be inserted.
[in]positionA child of parent which shall become the next sibling of this object, or nullptr if this object shall become the last child.
[in]branchIdDefines the branch the child belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertChildrenAsFirst()

MAXON_METHOD Result<void> InsertChildrenAsFirst ( const Block< const typename HIERARCHY::template Child< Interface >::type > &  children,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert a list of child objects (including its children and next siblings, if any) as the first child of this object. This object gets the ownership of the given children.

Each child object mustn't have a parent or a previous sibling.

Parameters
[in]childrenBlock of children.
[in]branchIdDefines the branch the children belong to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertChildrenAsLast()

MAXON_METHOD Result<void> InsertChildrenAsLast ( const Block< const typename HIERARCHY::template Child< Interface >::type > &  children,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert a list of child objects (including its children and next siblings, if any) as the last child of this object. If there are already children existing in the given branch the last one will get ownership of the given children objects. Otherwise this object gets the ownership of the given children.

Each child object mustn't have a parent or a previous sibling.

Parameters
[in]childrenBlock of children.
[in]branchIdDefines the branch the children belong to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ InsertChildrenAt()

MAXON_METHOD Result<void> InsertChildrenAt ( const Block< const typename HIERARCHY::template Child< Interface >::type > &  children,
Int  position,
const ConstDataPtr branchId = ConstDataPtr() 
)

Insert a list of children objects (including its children and next siblings, if any) as the given child position of this object. For example if you specify a position of 3 and there are already 5 children existing the children will be inserted between the previously second and third child. If you specify a position of 1 the given children will be inserted as the first child.

If a next sibling exists, the last children object gets ownership of the next sibling. If a previous sibling exists, the previous sibling gets the ownership of the given children objects. Otherwise this object gets the ownership of the given children.

Each child object mustn't have a parent or a previous sibling.

Parameters
[in]childrenBlock of children.
[in]positionA child of parent which shall become the next sibling of this object, or nullptr if this object shall become the last child.
[in]branchIdDefines the branch the children belong to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ Replace()

MAXON_METHOD Result<void> Replace ( const typename HIERARCHY::template Sibling< Interface >::type newObject)

Replace this object with the new one and remove it from the hierarchy. The new object will have the same prev/next siblings and descendants like this object.

Returns
This object including the descendants hierarchy. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ Remove()

Removes this object from the hierarchy, including all descendants.

Returns
This object including the descendants hierarchy.

◆ RemoveChildren()

MAXON_METHOD HIERARCHY::template Child<Interface>::type RemoveChildren ( const ConstDataPtr branchId = ConstDataPtr())

Removes all descendants from the given branch hierarchy. The descendants hierarchy is returned as a reference which has the ownership of the descendants.

Parameters
[in]branchIdDefines from which branch the children are removed.
Returns
Descendants hierarchy. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ RemoveAllChildren()

MAXON_METHOD void RemoveAllChildren ( )

Removes all descendants from the hierarchy including all branches.

◆ GetFirstChild()

MAXON_METHOD HIERARCHY::template Child<Interface>::type GetFirstChild ( const ConstDataPtr branchId = ConstDataPtr()) const

Returns the first child of this object.

Parameters
[in]branchIdThe branch.
Returns
Child object or nullptr if not available. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ GetLastChild()

MAXON_METHOD HIERARCHY::template Child<Interface>::type GetLastChild ( const ConstDataPtr branchId = ConstDataPtr()) const

Returns the last child of this object.

Parameters
[in]branchIdThe branch.
Returns
Child object or nullptr if not available. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ GetChildAt()

MAXON_METHOD HIERARCHY::template Child<Interface>::type GetChildAt ( Int  position,
const ConstDataPtr branchId = ConstDataPtr() 
) const

Returns the n'th child of this object.

Parameters
[in]positionThe child position.
[in]branchIdThe branch.
Returns
Child object or nullptr if not available. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ GetChildren()

MAXON_METHOD Result<BaseArray<typename HIERARCHY::template Child<Interface>::type> > GetChildren ( const ConstDataPtr branchId = ConstDataPtr()) const

Returns all children of the given hierarchy.

Parameters
[in]branchIdThe branch. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ GetBranches()

MAXON_METHOD Result<BaseArray<ConstDataPtr> > GetBranches ( ) const

Returns all branches of the given hierarchy.

◆ GetBranchId()

MAXON_METHOD ConstDataPtr GetBranchId ( ) const

Returns the branch the object belongs to.

◆ SetLocking()

MAXON_METHOD void SetLocking ( const Bool  locking)

Set the locking of an object. If the object is locked it cannot be removed or changed in the hierarchy.

◆ IsLocked()

MAXON_METHOD Bool IsLocked ( ) const

Get the locking of an object. If the object is locked it cannot be removed or changed in the hierarchy.

Returns
True if locked.

◆ GetParent()

MAXON_METHOD HIERARCHY::template Parent<Interface>::type GetParent ( ) const

Returns the parent of this object. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ GetParentPtr()

MAXON_METHOD std::add_pointer<HierarchyObjectInterface>::type GetParentPtr ( ) const

TODO: (Sven) check if this is useful or if maybe its better to return const REFTYPE& (for GetParent, GetNext, GetPrev)

◆ GetNext()

MAXON_METHOD HIERARCHY::template Sibling<Interface>::type GetNext ( ) const

Returns the next sibling of this object. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ GetPrev()

MAXON_METHOD HIERARCHY::template Sibling<Interface>::type GetPrev ( ) const

Returns the previous sibling of this object. @MAXON_ANNOTATION{interfaceParameter=Interface}

◆ GetFirst()

MAXON_METHOD HIERARCHY::template Sibling<Interface>::type GetFirst ( ) const

Returns the first sibling of this chain. If the object is already the first element the object is returned;

◆ GetLast()

MAXON_METHOD HIERARCHY::template Sibling<Interface>::type GetLast ( ) const

Returns the last sibling of this chain. If the object is already the first element the object is returned;

◆ ParentChanged()

MAXON_METHOD void ParentChanged ( Bool  removed)

Is invoked whenever the parent of this object changes. This method can be overridden when special actions have to be taken on such a change, for example the update of an underlying hierarchy which has to be kept in sync with this hierarchy.

This method must not be invoked by user code.

Parameters
[in]removedFlag if the object has been removed (true) or inserted (false).

◆ FindNextLeaf()

MAXON_METHOD std::add_pointer<HierarchyObjectInterface>::type FindNextLeaf ( const HierarchyObjectInterface stopAtParent) const

◆ MAXON_OBSERVABLE() [1/2]

MAXON_OBSERVABLE ( Result< void >  ,
ObservableHierarchyInsert  ,
(const HierarchyObjectRef<> &sender, const HierarchyObjectRef<> &object, const ConstDataPtr &branchId)  ,
ObservableCombinerRunAllComponent   
)

ObservableHierarchyInsert is sent whenever an object was inserted in the hierarchy. Note: The children and siblings of the object are not sent as an observable!

Parameters
[in]senderSender object.
[in]objectHierarchyObject which was added.
[in]branchIdThe branch the object belongs to.

◆ MAXON_OBSERVABLE() [2/2]

MAXON_OBSERVABLE ( Result< void >  ,
ObservableHierarchyRemove  ,
(const HierarchyObjectRef<> &sender, const HierarchyObjectRef<> &object, const ConstDataPtr &branchId)  ,
ObservableCombinerRunAllComponent   
)

ObservableHierarchyRemove is sent whenever an object was removed from the hierarchy. Note: The children of the object are not sent as an observable!

Parameters
[in]senderSender object.
[in]objectHierarchyObject which was removed.
[in]branchIdThe branch the object belongs to.

◆ FlushBranches()

MAXON_METHOD void FlushBranches ( )

Removes all brances in the object.