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

#include <GTreeLeafT.hh>

Inheritance diagram for GTreeLeafT< T >:
GTreeNodeT< T > GNamed

Public Member Functions

template<class Q >
bool IsInstanceOf () const
 
template<class Q >
bool IsInstanceOf ()
 
virtual GTreeLeafT< T > * Clone () const
 
virtual const char * ClassName () const
 
Constructors, affectation, destructor
 GTreeLeafT (T &object_ref)
 
 GTreeLeafT (T *object_ptr)
 
 GTreeLeafT (const GTreeLeafT< T > &original)
 
virtual ~GTreeLeafT ()
 
Element information
virtual void SetName (const string &leaf_name)
 
virtual string GetName () const
 
virtual string GetInfo () const
 
virtual u_int GetLeafCount () const
 
virtual u_int GetLeafTotalCount () const
 
const T * GetDataPtr () const
 
T * GetDataPtr ()
 
const T & GetData () const
 
T & GetData ()
 
bool IsObjectAdopted () const
 
virtual bool IsLeaf () const
 
Creation of objects structures from the tree
virtual GTreeNodeT< GItem > * CreateItemTree () 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 IsBranch () const
 
void SetUserData (void *data)
 
void * GetUserData () const
 
virtual GListIterT< GTreeNodeT
< T > > 
GetListIter () const
 
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)
 
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)
 
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 ()
 
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 Public Member Functions inherited from GTreeNodeT< T >
static const char * StaticClassName ()
 
- Static Public Member Functions inherited from GNamed
static const char * StaticClassName ()
 

Protected Attributes

T * data_ptr
 Pointer to the object associated with the leaf.
 
bool adopted
 Flag if data object should be deleted by the tree.
 
- 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.
 

Detailed Description

template<class T>
class GTreeLeafT< T >

A tree leaf is a final tree element (it does not contain sub-elements).

Since the template class T must inherit from the base class GNamed, the functions related to the leaf (that also inherits from GNamed class) name and information are overloaded to be redirected to the type T object.

Constructor & Destructor Documentation

template<class T >
GTreeLeafT< T >::GTreeLeafT ( T &  object_ref)
inline

Constructor with reference to object. The object is considered external, and is not managed by the tree.

Parameters
object_refobject given by reference

References GTreeLeafT< T >::adopted, GTreeLeafT< T >::data_ptr, and GDebugConst.

template<class T >
GTreeLeafT< T >::GTreeLeafT ( T *  object_ptr)

Constructor with object pointer. The object adopted, and will be deleted by the tree.

Parameters
object_ptrobject given by pointer

References GTreeLeafT< T >::adopted, GTreeLeafT< T >::data_ptr, GClassError, and GDebugConst.

template<class T >
GTreeLeafT< T >::GTreeLeafT ( const GTreeLeafT< T > &  original)

Copy constructor.

Parameters
originalobject to copy

References GTreeLeafT< T >::data_ptr, GClassError, GDebugConst, GTreeLeafT< T >::GetDataPtr(), and GTreeLeafT< T >::IsObjectAdopted().

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

Destructor: if the object was adopted, it is deleted.

References GDebugDest.

Member Function Documentation

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

Create a GItem tree leaf, with the item pointing to the original tree leaf object.

Implements GTreeNodeT< T >.

References GItem::SetInfo().

template<class T >
const T & GTreeLeafT< T >::GetData ( ) const
inline

Return the data object (by reference) of the leaf.

template<class T >
T & GTreeLeafT< T >::GetData ( )
inline

Return the data object (by reference) of the leaf.

template<class T >
const T * GTreeLeafT< T >::GetDataPtr ( ) const
inline

Return the pointer to the data object of the leaf.

Referenced by GTreeNodeT< T >::CreateItemList(), GTreeNodeT< T >::CreateList(), and GTreeLeafT< T >::GTreeLeafT().

template<class T >
T * GTreeLeafT< T >::GetDataPtr ( )
inline

Return the pointer to the data object of the leaf.

template<class T >
string GTreeLeafT< T >::GetInfo ( ) const
inlinevirtual

Return the information related to the object associated to the leaf.

Reimplemented from GNamed.

template<class T >
u_int GTreeLeafT< T >::GetLeafCount ( ) const
inlinevirtual

Return the number of leaves.

Implements GTreeNodeT< T >.

template<class T >
u_int GTreeLeafT< T >::GetLeafTotalCount ( ) const
inlinevirtual

Return the total number of leaves, recursively in the tree structure (trivial here: no sub-structure).

Implements GTreeNodeT< T >.

template<class T >
string GTreeLeafT< T >::GetName ( ) const
inlinevirtual

Return the name of the leaf: it returns the name of the object associated to the leaf.

Reimplemented from GNamed.

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

template<class T>
template<class Q >
bool GTreeLeafT< 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 >
bool GTreeLeafT< T >::IsLeaf ( ) const
inlinevirtual

Return true if the node is a leaf.

Reimplemented from GTreeNodeT< T >.

template<class T >
bool GTreeLeafT< T >::IsObjectAdopted ( ) const
inline

Return true if the object is adopted by the class, false if it is an external reference (and not deleted).

Referenced by GTreeLeafT< T >::GTreeLeafT().

template<class T >
void GTreeLeafT< 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().

template<class T >
void GTreeLeafT< T >::SetName ( const string &  leaf_name)
inlinevirtual

Change the name of the leaf: the function acts on the object associated to the leaf.

Parameters
leaf_namenew leaf name

Reimplemented from GNamed.


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