libyui  3.3.2
TreeItem< PAYLOAD > Class Template Reference

Template class for tree items that can handle tree children in a generic way - firstChild(), next() and parent(). More...

#include <TreeItem.h>

Inheritance diagram for TreeItem< PAYLOAD >:

Public Member Functions

 TreeItem (const PAYLOAD &val, TreeItem< PAYLOAD > *parent=0)
 Constructor. More...
 
virtual ~TreeItem ()
 Destructor. More...
 
const PAYLOAD & value () const
 Returns this item's value, the "payload".
 
void setValue (PAYLOAD newValue)
 Set this item's value, the "payload". More...
 
TreeItem< PAYLOAD > * parent () const
 Returns this item's parent or 0 if there is none.
 
TreeItem< PAYLOAD > * next () const
 Returns this item's next sibling or 0 if there is none.
 
TreeItem< PAYLOAD > * firstChild () const
 Returns this item's first child or 0 if there is none.
 
void setParent (TreeItem< PAYLOAD > *newParent)
 Sets this item's parent.
 
void setNext (TreeItem< PAYLOAD > *newNext)
 Sets this item's next sibling.
 
void setFirstChild (TreeItem< PAYLOAD > *newFirstChild)
 Sets this item's first child.
 
void addChild (TreeItem< PAYLOAD > *newChild)
 Add a child to the internal children list - usually called from within the child's default constructor. More...
 

Protected Member Functions

 TreeItem (PAYLOAD val, bool autoAddChild, TreeItem< PAYLOAD > *parent=0)
 Constructor to be called for derived classes: Decide whether or not to automatically insert this item into the parent's children list. More...
 

Protected Attributes

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

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

Definition at line 40 of file TreeItem.h.

Constructor & Destructor Documentation

◆ TreeItem() [1/2]

template<class PAYLOAD>
TreeItem< PAYLOAD >::TreeItem ( 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".

Definition at line 49 of file TreeItem.h.

◆ TreeItem() [2/2]

template<class PAYLOAD>
TreeItem< PAYLOAD >::TreeItem ( PAYLOAD  val,
bool  autoAddChild,
TreeItem< PAYLOAD > *  parent = 0 
)
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.

Definition at line 69 of file TreeItem.h.

◆ ~TreeItem()

template<class PAYLOAD>
virtual TreeItem< PAYLOAD >::~TreeItem ( )
inlinevirtual

Destructor.

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

Definition at line 97 of file TreeItem.h.

Here is the call graph for this function:

Member Function Documentation

◆ addChild()

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.

Definition at line 165 of file TreeItem.h.

Here is the call graph for this function:

◆ setValue()

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.

Definition at line 122 of file TreeItem.h.


The documentation for this class was generated from the following file: