#include <hierarchyobject.h>
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.
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_GENERIC (typename HIERARCHY=DefaultHierarchy< void >) | |
|
private |
|
private |
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.
[in] | nextSibling | An object which shall become the next sibling of this object. |
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.
[in] | prevSibling | Another object of which this object shall become the next sibling. |
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.
[in] | parent | Parent object under which the object should be inserted. |
[in] | branchId | Defines the branch the child belongs to. |
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.
[in] | parent | Parent object under which the object should be inserted. |
[in] | branchId | Defines the branch the child belongs to. |
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.
[in] | parent | Parent object under which the object should be inserted. |
[in] | position | A child of parent which shall become the next sibling of this object, or nullptr if this object shall become the last child. |
[in] | branchId | Defines the branch the child belongs to. |
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.
[in] | child | Parent object under which the object should be inserted. |
[in] | branchId | Defines the branch the children belongs to. |
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.
[in] | child | Parent object under which the object should be inserted. |
[in] | branchId | Defines the branch the child belongs to. |
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.
[in] | child | Parent object under which the object should be inserted. |
[in] | position | A child of parent which shall become the next sibling of this object, or nullptr if this object shall become the last child. |
[in] | branchId | Defines the branch the child belongs to. |
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.
[in] | children | Block of children. |
[in] | branchId | Defines the branch the children belong to. |
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.
[in] | children | Block of children. |
[in] | branchId | Defines the branch the children belong to. |
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.
[in] | children | Block of children. |
[in] | position | A child of parent which shall become the next sibling of this object, or nullptr if this object shall become the last child. |
[in] | branchId | Defines the branch the children belong to. |
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.
MAXON_METHOD HierarchyObjectRef Remove | ( | ) |
Removes this object from the hierarchy, including all descendants.
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.
[in] | branchId | Defines from which branch the children are removed. |
MAXON_METHOD void RemoveAllChildren | ( | ) |
Removes all descendants from the hierarchy including all branches.
MAXON_METHOD HIERARCHY::template Child<Interface>::type GetFirstChild | ( | const ConstDataPtr & | branchId = ConstDataPtr() | ) | const |
Returns the first child of this object.
[in] | branchId | The branch. |
MAXON_METHOD HIERARCHY::template Child<Interface>::type GetLastChild | ( | const ConstDataPtr & | branchId = ConstDataPtr() | ) | const |
Returns the last child of this object.
[in] | branchId | The branch. |
MAXON_METHOD HIERARCHY::template Child<Interface>::type GetChildAt | ( | Int | position, |
const ConstDataPtr & | branchId = ConstDataPtr() |
||
) | const |
Returns the n'th child of this object.
[in] | position | The child position. |
[in] | branchId | The branch. |
MAXON_METHOD Result<BaseArray<typename HIERARCHY::template Child<Interface>::type> > GetChildren | ( | const ConstDataPtr & | branchId = ConstDataPtr() | ) | const |
Returns all children of the given hierarchy.
[in] | branchId | The branch. @MAXON_ANNOTATION{interfaceParameter=Interface} |
MAXON_METHOD Result<BaseArray<ConstDataPtr> > GetBranches | ( | ) | const |
Returns all branches of the given hierarchy.
MAXON_METHOD ConstDataPtr GetBranchId | ( | ) | const |
Returns the branch the object belongs to.
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.
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.
MAXON_METHOD HIERARCHY::template Parent<Interface>::type GetParent | ( | ) | const |
Returns the parent of this object. @MAXON_ANNOTATION{interfaceParameter=Interface}
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)
MAXON_METHOD HIERARCHY::template Sibling<Interface>::type GetNext | ( | ) | const |
Returns the next sibling of this object. @MAXON_ANNOTATION{interfaceParameter=Interface}
MAXON_METHOD HIERARCHY::template Sibling<Interface>::type GetPrev | ( | ) | const |
Returns the previous sibling of this object. @MAXON_ANNOTATION{interfaceParameter=Interface}
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;
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;
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.
[in] | removed | Flag if the object has been removed (true) or inserted (false). |
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 | |||
) |
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!
[in] | sender | Sender object. |
[in] | object | HierarchyObject which was added. |
[in] | branchId | The branch the object belongs to. |
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!
[in] | sender | Sender object. |
[in] | object | HierarchyObject which was removed. |
[in] | branchId | The branch the object belongs to. |
MAXON_METHOD void FlushBranches | ( | ) |
Removes all brances in the object.