GCpp general purpose C++ library  version 1.0
GTreeLeafT.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GTreeLeafT.hh
3  *
4  * Include file for GTreeLeafT template class.
5  */
6 //======================================================================
7 
8 #ifndef G_TREE_LEAF_T_HH
9 #define G_TREE_LEAF_T_HH
10 
11 #include "GTreeNodeT.hh"
12 
13 //======================================================================
14 /*! \class GTreeLeafT
15  *
16  * A tree leaf is a final tree element (it does not contain sub-elements).
17  *
18  * Since the template class \b T must inherit from the base class GNamed,
19  * the functions related to the leaf (that also inherits from GNamed class)
20  * \b name and \b information are overloaded to be redirected to the
21  * type \b T object.
22  */
23 template <class T> class GTreeLeafT : public GTreeNodeT<T>
24 {
25  //------------------------------------------------------------
26  /*! \object_doc */
28  //------------------------------------------------------------
29 
30  using GTreeNodeT <T>::parent;
31  using GTreeNodeT <T>::list_iter;
32 
33  protected:
34  T * data_ptr; ///< Pointer to the object associated with the leaf
35  bool adopted; ///< Flag if data object should be deleted by the tree
36 
37  public:
38  //------------------------------------------------------------
39  /** @name Constructors, affectation, destructor */
40  //@{
41  GTreeLeafT ( T & object_ref ); //
42  GTreeLeafT ( T * object_ptr );
43  GTreeLeafT ( const GTreeLeafT<T> & original );
44  virtual ~GTreeLeafT ( );
45  //@}
46 
47  //------------------------------------------------------------
48  /** @name Element information */
49  //@{
50  // Redefined from GNamed base class
51  virtual void SetName ( const string & leaf_name ); // inline
52  virtual string GetName ( ) const; // inline
53  virtual string GetInfo ( ) const; // inline
54 
55  // Mandatory functions from the base class
56  virtual u_int GetLeafCount ( ) const; // inline
57  virtual u_int GetLeafTotalCount ( ) const; // inline
58 
59  //------------------------------------------------------------
60  const T * GetDataPtr ( ) const; // inline
61  T * GetDataPtr ( ); // inline
62  const T & GetData ( ) const; // inline
63  T & GetData ( ); // inline
64 
65  bool IsObjectAdopted ( ) const; // inline
66 
67  virtual bool IsLeaf ( ) const; //inline
68  //@}
69 
70  //------------------------------------------------------------
71  /** @name Creation of objects structures from the tree */
72  //@{
73  virtual GTreeNodeT<GItem> * CreateItemTree ( ) const;
74  //@}
75 
76  //------------------------------------------------------------
77  /** @name Print out */
78  //@{
79  virtual void Print ( FILE * fp = stdout, const string & prefix = "", bool info = false ) const;
80  //@}
81 };
82 
83 //----------------------------------------------------------------------
84 // Inline functions
85 #include "icc/GTreeLeafT.icc"
86 
87 //======================================================================
88 #endif
89 
const T & GetData() const
Definition: GTreeLeafT.icc:111
virtual string GetName() const
Definition: GTreeLeafT.icc:81
virtual void Print(FILE *fp=stdout, const string &prefix="", bool info=false) const
Definition: GTreeLeafT.icc:164
GTreeBranchT< T > * parent
Parent element of the tree.
Definition: GTreeNodeT.hh:52
Definition: GTreeLeafT.hh:23
virtual string GetInfo() const
Definition: GTreeLeafT.icc:85
GListIterT< GTreeNodeT< T > > * list_iter
Pointer to the iterator in parent list.
Definition: GTreeNodeT.hh:53
const T * GetDataPtr() const
Definition: GTreeLeafT.icc:103
#define GObject(T)
Definition: GClassDefine.hh:65
virtual u_int GetLeafTotalCount() const
Definition: GTreeLeafT.icc:96
T * data_ptr
Pointer to the object associated with the leaf.
Definition: GTreeLeafT.hh:34
virtual void SetName(const string &leaf_name)
Definition: GTreeLeafT.icc:75
virtual bool IsLeaf() const
Definition: GTreeLeafT.icc:127
bool adopted
Flag if data object should be deleted by the tree.
Definition: GTreeLeafT.hh:35
Definition: GItem.hh:24
virtual GTreeNodeT< GItem > * CreateItemTree() const
Definition: GTreeLeafT.icc:138
Definition: GTreeNodeT.hh:44
unsigned int u_int
Definition: GTypes.hh:38
bool IsObjectAdopted() const
Definition: GTreeLeafT.icc:121
virtual u_int GetLeafCount() const
Definition: GTreeLeafT.icc:91