GCpp general purpose C++ library  version 1.0
GInterval.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GInterval.hh
3  *
4  * Include file for class GInterval that defines an interval between
5  * 2 integer values (bounds included).
6  */
7 //======================================================================
8 
9 #ifndef G_INTERVAL_HH
10 #define G_INTERVAL_HH
11 
12 #include "GGlobal.hh"
13 #include "GString.hh"
14 
15 /*! \class GInterval
16  *
17  * This class defines an interval between 2 integer values.
18  * The bounds belong to the interval.
19  * If the upper bound is smaller than the lower bound, the interval
20  * is considered empty.
21  *
22  */
23 
24 class GInterval
25 {
26  //------------------------------------------------------------
27  /*! \object_doc */
29  //------------------------------------------------------------
30 
31  private:
32  static string c_range; ///< Range character identification
33 
34  protected:
35  int i_min; ///< Interval lower bound
36  int i_max; ///< Interval upper bound
37 
38  public:
39 
40  //------------------------------------------------------------
41  // Constructor / Destructor / Affectation
42  GInterval ( ); // inline
43  GInterval ( int i ); // inline
44  GInterval ( int i1, int i2 ); // inline
45  GInterval ( const string &s );
46  GInterval ( const GInterval &original ); // inline
47 
48  virtual ~GInterval ( ); // inline
49 
50  GInterval & operator = ( const GInterval &original );
51 
52  //----------------------------------------------------------
53  int GetMin ( ) const; // inline
54  int GetMax ( ) const; // inline
55 
56  void SetMin ( int i ); // inline
57  void SetMax ( int i ); // inline
58 
59  bool IsEmpty ( ) const; // inline
60 
61  string GetString ( ) const;
62  string GetStringPar ( ) const; // inline
63 
64  int GetValNumber ( ) const; // inline
65 
66  //----------------------------------------------------------
67  // Comparaison operator and functions
68  virtual bool operator == ( const GInterval &item );
69 
70  GInterval Overlap ( const GInterval &inter ) const;
71  bool IsInside ( const GInterval &inter, const bool exclude = false ) const;
72  bool Contains ( const GInterval &inter, const bool exclude = false ) const;
73  bool Touches ( const GInterval &inter ) const;
74 
75 };
76 
77 //----------------------------------------------------------------------
78 // Inline functions
79 #include "icc/GInterval.icc"
80 
81 //======================================================================
82 #endif
Definition: GInterval.hh:24
int GetMin() const
Definition: GInterval.icc:48
int GetMax() const
Definition: GInterval.icc:52
#define GObject(T)
Definition: GClassDefine.hh:65
GInterval Overlap(const GInterval &inter) const
Definition: GInterval.cpp:188
int i_min
Interval lower bound.
Definition: GInterval.hh:35
bool IsEmpty() const
Definition: GInterval.icc:69
string GetString() const
Definition: GInterval.cpp:148
string GetStringPar() const
Definition: GInterval.icc:76
void SetMin(int i)
Definition: GInterval.icc:58
int i_max
Interval upper bound.
Definition: GInterval.hh:36
int GetValNumber() const
Definition: GInterval.icc:80
bool Touches(const GInterval &inter) const
Definition: GInterval.cpp:246
bool IsInside(const GInterval &inter, const bool exclude=false) const
Definition: GInterval.cpp:214
void SetMax(int i)
Definition: GInterval.icc:64
bool Contains(const GInterval &inter, const bool exclude=false) const
Definition: GInterval.cpp:238
static string c_range
Range character identification.
Definition: GInterval.hh:32