GCpp general purpose C++ library  version 1.0
GIntervalList.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GIntervalList.hh
3  *
4  * Include file for class GIntervalList.
5  */
6 //======================================================================
7 
8 #ifndef G_INTERVAL_LIST_HH
9 #define G_INTERVAL_LIST_HH
10 
11 #include "GInterval.hh"
12 #include "GListT.hh"
13 
14 //======================================================================
15 /*! \class GIntervalList
16  *
17  * This class defines a list of intervals of integer values.
18  *
19  * The base class is protected since adding and removing intervals
20  * is done with a check of overlapping intervals.
21  *
22  * The class defines an index to navigate from one value to the next
23  * (and not only from one interval to the next, as the base class do).
24  *
25  */
26 
27 class GIntervalList : protected GListT<GInterval>
28 {
29 //----------------------------------------------------------------------
30  /*! \object_doc */
32 //----------------------------------------------------------------------
33 
34  using GListT<GInterval>::Begin;
35  using GListT<GInterval>::End;
36  using GListT<GInterval>::Null;
37  using GListT<GInterval>::First;
38  using GListT<GInterval>::Last;
39  using GListT<GInterval>::Next;
40  using GListT<GInterval>::Previous;
41  using GListT<GInterval>::Current;
42  using GListT<GInterval>::GetSize;
43  using GListT<GInterval>::Empty;
44 
45  static const int noMin; ///< Undefined minimu value
46  static const int noMax; ///< Undefined maximum value
47 
48  static string c_separ; ///< Elements separation characters
49 
50  /// Defines locally the iterator type
52 
53  protected:
54  int * index_ptr; ///< Pointer of the index (so that the value can be modified for a constant list)
55 
56  public:
57  //------------------------------------------------------------
58  // Constructor / Destructor / Affectation
59 
60  GIntervalList ( );
61  GIntervalList ( const string & str );
62  GIntervalList ( const GIntervalList & original );
63 
64  virtual ~GIntervalList ( );
65 
66  GIntervalList & operator = ( const GIntervalList &original );
67 
68  //------------------------------------------------------------
69  virtual string GetString ( ) const;
70  virtual string GetStringPar ( ) const;
71 
72  int GetMinValue ( ) const;
73  int GetMaxValue ( ) const;
74  int GetValNumber ( ) const;
75  int * GetArray ( int & len ) const;
76 
77  bool Contains ( int val ) const;
78 
79  //------------------------------------------------------------
80  // Loop on values
81  int FromFirst ( ) const;
82  int ToLast ( ) const;
83  int NextVal ( ) const;
84 
85  int FromLast ( ) const;
86  int ToFirst ( ) const;
87  int PreviousVal ( ) const;
88 
89  //------------------------------------------------------------
90  // List functions
91  virtual GListIterT<GInterval> Add ( const GInterval & inter );
92  virtual GListIterT<GInterval> Add ( const string & s );
93  virtual GListIterT<GInterval> Add ( int i );
94  virtual GListIterT<GInterval> Add ( int i1, int i2 );
95 
96  virtual bool Remove ( const GInterval & inter );
97  virtual bool Remove ( const string & s );
98  virtual bool Remove ( int i );
99  virtual bool Remove ( int i1, int i2 );
100 
101  //------------------------------------------------------------
102  // hidden functions from the base class
103  protected:
104  // fonctions "cachées" de la classe de base
105  virtual bool Remove ( );
106  virtual bool Remove ( const GInterval * ptr, bool all = true );
107 };
108 
109 //----------------------------------------------------------------------
110 // Inline functions
111 #include "icc/GIntervalList.icc"
112 
113 //======================================================================
114 #endif
virtual GListIterT< GInterval > End() const
int ToLast() const
Definition: GIntervalList.cpp:137
int NextVal() const
Definition: GIntervalList.cpp:176
int FromFirst() const
Definition: GIntervalList.cpp:124
Definition: GListIterT.hh:21
GListIterT< GInterval > Current() const
static string c_separ
Elements separation characters.
Definition: GIntervalList.hh:48
virtual u_int GetSize() const
Definition: GListIterT.hh:13
virtual string GetString() const
Definition: GIntervalList.cpp:20
virtual string GetStringPar() const
Definition: GIntervalList.cpp:39
int PreviousVal() const
Definition: GIntervalList.cpp:195
Definition: GInterval.hh:24
int FromLast() const
Definition: GIntervalList.cpp:150
virtual GListIterT< GInterval > Begin() const
Definition: GIntervalList.hh:27
static const int noMax
Undefined maximum value.
Definition: GIntervalList.hh:46
#define GObject(T)
Definition: GClassDefine.hh:65
int * index_ptr
Pointer of the index (so that the value can be modified for a constant list)
Definition: GIntervalList.hh:54
static const int noMin
Undefined minimu value.
Definition: GIntervalList.hh:45
int GetValNumber() const
Definition: GIntervalList.cpp:58
GListIterT< GInterval > First() const
int ToFirst() const
Definition: GIntervalList.cpp:163
int GetMaxValue() const
Definition: GIntervalList.icc:83
GListIterT< GInterval > Previous() const
virtual void Empty()
bool Contains(int val) const
Definition: GIntervalList.cpp:104
static GListIterT< GInterval > Null()
virtual GListIterT< GInterval > Add(const GInterval &inter)
Definition: GIntervalList.cpp:221
virtual bool Remove()
Definition: GIntervalList.icc:90
GListIterT< GInterval > Last() const
GListIterT< GInterval > Next() const
int * GetArray(int &len) const
Definition: GIntervalList.cpp:80
int GetMinValue() const
Definition: GIntervalList.icc:78