TreeItem< PAYLOAD > Class Template Reference

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'. More...

#include <TreeItem.h>

Inheritance diagram for TreeItem< PAYLOAD >:

SortedTreeItem< PAYLOAD >

List of all members.

Public Member Functions

 T (const PAYLOAD &val, TreeItem< PAYLOAD > *parent=0)
virtual ~ ()
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)
bool isChildOf (const TreeItem< PAYLOAD > *maybeParent) const

Protected Member Functions

 T (PAYLOAD val, bool autoAddChild, TreeItem< PAYLOAD > *parent=0)

Protected Attributes

PAYLOAD _value
TreeItem< PAYLOAD > * _parent
TreeItem< PAYLOAD > * _next
TreeItem< PAYLOAD > * _firstChild

Private Member Functions

 T (const TreeItem< PAYLOAD > &)
TreeItem< PAYLOAD > & operator= (const TreeItem< PAYLOAD > &)


Detailed Description

template<class PAYLOAD>
class TreeItem< PAYLOAD >

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=().


Constructor & Destructor Documentation

template<class PAYLOAD>
virtual TreeItem< PAYLOAD >::~ (  )  [inline, virtual]

Destructor. Takes care of children - they will be deleted along with this item.

Reimplemented in SortedTreeItem< PAYLOAD >.


Member Function Documentation

template<class PAYLOAD>
TreeItem< PAYLOAD >::T ( const PAYLOAD &  val,
TreeItem< PAYLOAD > *  parent = 0 
) [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".

template<class PAYLOAD>
TreeItem< PAYLOAD >::T ( PAYLOAD  val,
bool  autoAddChild,
TreeItem< PAYLOAD > *  parent = 0 
) [inline, protected]

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.

template<class PAYLOAD>
TreeItem< PAYLOAD >::T ( const TreeItem< PAYLOAD > &   )  [inline, private]

Private (i.e. disabled) copy constructor and operator=()

template<class PAYLOAD>
TreeItem<PAYLOAD>& TreeItem< PAYLOAD >::operator= ( const TreeItem< PAYLOAD > &   )  [inline, private]

template<class PAYLOAD>
const PAYLOAD& TreeItem< PAYLOAD >::value (  )  const [inline]

Returns this item's value, the "payload".

template<class PAYLOAD>
void TreeItem< PAYLOAD >::setValue ( PAYLOAD  newValue  )  [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.

template<class PAYLOAD>
TreeItem<PAYLOAD>* TreeItem< PAYLOAD >::parent (  )  const [inline]

Returns this item's parent or 0 if there is none.

Reimplemented in SortedTreeItem< PAYLOAD >.

template<class PAYLOAD>
TreeItem<PAYLOAD>* TreeItem< PAYLOAD >::next (  )  const [inline]

Returns this item's next sibling or 0 if there is none.

Reimplemented in SortedTreeItem< PAYLOAD >.

template<class PAYLOAD>
TreeItem<PAYLOAD>* TreeItem< PAYLOAD >::firstChild (  )  const [inline]

Returns this item's first child or 0 if there is none.

Reimplemented in SortedTreeItem< PAYLOAD >.

template<class PAYLOAD>
void TreeItem< PAYLOAD >::setParent ( TreeItem< PAYLOAD > *  newParent  )  [inline]

Sets this item's parent.

template<class PAYLOAD>
void TreeItem< PAYLOAD >::setNext ( TreeItem< PAYLOAD > *  newNext  )  [inline]

Sets this item's next sibling.

template<class PAYLOAD>
void TreeItem< PAYLOAD >::setFirstChild ( TreeItem< PAYLOAD > *  newFirstChild  )  [inline]

Sets this item's first child.

template<class PAYLOAD>
void TreeItem< PAYLOAD >::addChild ( TreeItem< PAYLOAD > *  newChild  )  [inline]

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.

template<class PAYLOAD>
bool TreeItem< PAYLOAD >::isChildOf ( const TreeItem< PAYLOAD > *  maybeParent  )  const [inline]

Check if this item is direct or indirect child of 'maybeParent' - or even the same.


Member Data Documentation

template<class PAYLOAD>
PAYLOAD TreeItem< PAYLOAD >::_value [protected]

template<class PAYLOAD>
TreeItem<PAYLOAD>* TreeItem< PAYLOAD >::_parent [protected]

template<class PAYLOAD>
TreeItem<PAYLOAD>* TreeItem< PAYLOAD >::_next [protected]

template<class PAYLOAD>
TreeItem<PAYLOAD>* TreeItem< PAYLOAD >::_firstChild [protected]


The documentation for this class was generated from the following file:
Generated on Fri Sep 21 22:35:03 2007 for liby2util by  doxygen 1.5.3