GCpp general purpose C++ library  version 1.0
GTreeBranchT< T > Class Template Reference

#include <GTreeBranchT.hh>

Inheritance diagram for GTreeBranchT< T >:
GTreeNodeT< T > GNamedListT< GTreeNodeT< T > > GNamed GSortListT< GTreeNodeT< T > > GListT< GTreeNodeT< T > > GCollectionT< GTreeNodeT< T > >

Public Member Functions

template<class Q >
bool IsInstanceOf () const
 
template<class Q >
bool IsInstanceOf ()
 
virtual GTreeBranchT< T > * Clone () const
 
virtual const char * ClassName () const
 
Constructors, affectation, destructor
 GTreeBranchT (const string &branch_name)
 
 GTreeBranchT (const GTreeBranchT< T > &original)
 
virtual ~GTreeBranchT ()
 
Element information
virtual bool IsBranch () const
 
virtual u_int GetLeafCount () const
 
virtual u_int GetBranchCount () const
 
virtual u_int GetLeafTotalCount () const
 
Tree structure exploration
virtual GTreeNodeT< T > * NextNode ()
 
Tree construction function
virtual GTreeBranchT< T > * AddBranch (const string &bname)
 
virtual GTreeLeafT< T > * AddLeaf (T &object_ref)
 
virtual GTreeLeafT< T > * AddLeaf (T *object_ptr)
 
Creation of objects structures from the tree
virtual GTreeNodeT< GItem > * CreateItemTree () const
 
virtual GTreeBranchT< T > * CreateFolderTree () const
 
Print out
virtual void Print (FILE *fp=stdout, const string &prefix="", bool info=false) const
 
- Public Member Functions inherited from GTreeNodeT< T >
template<class Q >
bool IsInstanceOf () const
 
template<class Q >
bool IsInstanceOf ()
 
 GTreeNodeT ()
 
 GTreeNodeT (const GTreeNodeT< T > &original)
 
virtual ~GTreeNodeT ()
 
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 IsLeaf () const
 
void SetUserData (void *data)
 
void * GetUserData () const
 
virtual GListIterT< GTreeNodeT
< T > > 
GetListIter () const
 
virtual GTreeLeafT< T > * FirstLeaf ()
 
virtual GTreeLeafT< T > * NextLeaf ()
 
virtual GTreeNodeT< T > * FindNode (const string &name)
 
virtual GTreeBranchT< T > * FindBranch (const string &name)
 
virtual GTreeBranchT< T > * AddBranch (const string &parent, const string &bname)
 
virtual GTreeLeafT< T > * AddLeaf (const string &parent, T &object_ref)
 
virtual GTreeLeafT< T > * AddLeaf (const string &parent, T *object_ptr)
 
u_int GetLevel () const
 
virtual string GetFullName () const
 
virtual GNamedListT< T > * CreateList ()
 
virtual GItemListCreateItemList ()
 
- Public Member Functions inherited from GNamed
template<class Q >
bool IsInstanceOf () const
 
template<class Q >
bool IsInstanceOf ()
 
 GNamed (const string &object_name="")
 
 GNamed (const GNamed &object)
 
virtual ~GNamed ()
 
GNamedoperator= (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
 
- Public Member Functions inherited from GNamedListT< GTreeNodeT< T > >
bool IsInstanceOf () const
 
bool IsInstanceOf ()
 
 GNamedListT (u_int fl=0)
 
 GNamedListT (const GNamedListT< GTreeNodeT< T > > &list)
 
 GNamedListT (const GNamedListT< GTreeNodeT< T > > &list, u_int fl)
 
GNamedListT< GTreeNodeT< T > > & operator= (const GNamedListT< GTreeNodeT< T > > &list)
 
virtual void SetCaseSensitive (bool b=true)
 
virtual void SetDictSort (bool b=true)
 
virtual int Compare (const GTreeNodeT< T > &obj1, const GTreeNodeT< T > &obj2) const
 
virtual bool ExistName (const string &obj_name) const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindName (const string &obj_name, const char smod= 'f') const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindNameFirst (const string &obj_name) const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindNameLast (const string &obj_name) const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindNameNext (const string &obj_name) const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindNamePrevious (const string &obj_name) const
 
virtual string * CreateNamesTable () const
 
virtual void SetNamesTable (string table[]) const
 
virtual void Print (FILE *fp=stdout, const string &prefix="") const
 
virtual void Print (ostream &os, const string &prefix="") const
 
- Public Member Functions inherited from GSortListT< GTreeNodeT< T > >
bool IsInstanceOf () const
 
bool IsInstanceOf ()
 
 GSortListT (u_int fl=0)
 
 GSortListT (const GSortListT< GTreeNodeT< T > > &list)
 
 GSortListT (const GListT< GTreeNodeT< T > > &list)
 
 GSortListT (const GListT< GTreeNodeT< T > > &list, u_int fl)
 
GSortListT< GTreeNodeT< T > > & operator= (const GListT< GTreeNodeT< T > > &list)
 
virtual void ReverseSort ()
 
virtual void Sort ()
 
virtual bool IsSorted () const
 
- Public Member Functions inherited from GListT< GTreeNodeT< T > >
bool IsInstanceOf () const
 
bool IsInstanceOf ()
 
 GListT (u_int opts=0)
 
 GListT (const GListT< GTreeNodeT< T > > &list)
 
 GListT (const GListT< GTreeNodeT< T > > &list, u_int opts)
 
GListT< GTreeNodeT< T > > & operator= (const GListT< GTreeNodeT< T > > &list)
 
virtual GListIterT< GTreeNodeT
< T > > 
Begin () const
 
virtual GListIterT< GTreeNodeT
< T > > 
End () const
 
virtual bool Exist (const GTreeNodeT< T > *ptr) const
 
virtual GListIterT< GTreeNodeT
< T > > 
Find (const GTreeNodeT< T > *ptr) const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindNext (const GTreeNodeT< T > *ptr) const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindPrevious (const GTreeNodeT< T > *ptr) const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindFirst (const GTreeNodeT< T > *ptr) const
 
virtual GListIterT< GTreeNodeT
< T > > 
FindLast (const GTreeNodeT< T > *ptr) const
 
GListIterT< GTreeNodeT< T > > Current () const
 
GListIterT< GTreeNodeT< T > > Previous () const
 
GListIterT< GTreeNodeT< T > > Next () const
 
GListIterT< GTreeNodeT< T > > First () const
 
GListIterT< GTreeNodeT< T > > Last () const
 
GListIterT< GTreeNodeT< T > > Goto (u_int n=0) const
 
GTreeNodeT< T > & At (u_int n) const
 
int Index () const
 
virtual int Move (int n)
 
virtual bool MoveUp ()
 
virtual bool MoveDown ()
 
virtual bool MoveTop ()
 
virtual bool MoveBottom ()
 
virtual GListIterT< GTreeNodeT
< T > > 
Add (GTreeNodeT< T > *obj_ptr)
 
virtual GListIterT< GTreeNodeT
< T > > 
Add (GTreeNodeT< T > &obj_ptr)
 
virtual GListIterT< GTreeNodeT
< T > > 
Insert (GTreeNodeT< T > *obj_ptr)
 
virtual GListIterT< GTreeNodeT
< T > > 
Insert (GTreeNodeT< T > &obj_ptr)
 
virtual GListIterT< GTreeNodeT
< T > > 
Append (GTreeNodeT< T > *obj_ptr)
 
virtual GListIterT< GTreeNodeT
< T > > 
Append (GTreeNodeT< T > &obj_ptr)
 
virtual GListIterT< GTreeNodeT
< T > > 
Prepend (GTreeNodeT< T > *obj_ptr)
 
virtual GListIterT< GTreeNodeT
< T > > 
Prepend (GTreeNodeT< T > &obj_ptr)
 
virtual GTreeNodeT< T > * Take ()
 
virtual GTreeNodeT< T > * Take (const GTreeNodeT< T > *ptr)
 
virtual bool Remove ()
 
virtual bool Remove (const GTreeNodeT< T > *ptr, bool all=true)
 
virtual void Empty ()
 
- Public Member Functions inherited from GCollectionT< GTreeNodeT< T > >
bool IsInstanceOf () const
 
bool IsInstanceOf ()
 
 GCollectionT (u_int flg=0)
 
virtual u_int GetSize () const
 
virtual u_int GetCount () const
 
virtual u_int GetOptions () const
 
bool CheckOptions (u_int opts) const
 
bool FixPositionOption () const
 
bool IsSortable () const
 
bool IsAlwaysSorted () const
 
bool IsReverseSorted () const
 
bool UniqueNameOption () const
 
bool IsCaseSensitive () const
 
bool DictSortOption () const
 

Static Public Member Functions

static const char * StaticClassName ()
 
- Static Public Member Functions inherited from GTreeNodeT< T >
static const char * StaticClassName ()
 
- Static Public Member Functions inherited from GNamed
static const char * StaticClassName ()
 
- Static Public Member Functions inherited from GNamedListT< GTreeNodeT< T > >
static const char * StaticClassName ()
 
- Static Public Member Functions inherited from GSortListT< GTreeNodeT< T > >
static const char * StaticClassName ()
 
- Static Public Member Functions inherited from GListT< GTreeNodeT< T > >
static const char * StaticClassName ()
 
static GListIterT< GTreeNodeT
< T > > 
Null ()
 
- Static Public Member Functions inherited from GCollectionT< GTreeNodeT< T > >
static const char * StaticClassName ()
 

Protected Member Functions

Internal functions redefined for list behaviour
virtual GListIterT< GTreeNodeT
< T > > 
__Add (GTreeNodeT< T > *item)
 
virtual GListIterT< GTreeNodeT
< T > > 
__Insert (GTreeNodeT< T > *item)
 
virtual GTreeNodeT< T > * __Take ()
 
- Protected Member Functions inherited from GNamedListT< GTreeNodeT< T > >
virtual GListIterT< GTreeNodeT
< T > > * 
__FindName (const string &obj_name, const char smod= 'f') const
 
- Protected Member Functions inherited from GSortListT< GTreeNodeT< T > >
virtual GListIterT< GTreeNodeT
< T > > 
__AddSorted (GTreeNodeT< T > *item)
 
- Protected Member Functions inherited from GListT< GTreeNodeT< T > >
virtual GListIterT< GTreeNodeT
< T > > * 
__Exist (const GTreeNodeT< T > *ptr, GListIterT< GTreeNodeT< T > > *except=NULL) const
 
virtual GListIterT< GTreeNodeT
< T > > * 
__Find (const GTreeNodeT< T > *ptr, GListIterT< GTreeNodeT< T > > *except=NULL) const
 
virtual void __Swap (GListIterT< GTreeNodeT< T > > *iter)
 
virtual bool __MoveUp ()
 
virtual bool __MoveDown ()
 

Additional Inherited Members

- Protected Attributes inherited from GTreeNodeT< T >
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.
 
- Protected Attributes inherited from GNamed
string name
 Object name.
 
- Protected Attributes inherited from GListT< GTreeNodeT< T > >
GListIterT< GTreeNodeT< T > > ** first_item
 Iterator on first object in the list.
 
GListIterT< GTreeNodeT< T > > ** last_item
 Iterator on last object in the list.
 
GListIterT< GTreeNodeT< T > > ** current_item
 Iterator on current object in the list.
 
- Protected Attributes inherited from GCollectionT< GTreeNodeT< T > >
u_int options
 Collection option flags.
 
u_int count_item
 Number of objects in the collection.
 

Detailed Description

template<class T>
class GTreeBranchT< T >

A tree branch is a tree element itself, and a the list of tree elements that a contained in the branch.

Constructor & Destructor Documentation

template<class T >
GTreeBranchT< T >::GTreeBranchT ( const string &  branch_name)
inline

Default constructor.

References GDebugConst, and GNamed::SetName().

template<class T >
GTreeBranchT< T >::GTreeBranchT ( const GTreeBranchT< T > &  original)
inline

Copy constructor.

Parameters
originalobject to copy

References GDebugConst.

template<class T >
GTreeBranchT< T >::~GTreeBranchT ( )
inlinevirtual

Destructor.

References GDebugDest.

Member Function Documentation

template<class T >
GListIterT< GTreeNodeT< T > > GTreeBranchT< T >::__Add ( GTreeNodeT< T > *  obj_ptr)
protectedvirtual

Function redefined from list base class to add an element to the branch, after current element.

Parameters
obj_ptrobject pointer

Reimplemented from GNamedListT< GTreeNodeT< T > >.

References GDebugClass, GGetString(), GTreeNodeT< T >::SetListIter(), and GTreeNodeT< T >::SetParent().

template<class T >
GListIterT< GTreeNodeT< T > > GTreeBranchT< T >::__Insert ( GTreeNodeT< T > *  obj_ptr)
protectedvirtual

Function redefined from list base class to insert an element to the branch, before current element.

Parameters
obj_ptrobject pointer

Reimplemented from GNamedListT< GTreeNodeT< T > >.

References GDebugClass, GGetString(), GTreeNodeT< T >::SetListIter(), and GTreeNodeT< T >::SetParent().

template<class T >
GTreeNodeT< T > * GTreeBranchT< T >::__Take ( )
inlineprotectedvirtual

Function redefined from base class to take the current element out of the list (without deleting it, just removing the connecting pointers).

Reimplemented from GListT< GTreeNodeT< T > >.

References GTreeNodeT< T >::SetListIter(), and GTreeNodeT< T >::SetParent().

template<class T >
GTreeBranchT< T > * GTreeBranchT< T >::AddBranch ( const string &  bname)
inlinevirtual

Add a sub-branch at the end of the current branch.

Parameters
bnamename of the sub-branch

Reimplemented from GTreeNodeT< T >.

Referenced by GTreeNodeT< T >::AddBranch().

template<class T >
GTreeLeafT< T > * GTreeBranchT< T >::AddLeaf ( T &  object_ref)
inlinevirtual

Add a leaf at the end of the current branch. The object is not adopted by the created leaf.

Parameters
object_refobject given by reference

Reimplemented from GTreeNodeT< T >.

Referenced by GTreeNodeT< T >::AddLeaf().

template<class T >
GTreeLeafT< T > * GTreeBranchT< T >::AddLeaf ( T *  object_ptr)
inlinevirtual

Add a leaf at the end of the current branch. The object is adopted by the created leaf.

Parameters
object_ptrobject given by pointer

Reimplemented from GTreeNodeT< T >.

template<class T >
GTreeBranchT< T > * GTreeBranchT< T >::CreateFolderTree ( ) const
virtual

Create a copy of the tree containing only the folders (branches). The user data pointer of the created tree nodes (branches) is copied from the original tree.

References GListT< GTreeNodeT< T > >::Append(), GTreeBranchT< T >::CreateFolderTree(), GTreeNodeT< T >::IsBranch(), and GTreeNodeT< T >::SetUserData().

Referenced by GTreeBranchT< T >::CreateFolderTree().

template<class T >
GTreeNodeT< GItem > * GTreeBranchT< T >::CreateItemTree ( ) const
virtual

Create a GItem tree branch: the tree structure is dupplicated, but with GItem objects pointing on original tree leaf objects. The resulting tree must be deleted by the calling function.

Implements GTreeNodeT< T >.

References GListT< GTreeNodeT< T > >::Append(), and GTreeBranchT< T >::CreateItemTree().

Referenced by GTreeBranchT< T >::CreateItemTree().

template<class T >
u_int GTreeBranchT< T >::GetBranchCount ( ) const
virtual

Return the number of (sub-)branches in this branch.

template<class T >
u_int GTreeBranchT< T >::GetLeafCount ( ) const
virtual

Return the number of leaves in this branch.

Implements GTreeNodeT< T >.

template<class T >
u_int GTreeBranchT< T >::GetLeafTotalCount ( ) const
virtual

Return the total number of leaves, in this branch and in the sub-branches included.

Implements GTreeNodeT< T >.

template<class T >
bool GTreeBranchT< T >::IsBranch ( ) const
inlinevirtual

Return true if the node is a branch.

Reimplemented from GTreeNodeT< T >.

template<class T>
template<class Q >
bool GTreeBranchT< T >::IsInstanceOf ( ) const
inline

Macro from GCpp library that defines the following functions:

  • ClassName(): return the real class name of the object
  • StaticClassName(): return the used class name of the object (that may be a base class of the real object).
  • IsInstanceOf<T>(): return true if the current object is an instance of the template class name argument
  • Clone(): return an allocated copy of the object.
template<class T >
GTreeNodeT< T > * GTreeBranchT< T >::NextNode ( )
virtual

Return the next node: first node in the branch if it exists, else next node in the parent list.

Reimplemented from GTreeNodeT< T >.

References GTreeNodeT< T >::NextNode().

template<class T >
void GTreeBranchT< T >::Print ( FILE *  fp = stdout,
const string &  prefix = "",
bool  info = false 
) const
virtual

Print the list: elements are given by their name or associated information.

Parameters
fpfile pointer
prefixtext written before each line
infoif true, the information is printed instead of the name

Implements GTreeNodeT< T >.

References GTreeNodeT< T >::GetParent().


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