#include <TreeItem.h>
Public Member Functions | |
TreeItem (const PAYLOAD &val, TreeItem< PAYLOAD > *parent=0) | |
virtual | ~TreeItem () |
const PAYLOAD & | value () const |
void | setValue (PAYLOAD newValue) |
TreeItem< PAYLOAD > * | parent () const |
TreeItem< PAYLOAD > * | next () const |
TreeItem< PAYLOAD > * | firstChild () const |
void | setParent (TreeItem< PAYLOAD > *newParent) |
void | setNext (TreeItem< PAYLOAD > *newNext) |
void | setFirstChild (TreeItem< PAYLOAD > *newFirstChild) |
void | addChild (TreeItem< PAYLOAD > *newChild) |
Protected Member Functions | |
TreeItem (PAYLOAD val, bool autoAddChild, TreeItem< PAYLOAD > *parent=0) | |
Protected Attributes | |
PAYLOAD | _value |
TreeItem< PAYLOAD > * | _parent |
TreeItem< PAYLOAD > * | _next |
TreeItem< PAYLOAD > * | _firstChild |
Template class for tree items that can handle tree children in a generic way - firstChild(), next() and parent(). Each item stores one value of type 'PAYLOAD'.
Class 'PAYLOAD' needs to provide operator=().
|
inline |
Constructor. Creates a new tree item with value "val" and inserts it ( without maintaining any meaningful sort order! ) into the children list of "parent".
|
inlineprotected |
Constructor to be called for derived classes: Decide whether or not to automatically insert this item into the parent's children list. Useful for derived classes that want to maintain a specific sort order among children.
Destructor. Takes care of children - they will be deleted along with this item.
Add a child to the internal children list - usually called from within the child's default constructor.
This default method does not maintain any meaningful sorting order - derived classes that require this might want to use the other constructor ( with 'autoAddChild' set to 'false' ) take care of child insertion themselves.
Returns this item's first child or 0 if there is none.
Returns this item's next sibling or 0 if there is none.
Returns this item's parent or 0 if there is none.
|
inline |
Sets this item's first child.
Sets this item's next sibling.
|
inline |
Sets this item's parent.
|
inline |
Set this item's value, the "payload".
If the sort order among children of one level is important, overwrite this method and change the sort order according to the new value. The template class itself never calls this.
|
inline |
Returns this item's value, the "payload".