My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
AxisRange.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_AXISRANGE_H
2 #define GCP_UTIL_AXISRANGE_H
3 
11 #include "gcp/util/common/CoordAxes.h"
12 #include "gcp/util/common/CoordRange.h"
13 
14 #include "gcp/control/code/unix/libunix_src/common/genericregs.h"
15 
16 namespace gcp {
17  namespace util {
18 
19  class AxisRange {
20  public:
21 
25  AxisRange(CoordAxes axes, CoordRange range);
26  AxisRange(CoordAxes& axes, CoordRange* range=0);
27  AxisRange(CoordAxes* axes, CoordRange* range=0);
28  AxisRange(RegMapBlock* block, CoordRange* range=0);
29 
34  AxisRange(unsigned nEl);
35  AxisRange();
36 
40  void setTo(CoordAxes* axes, CoordRange* range);
41  void setToDc(CoordAxes* axes, CoordRange* range);
42  void setTo(unsigned nEl);
43 
47  virtual ~AxisRange();
48 
52  inline unsigned currentElement() {
53  return iElCurrent_;
54  }
55 
59  inline unsigned currentIterator() {
60  return iter_;
61  }
62 
63  void operator=(AxisRange& obj);
64 
69  {
70  // If we are done, just return silently
71 
72  if(!isEnd()) {
73 
74  // Increment the monotonic iterator
75 
76  iter_++;
77 
78  // If we just did the last element of the current range, advance
79  // to the next range
80 
81  if(iElCurrent_ == (*iRange_).stop()) {
82 
83  // If we are on the last range just stop
84 
85  if(iRange_ < ranges_.end()) {
86  iRange_++;
87 
88  // And set the new element pointing to the beginning of this
89  // range
90 
91  if(!isEnd())
92  iElCurrent_ = (*iRange_).start();
93  }
94 
95  } else // Else increment to the next slot
96  iElCurrent_++;
97  }
98 
99  return *this;
100  }
101 
105  void reset();
106 
110  bool isEnd();
111 
115  friend std::ostream& operator<<(std::ostream& os, AxisRange& range);
116 
121 
122  unsigned nEl();
123 
124  private:
125 
126  unsigned iter_;
127  unsigned iElCurrent_;
128  std::vector<Range<unsigned> > ranges_;
129  std::vector<Range<unsigned> >::iterator iRange_;
130  CoordAxes axes_;
131  unsigned nEl_;
132 
133  }; // End class AxisRange
134 
135  } // End namespace util
136 } // End namespace gcp
137 
138 
139 
140 
141 #endif // End #ifndef GCP_UTIL_AXISRANGE_H
Definition: CoordAxes.h:25
Coord currentCoord()
Definition: AxisRange.cc:202
void setToDc(CoordAxes *axes, CoordRange *range)
Definition: AxisRange.cc:129
void reset()
Definition: AxisRange.cc:168
unsigned currentElement()
Definition: AxisRange.h:52
Definition: AxisRange.h:19
virtual ~AxisRange()
Definition: AxisRange.cc:161
unsigned currentIterator()
Definition: AxisRange.h:59
friend std::ostream & operator<<(std::ostream &os, AxisRange &range)
Definition: Coord.h:21
Definition: CoordRange.h:20
AxisRange()
Definition: AxisRange.cc:52
bool isEnd()
Definition: AxisRange.cc:183
const AxisRange & operator++()
Definition: AxisRange.h:68
void setTo(CoordAxes *axes, CoordRange *range)
Definition: AxisRange.cc:97
unsigned nEl()
Definition: AxisRange.cc:210