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:

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))

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 Result< DataGetOwner () const
 
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 HIERARCHY::template Parent< Interface >::type GetParent () const
 
MAXON_METHOD HIERARCHY::template Sibling< Interface >::type GetNext () const
 
MAXON_METHOD HIERARCHY::template Sibling< Interface >::type GetPrev () const
 
MAXON_METHOD void ParentChanged (Bool removed)
 
 MAXON_OBSERVABLE (Result< void >, ObservableHierarchyInsert,(const HierarchyObjectRef<> &sender, const HierarchyObjectRef<> &object), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (Result< void >, ObservableHierarchyRemove,(const HierarchyObjectRef<> &sender, const HierarchyObjectRef<> &object), ObservableCombinerRunAllComponent)
 

Private Member Functions

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

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( HierarchyObjectInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.hierarchyobject"   
)
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, methodId="InsertBefore@c3fe8c32c67820f6"->"InsertBefore@62454b3823c81bf2"}

◆ 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, methodId="InsertAfter@c3fe8c32c67820f6"->"InsertAfter@62454b3823c81bf2"}

◆ 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 optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertAsFirstChildOf@f9dc7b22971a5d68"->"InsertAsFirstChildOf@102e044c15f5ab6e"}

◆ 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 optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertAsLastChildOf@f9dc7b22971a5d68"->"InsertAsLastChildOf@102e044c15f5ab6e"}

◆ 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 optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertAsChildAt@d7661a010b96b80b"->"InsertAsChildAt@ea13e24df06f9311"}

◆ 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 optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertChildAsFirst@78cfce42ca9ca78c"->"InsertChildAsFirst@102e044c15f5ab6e"}

◆ 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 optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertChildAsLast@78cfce42ca9ca78c"->"InsertChildAsLast@102e044c15f5ab6e"}

◆ 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 optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertChildAt@383db2fbc2df502f"->"InsertChildAt@ea13e24df06f9311"}

◆ 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]childrenParent object under which the object should be inserted.
[in]branchIdDefines the optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertChildrenAsFirst@07fadb8f8931912e"->"InsertChildrenAsFirst@86618450ea9ca0ec"}

◆ 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]childrenParent object under which the object should be inserted.
[in]branchIdDefines the optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertChildrenAsLast@07fadb8f8931912e"->"InsertChildrenAsLast@86618450ea9ca0ec"}

◆ 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 bbe 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]childrenParent 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 optional branch to which the children belongs to.
Returns
OK on success. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="InsertChildrenAt@f553b7ebf3c298d1"->"InsertChildrenAt@1acb74f98583998f"}

◆ 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, methodId="Replace@c3fe8c32c67820f6"->"Replace@62454b3823c81bf2"}

◆ Remove()

Remove this object from the hierarchy, including all descendants.

Returns
This object including the descendants hierarchy. @MAXON_ANNOTATION{methodId="Remove@170d2d4035a37642"->"Remove@0a69c52cd1f871c4"}

◆ RemoveChildren()

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

Remove 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 the optional branch to which the children belongs to.
Returns
Descendants hierarchy. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="RemoveChildren@f2c30f6fa85ad950"->"RemoveChildren@073ee856ce7033e4"}

◆ RemoveAllChildren()

MAXON_METHOD void RemoveAllChildren ( )

Remove all descendants from the hierarchy.

◆ GetOwner()

MAXON_METHOD Result<Data> GetOwner ( ) const

Returns the owner of this object (and the whole hierarchy).

Returns
Owner of hierarchy.

◆ GetFirstChild()

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

Returns the first child of this object.

Parameters
[in]branchIdDefines the optional branch to which the children belongs to.
Returns
Child object or nullptr if not available. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="GetFirstChild@659ede85630050ea"->"GetFirstChild@e09e2282ff9648d6"}

◆ GetLastChild()

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

Returns the last child of this object.

Parameters
[in]branchIdDefines the optional branch to which the children belongs to.
Returns
Child object or nullptr if not available. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="GetLastChild@659ede85630050ea"->"GetLastChild@e09e2282ff9648d6"}

◆ 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]branchIdDefines the optional branch to which the children belongs to.
Returns
Child object or nullptr if not available. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="GetChildAt@ccf5aa5f8df8fea7"->"GetChildAt@6e9146707db92093"}

◆ 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]branchIdDefines the optional branch to which the children belongs to. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="GetChildren@82b1e42d9879cc5d"->"GetChildren@a322b1e0ff7d4a03"}

◆ GetBranches()

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

Returns all branches of the given hierarchy.

◆ GetParent()

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

Returns the parent of this object. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="GetParent@039201505769407c"->"GetParent@42cee06d6d15c6f6"}

◆ GetNext()

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

Returns the next sibling of this object. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="GetNext@13c3e32f7298ccfc"->"GetNext@42cee06d6d15c6f6"}

◆ GetPrev()

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

Returns the previous sibling of this object. @MAXON_ANNOTATION{interfaceParameter=Interface, methodId="GetPrev@13c3e32f7298ccfc"->"GetPrev@42cee06d6d15c6f6"}

◆ 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).

◆ MAXON_OBSERVABLE() [1/2]

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

ObservableHierarchyInsert is sent whenever an object was inserted in the hierarchy.

Parameters
[in]senderSender object.
[in]objectHierarchyObject which was added.

◆ MAXON_OBSERVABLE() [2/2]

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

ObservableHierarchyRemove is sent whenever an object was removed from the hierarchy.

Parameters
[in]senderSender object.
[in]objectHierarchyObject which was removed.
maxon::IMAGEHIERARCHY::LAYER
Adds an image layer to a image. Layers are only allowed under Images or other layers.
maxon::IMAGEHIERARCHY::ALPHA
Adds an alpha to a image. Alphas are allowed to insert under images.
maxon::MAXON_ENUM_LIST
struct maxon::ABIParamType MAXON_ENUM_LIST
maxon::IMAGEHIERARCHY::TEXTURE
Root of everything. Must not be used with AddChildren.
maxon::IMAGEHIERARCHY
IMAGEHIERARCHY
used by ImageBaseInterface to add layers/alphas/images to the right sub tree in the hierarchy.
Definition: gfx_image.h:107
maxon::IMAGEHIERARCHY::MAX_ELEMENTS
maxon::IMAGEHIERARCHY::MASK
Adds a layer mask to a layer. Layer masks are allowed to insert under layers (layer mask).
maxon::IMAGEHIERARCHY::IMAGE
Adds a subImage to a texture. Images are only allowed under Textures.