About
A GeListHead object is the root of a list or tree of GeListNode elements. See also GeListNode Manual.
GeListHead objects are an instance of ID_LISTHEAD
.
Allocation/Deallocation
GeListHead objects can be created with the usual tools:
- GeListHead::Alloc(): Creates a new GeListHead.
- GeListHead::Free(): Destroys the given GeListHead.
The creation of GeListHead objects is typically only needed in custom NodeData based plugin classes that internally store custom objects (see also Heads and Branches).
Access
It is possible to get the root GeListHead from every member of that list or tree:
- GeListNode::GetListHead(): Returns the GeListHead root of the element's list or tree.
doc->GetSelection(selection);
for (
Int32 i = 0;
i < selection->GetCount(); ++
i)
{
C4DAtom*
const atom = selection->GetIndex(
i);
continue;
GeListNode*
const node =
static_cast<GeListNode*
>(
atom);
GeListHead*
const head =
node->GetListHead();
if (head != nullptr)
{
GeListNode* const child = head->GetFirst();
{
const BaseList2D* const child2D = static_cast<BaseList2D*>(child);
}
}
}
Py_ssize_t i
Definition: abstract.h:645
#define atom
Definition: graminit.h:72
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
#define Tbaselist2d
2D list.
Definition: ge_prepass.h:995
#define Tgelistnode
Node list.
Definition: ge_prepass.h:999
maxon::Int32 Int32
Definition: ge_sys_math.h:51
const char * doc
Definition: pyerrors.h:226
GeListHead objects can also be obtained using GeListNode::GetBranchInfo():
const Int32 branchCount = branches.GetCount();
{
const String branchName = branches[
i].name;
const GeListHead* branchHead = branches[
i].head;
if (branchHead != nullptr)
{
const GeListNode* child = branchHead->GetFirst();
{
const BaseList2D* child2D = static_cast<const BaseList2D*>(child);
}
}
}
ONLYWITHCHILDREN
Only return branch if it is in use, i.e. has content.
Definition: ge_prepass.h:1
typename BufferedBaseArraySelector< COUNT, MINCHUNKSIZE, MEMFLAGS, ALLOCATOR >::template Type< T > BufferedBaseArray
Definition: basearray.h:1814
#define iferr_return
Definition: resultbase.h:1531
See also GeListNode Heads and Branches and BaseList2D::GetMain() at BaseList2D Read-Only Properties.
Navigation
GeListHead itself is based on GeListNode. So instances of GeListHead can be organized in a list or tree:
- GeListHead::InsertBefore(): Inserts the element before the given GeListNode in the list.
- GeListHead::InsertAfter(): Inserts the element after the given GeListNode in the list.
- GeListHead::InsertUnder(): Inserts the element under the given GeListNode.
- GeListHead::InsertUnderLast(): Inserts the element as the last child element under the given GeListNode.
- GeListHead::Remove(): Removes the element from the list or tree.
See Edit Lists and Trees.
Parent
The parent of a GeListHead instance is typically the object that owns that instance/branch.
- GeListHead::SetParent(): Sets the parent of the GeListHead.
- GeListHead::GetParent(): Returns the parent of the GeListHead.
GeListHead::SetParent() is normally used directly after the creation of a GeListHead instance.
_branchHead = GeListHead::Alloc();
if (_branchHead == nullptr)
return false;
_branchHead->SetParent(
node);
_branchName = ::String { "My Branch" };
List Content
A GeListHead is a root of a list of GeListNode elements. These elements can be obtained with:
- GeListHead::GetFirst(): Returns the first element of the list.
- GeListHead::GetLast(): Returns the last element of the list.
New elements can be added to the list with:
- GeListHead::InsertFirst(): Inserts the given element as the first element of the list.
- GeListHead::InsertLast(): Inserts the given element as the last element of the list.
- GeListHead::Insert(): Inserts the given element as a child or after another elements.
All elements of a list can easily be deleted with:
- GeListHead::FlushAll(): Clears the list. The list elements will be properly deallocated.
if (marker != nullptr)
{
GeListHead* const head = marker->GetListHead();
if (head == nullptr)
head->FlushAll();
}
BaseList2D * GetFirstMarker(BaseDocument *doc)
Further Reading