Templated base class for hierarchy objects that have a parent and list of children of type T. More...
Public Member Functions | |
delegate bool | ForEachCallback (T obj) |
Callback for depth-first searches. More... | |
ksHierarchyObject () | |
Constructor. More... | |
virtual bool | AddChild (T child) |
Adds a child to the object if that does not create a circular reference. More... | |
virtual bool | InsertChild (int index, T child) |
Inserts a child at an index if that does not create a circular reference. More... | |
virtual bool | RemoveChild (T child) |
Removes a child from this object. More... | |
virtual void | Detach () |
Removes the object from its parent. Does nothing if the object has no parent. More... | |
bool | IsDescendantOf (T obj) |
Checks if an object is a descendant of this object. More... | |
void | ForEachDescendant (ForEachCallback callback) |
Iterates the descendants using depth-first search. More... | |
void | ForSelfAndDescendants (ForEachCallback callback) |
Iterates this object and its descendants using depth-first search. More... | |
Protected Member Functions | |
virtual bool | PerformAddChild (T child) |
Protected implementation of AddChild. More... | |
virtual bool | PerformInsertChild (int index, T child) |
Protected implementation of InsertChild. More... | |
virtual bool | PerformRemoveChild (T child) |
Protected implementation of RemoveChild. More... | |
virtual void | PerformDetach () |
Protected implementation of Detach. More... | |
Protected Attributes | |
T | m_parent |
ksLinkedList< T > | m_children = new ksLinkedList<T>() |
Properties | |
T | Parent [get] |
Parent. More... | |
ksConstList< T > | Children [get] |
Children More... | |
T | Root [get] |
The root ancestor of this object, or this if this object is a root. More... | |
IEnumerable< T > | Descendants [get] |
Iterator for descendants. More... | |
IEnumerable< T > | SelfAndDescendants [get] |
Iterator for this object and its descendants. More... | |
IEnumerable< T > | Ancestors [get] |
Iterator for ancestors. More... | |
IEnumerable< T > | SelfAndAncestors [get] |
Iterator for this object and its ancestors. More... | |
Templated base class for hierarchy objects that have a parent and list of children of type T.
Non-templated base class for hierarchy objects with a parent and children.
There is also a non-templated variant of ksHierarchyObject.
T |
There is also a templated variant that enforces all objects in the hierarchy derive the templated type.
T | : | ksHierarchyObject<T> |
Constructor.
|
virtual |
Adds a child to the object if that does not create a circular reference.
If the child has another parent, removes it from its parent first. Throws ArgumentNullException if the child is null.
child | Child to add. |
|
virtual |
Removes the object from its parent. Does nothing if the object has no parent.
delegate bool KS.Reactor.ksHierarchyObject< T >.ForEachCallback | ( | T | obj | ) |
Callback for depth-first searches.
obj | Object being iterated. |
void KS.Reactor.ksHierarchyObject< T >.ForEachDescendant | ( | ForEachCallback | callback | ) |
Iterates the descendants using depth-first search.
callback | Callback to call on descendants. If it returns false, will not iterate children. |
void KS.Reactor.ksHierarchyObject< T >.ForSelfAndDescendants | ( | ForEachCallback | callback | ) |
Iterates this object and its descendants using depth-first search.
callback | Callback to call on descendants. If it returns false, will not iterate children. |
|
virtual |
Inserts a child at an index if that does not create a circular reference.
If the child has another parent, removes it from its parent first. Throws ArgumentNullException if the child is null.
index | Index to insert at. |
child | Child to insert. |
bool KS.Reactor.ksHierarchyObject< T >.IsDescendantOf | ( | T | obj | ) |
Checks if an object is a descendant of this object.
obj | Object to check. |
|
protectedvirtual |
Protected implementation of AddChild.
The public AddChild calls this one. Derived classes can override either to change public or internal behaviour.
Adds a child to the object if that does not create a circular reference. If the child has another parent, removes it from its parent first. Throws ArgumentNullException if the child is null.
child | Child to add. |
|
protectedvirtual |
Protected implementation of Detach.
Removes the object from its parent. Does nothing if the object has no parent.
|
protectedvirtual |
Protected implementation of InsertChild.
The public InsertChild calls this one. Derived classes can override either to change public or internal behaviour.
Inserts a child at an index if that does not create a circular reference. If the child has another parent, removes it from its parent first. Throws ArgumentNullException if the child is null.
index | Index to insert at. |
child | Child to insert. |
|
protectedvirtual |
Protected implementation of RemoveChild.
The public RemoveChild calls this one. Derived classes can override either to change public or internal behaviour.
Removes a child from this object. Throws ArgumentNullException if child is null.
child | Child to remove. |
|
virtual |
Removes a child from this object.
Throws ArgumentNullException if child is null.
child | Child to remove. |
|
get |
Iterator for ancestors.
|
get |
Children
|
get |
Iterator for descendants.
|
get |
Parent.
|
get |
The root ancestor of this object, or this if this object is a root.
|
get |
Iterator for this object and its ancestors.
|
get |
Iterator for this object and its descendants.