GCpp general purpose C++ library  version 1.0
GIterT.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GIterT.hh
3  *
4  * Include file for GIterT template class.
5  */
6 //======================================================================
7 
8 #ifndef G_ITER_T_HH
9 #define G_ITER_T_HH
10 
11 #include "GGlobal.hh"
12 
13 //======================================================================
14 /*! \class GIterT
15  *
16  * The template class GIterT is a base class for collection iterators.
17  * It should be derived for specific types of collections.
18  *
19  * The base class encapsulates a standard class T object pointer.
20  */
21 template < class T > class GIterT
22 {
23 //----------------------------------------------------------------------
24  /*! \object_doc */
26 //----------------------------------------------------------------------
27 
28  protected:
29  u_int flags; ///< Iterator flags
30  T * item_ptr; ///< Pointer on the instance of class T object
31 
32  public:
33  //------------------------------------------------------------
34  // Constructor / Destructor / Affectation
35  GIterT ( T * adr = NULL );
36  GIterT ( const GIterT<T> & p );
37  virtual ~GIterT ( );
38 
39  GIterT<T> & operator = ( const GIterT<T> & p );
40  GIterT<T> & operator = ( T * adr );
41 
42  void SetItemPtr ( T * adr );
43 
44  //------------------------------------------------------------
45  u_int GetFlags ( ) const;
46  void SetFlags ( u_int fl );
47  void SetFlag ( u_int fl, bool on = true );
48  bool IsFlagOn ( u_int fl ) const;
49  bool IsFlagOff ( u_int fl ) const;
50 
51  //------------------------------------------------------------
52  // Cast, reference and dereference
53 
54  operator bool ( void ) const;
55  operator T * ( void ) const;
56 
57  virtual T & operator * ( void );
58  virtual T * operator -> ( void );
59  virtual const T & operator * ( void ) const;
60  virtual const T * operator -> ( void ) const;
61 
62  //------------------------------------------------------------
63  // Comparison operators
64 
65  virtual bool operator == ( const GIterT<T> & p ) const;
66  virtual bool operator != ( const GIterT<T> & p ) const;
67  virtual bool operator == ( const T * adr ) const;
68  virtual bool operator != ( const T * adr ) const;
69 
70  //------------------------------------------------------------
71  // Incrementation / decrementation
72 
73  // not virtual since derived classes return another type of iterators
74  GIterT<T> & operator ++ ( void );
75  GIterT<T> & operator -- ( void );
76  GIterT<T> operator ++ ( int );
77  GIterT<T> operator -- ( int );
78 
79  //------------------------------------------------------------
80  T * GetPointer ( );
81 };
82 
83 
84 //----------------------------------------------------------------------
85 // Inline functions
86 #include "icc/GIterT.icc"
87 
88 
89 //======================================================================
90 #endif
Definition: GIterT.hh:21
#define GObject(T)
Definition: GClassDefine.hh:65
T * item_ptr
Pointer on the instance of class T object.
Definition: GIterT.hh:30
void SetFlag(u_int fl, bool on=true)
Definition: GIterT.icc:62
void SetItemPtr(T *adr)
Definition: GIterT.icc:44
u_int flags
Iterator flags.
Definition: GIterT.hh:29
bool IsFlagOn(u_int fl) const
Definition: GIterT.icc:71
void SetFlags(u_int fl)
Definition: GIterT.icc:55
unsigned int u_int
Definition: GTypes.hh:38
T * GetPointer()
Definition: GIterT.icc:149
bool IsFlagOff(u_int fl) const
Definition: GIterT.icc:77