About
maxon::HierarchyObjectInterface is a base interface used to create elements that can be organized in a tree like structure. A parent element can have one or many child elements. A child element can have only one parent but none, one or many siblings.
A parent object can organize its child elements in multiple sub-branches.
Hierarchy Interface
The hierarchy interface provides functions to insert an element into a given tree structure:
const TreeElementRef root = TreeElementFactory().Create(
"root"_s)
iferr_return;
const TreeElementRef elementA = TreeElementFactory().Create(
"Element A"_s)
iferr_return;
const TreeElementRef elementB = TreeElementFactory().Create(
"Element B"_s)
iferr_return;
const TreeElementRef elementC = TreeElementFactory().Create(
"Element C"_s)
iferr_return;
for (const auto& child : children)
{
const TreeElementRef treeElement = maxon::Cast<TreeElementRef>(child);
}
const char const char * name
Definition: abstract.h:195
Definition: string.h:1235
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define iferr_return
Definition: resultbase.h:1465
Child elements can be replaced or removed:
const TreeElementRef root = TreeElementFactory().Create(
"root"_s)
iferr_return;
const TreeElementRef elementA = TreeElementFactory().Create(
"Element A"_s)
iferr_return;
const TreeElementRef elementB = TreeElementFactory().Create(
"Element B"_s)
iferr_return;
const TreeElementRef elementC = TreeElementFactory().Create(
"Element C"_s)
iferr_return;
elementA.Remove();
const TreeElementRef firstElement = maxon::Cast<TreeElementRef>(firstChild);
Definition: hierarchyobject.h:18
Within a given hierarchy level one can navigate with:
while (child)
{
if (child.IsInstanceOf<TreeElementRef>())
{
const TreeElementRef treeElement = maxon::Cast<TreeElementRef>(child);
}
child = child.GetNext();
}
The parent of an element is accessed with:
The child elements of a parent object are accessed with:
Definition: datatypebase.h:1800
These observables are called on certain events:
ObservableHierarchyInsert:
Is called when an element was inserted in the hierarchy.
ObservableHierarchyRemove:
Is called when an element was removed from the hierarchy.
To navigate through a given hierarchy one can use these utility functions:
maxon::TraverseMeAndChildren<TreeElementRef>(root,
{
return true;
maxon::TraverseChildren<TreeElementRef>(root,
{
return true;
Definition: resultbase.h:766
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
It is also possible to iterate over all elements of a hierarchy using maxon::HierarchyObjectIterator:
{
}
Definition: hierarchyobject.h:410
PyObject * element
Definition: unicodeobject.h:1016
Custom Implementations
A custom interface can be based on maxon::HierarchyObjectInterface. The resulting reference object can be organized in a tree. The default implementation of maxon::HierarchyObjectInterface is maxon::HierarchyObjectClass
.
An interface based on maxon::HierarchyObjectInterface can implement maxon::HierarchyObjectInterface::ParentChanged() to be informed when the parent of the element has changed. This function must not be called by user code.
class TreeElementImplementation :
public maxon::Component<TreeElementImplementation, TreeElementInterface>
{
public:
{
}
{
return _name;
}
{
const auto parentObject = super.GetParent();
if (!parentObject)
if (!parentObject.IsInstanceOf<TreeElementRef>())
const TreeElementRef treeElement = maxon::Cast<TreeElementRef>(parentObject);
return treeElement.GetName();
}
{
if (removed)
return;
const auto parentObject = super.GetParent();
if (parentObject.IsInstanceOf<TreeElementRef>())
{
const TreeElementRef treeElement = maxon::Cast<TreeElementRef>(parentObject);
}
}
{
}
private:
};
Definition: objectbase.h:2651
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:181
return OK
Definition: apibase.h:2667
@ NORMAL
Samples the surface as the user moves over it the SculptObject and returns a new hit point and normal...
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define MAXON_COMPONENT(KIND,...)
Definition: objectbase.h:2212
#define MAXON_METHOD
Definition: interfacebase.h:1001
Further Reading