GCpp general purpose C++ library
version 1.0
|
#include <GTreeNodeT.hh>
Public Member Functions | |
template<class Q > | |
bool | IsInstanceOf () const |
template<class Q > | |
bool | IsInstanceOf () |
virtual GTreeNodeT< T > * | Clone () const =0 |
virtual const char * | ClassName () const |
Constructors, affectation, destructor | |
GTreeNodeT () | |
GTreeNodeT (const GTreeNodeT< T > &original) | |
virtual | ~GTreeNodeT () |
Tree structure functions | |
virtual void | SetParent (GTreeBranchT< T > *parent_ptr) |
virtual void | SetListIter (GListIterT< GTreeNodeT< T > > *iter_ptr) |
virtual const GTreeBranchT< T > * | GetParent () const |
virtual GTreeBranchT< T > * | GetParent () |
virtual const GTreeNodeT< T > * | GetRoot () const |
virtual GTreeNodeT< T > * | GetRoot () |
virtual bool | IsBranch () const |
virtual bool | IsLeaf () const |
void | SetUserData (void *data) |
void * | GetUserData () const |
virtual GListIterT< GTreeNodeT < T > > | GetListIter () const |
Tree structure exploration | |
virtual GTreeNodeT< T > * | NextNode () |
virtual GTreeLeafT< T > * | FirstLeaf () |
virtual GTreeLeafT< T > * | NextLeaf () |
virtual GTreeNodeT< T > * | FindNode (const string &name) |
virtual GTreeBranchT< T > * | FindBranch (const string &name) |
Tree construction functions | |
virtual GTreeBranchT< T > * | AddBranch (const string &bname) |
virtual GTreeBranchT< T > * | AddBranch (const string &parent, const string &bname) |
virtual GTreeLeafT< T > * | AddLeaf (T &object_ref) |
virtual GTreeLeafT< T > * | AddLeaf (const string &parent, T &object_ref) |
virtual GTreeLeafT< T > * | AddLeaf (T *object_ptr) |
virtual GTreeLeafT< T > * | AddLeaf (const string &parent, T *object_ptr) |
Element information | |
u_int | GetLevel () const |
virtual string | GetFullName () const |
virtual u_int | GetLeafCount () const =0 |
virtual u_int | GetLeafTotalCount () const =0 |
Creation of objects structures from the tree | |
virtual GNamedListT< T > * | CreateList () |
virtual GTreeNodeT< GItem > * | CreateItemTree () const =0 |
virtual GItemList * | CreateItemList () |
Print out | |
virtual void | Print (FILE *fp=stdout, const string &prefix="", bool info=false) const =0 |
![]() | |
template<class Q > | |
bool | IsInstanceOf () const |
template<class Q > | |
bool | IsInstanceOf () |
GNamed (const string &object_name="") | |
GNamed (const GNamed &object) | |
virtual | ~GNamed () |
GNamed & | operator= (const GNamed &object) |
virtual const string & | Name () const |
virtual string & | Name () |
virtual string | GetName () const |
virtual string | GetInfo () const |
virtual void | SetName (const string &object_name) |
int | Compare (const GNamed &object) const |
int | CompareDict (const GNamed &object) const |
bool | operator== (const GNamed &object) const |
bool | operator!= (const GNamed &object) const |
bool | operator< (const GNamed &object) const |
bool | operator> (const GNamed &object) const |
bool | operator<= (const GNamed &object) const |
bool | operator>= (const GNamed &object) const |
Static Public Member Functions | |
static const char * | StaticClassName () |
![]() | |
static const char * | StaticClassName () |
Protected Attributes | |
GTreeBranchT< T > * | parent |
Parent element of the tree. | |
GListIterT< GTreeNodeT< T > > * | list_iter |
Pointer to the iterator in parent list. | |
void * | user_data |
Pointer to a additional user data. | |
![]() | |
string | name |
Object name. | |
Template abstract base class to define a tree structure of objects. The tree elements inherit from the GNamed class for objects identification.
The main elements of a tree structure are:
The template class provide functions to dupplicate the tree structure, with GItem object pointing to the original tree class T objects.
Warning:
See GCpp template classes for more information about the template classes.
|
inline |
Default constructor.
References GDebugConst, GTreeNodeT< T >::list_iter, GTreeNodeT< T >::parent, and GTreeNodeT< T >::user_data.
|
inline |
Copy constructor. The pointer to the parent is not copied: if an element is copied, it is outside the tree structure.
original | object to copy |
References GDebugConst, GTreeNodeT< T >::list_iter, GTreeNodeT< T >::parent, and GTreeNodeT< T >::user_data.
|
inlinevirtual |
Destructor.
References GDebugDest.
|
inlinevirtual |
Add a sub-branch in current node (redefined in branch).
bname | name of the sub-branch |
Reimplemented in GTreeBranchT< T >.
|
virtual |
Add a sub-branch in current tree.
parent | parent branch name |
bname | name of the sub-branch |
References GTreeBranchT< T >::AddBranch().
|
inlinevirtual |
Add a leaf in current node (redefined in branch). The object is not adopted by the created leaf.
object_ref | object given by reference |
Reimplemented in GTreeBranchT< T >.
|
virtual |
Add a leaf in current tree. The object is not adopted by the created leaf.
parent | parent branch name |
object_ref | object given by reference |
References GTreeBranchT< T >::AddLeaf().
|
inlinevirtual |
Add a leaf in current node (redefined in branch). The object is adopted by the created leaf.
object_ptr | object given by pointer |
Reimplemented in GTreeBranchT< T >.
|
virtual |
Add a leaf in current tree. The object is adopted by the created leaf.
parent | parent branch name |
object_ptr | object given by pointer |
References GTreeBranchT< T >::AddLeaf().
|
virtual |
Create a list of GItem, for each leaf of the tree structure. The GItem elements refer to the data associated to the leaves. The resulting list must be deleted by the calling function.
References GItemList::AddItem(), GTreeLeafT< T >::GetDataPtr(), GTreeLeafT< T >::GetName(), GTreeNodeT< T >::NextLeaf(), and GItem::SetInfo().
|
virtual |
Create a list of objects, for each leaf of the tree structure. The list does not adopt the object pointers.
References GListT< T >::Append(), GTreeLeafT< T >::GetDataPtr(), and GTreeNodeT< T >::NextLeaf().
|
virtual |
Function searching for a branch in the tree structure. The function calls FindNode and checks that the node found is a branch.
name | name of the searched branch. |
References GTreeNodeT< T >::IsBranch().
|
virtual |
Function searching for a node in the tree structure. If name starts with '/', search from the tree root. Names "." and ".." respectively correspond to current and parent nodes. Note that the root name should not appear when searching from tree root: it is refered to by the '/' at name beginning.
name | name of the searched node. |
References GListT< GTreeNodeT< T > >::Begin(), GTreeNodeT< T >::FindNode(), GNamed::GetName(), GTreeNodeT< T >::IsBranch(), and GListT< GTreeNodeT< T > >::Null().
Referenced by GTreeNodeT< T >::FindNode().
|
virtual |
Return the first node that is a leaf in the tree structure.
References GTreeNodeT< T >::IsInstanceOf(), and GTreeNodeT< T >::NextLeaf().
|
virtual |
Return the full name of the node, including parent nodes. The name of root is not included.
|
pure virtual |
Function returning the number of leaves.
Implemented in GTreeBranchT< T >, and GTreeLeafT< T >.
|
pure virtual |
Function returning the total number of leaves, recursively in the tree structure.
Implemented in GTreeBranchT< T >, and GTreeLeafT< T >.
u_int GTreeNodeT< T >::GetLevel | ( | ) | const |
Return the hierarchy level of the object (0 means top element).
References GTreeNodeT< T >::GetParent().
|
inlinevirtual |
Return the list iterator (to this element) from the parent branch, if defined, else return a null iterator.
Referenced by GTreeNodeT< T >::NextNode().
|
inlinevirtual |
Return the tree element parent pointer.
Referenced by GTreeNodeT< T >::GetLevel(), GTreeNodeT< T >::NextNode(), GTreeLeafT< T >::Print(), and GTreeBranchT< T >::Print().
|
inlinevirtual |
Return the tree element parent pointer.
|
inlinevirtual |
Return the root (top tree) element pointer.
References GTreeNodeT< T >::GetRoot().
Referenced by GTreeNodeT< T >::GetRoot().
|
inlinevirtual |
Return the root (top tree) element pointer.
|
inline |
Get the pointer to the additionnal user data.
|
inlinevirtual |
Return true if the node is a branch.
Reimplemented in GTreeBranchT< T >.
Referenced by GTreeBranchT< T >::CreateFolderTree(), GTreeNodeT< T >::FindBranch(), and GTreeNodeT< T >::FindNode().
Macro from GCpp library that defines the following functions:
Referenced by GTreeNodeT< T >::FirstLeaf(), and GTreeNodeT< T >::NextLeaf().
|
inlinevirtual |
Return true if the node is a leaf.
Reimplemented in GTreeLeafT< T >.
|
virtual |
Return the next node taht is a leaf.
References GTreeNodeT< T >::IsInstanceOf(), and GTreeNodeT< T >::NextNode().
Referenced by GTreeNodeT< T >::CreateItemList(), GTreeNodeT< T >::CreateList(), and GTreeNodeT< T >::FirstLeaf().
|
virtual |
Return the next node in the tree structure. This function allows to loop on all nodes (branches and leaves).
Reimplemented in GTreeBranchT< T >.
References GTreeNodeT< T >::GetListIter(), GTreeNodeT< T >::GetParent(), and GListIterT< T >::Next().
Referenced by GTreeNodeT< T >::NextLeaf(), and GTreeBranchT< T >::NextNode().
|
pure virtual |
Print the list: elements are given by their name or associated information.
fp | file pointer |
prefix | text written before each line |
info | if true, the information is printed instead of the name |
Implemented in GTreeBranchT< T >, and GTreeLeafT< T >.
|
inlinevirtual |
Set the tree element parent pointer. This function is called when adding an element in a branch.
iter_ptr | pointer to the iterator in the branch list of elements |
Referenced by GTreeBranchT< T >::__Add(), GTreeBranchT< T >::__Insert(), and GTreeBranchT< T >::__Take().
|
inlinevirtual |
Set the tree element parent pointer. This function is called when adding an element in a branch.
parent_ptr | pointer to the tree parent object |
Referenced by GTreeBranchT< T >::__Add(), GTreeBranchT< T >::__Insert(), and GTreeBranchT< T >::__Take().
|
inline |
Set the pointer to an additionnal user data.
data | user data pointer |
Referenced by GTreeBranchT< T >::CreateFolderTree().