CARMA C++
MonitorPointIterator.h
Go to the documentation of this file.
1 #ifndef CARMA_MONITOR_MONITORPOINTITERATOR_H
2 #define CARMA_MONITOR_MONITORPOINTITERATOR_H
3 
4 
23 #include <vector>
24 #include <string>
25 
26 namespace carma {
27 namespace monitor {
28 
29 // Forward class declarations
30 class MonitorPoint;
31 class MonitorContainer;
32 
33 
52  public:
64  explicit MonitorPointIterator(
65  const MonitorContainer & rootContainer,
66  int maxDepth = 0,
67  const std::vector<std::string> skip = std::vector<std::string>());
68 
74  bool operator++( );
75 
82  bool operator++( int dummy );
83 
91  bool hasMonitorPoint( ) const;
92 
97  MonitorPoint & getMonitorPoint( ) const;
98 
102  void reset( );
103 
104  void checkStats( bool throwOnProblem ) const;
105 
106  private:
107  // No copying
109  MonitorPointIterator & operator=( const MonitorPointIterator & rhs );
110 
111  MonitorPoint & handleBadDeref( ) const;
112 
113  struct StackEntry {
114  const MonitorContainer * parent;
115  int index;
116  };
117 
118  const MonitorContainer & rootContainer_;
119  const unsigned int maxDepth_;
120 
121  bool initialized_;
122  const MonitorContainer * parent_;
123  int index_;
124  bool hasCurrentValue_;
125  MonitorPoint * currentValue_;
126 
127  // Placeholder: holds the component index for each level in
128  // the hierarachy
129  ::std::vector< StackEntry > stack_;
130 
131  const std::vector<std::string> skip_; // Containers to skip
132 };
133 
134 
135 } // End namespace carma::monitor
136 } // End namespace carma
137 
138 
139 inline bool
141 {
142  return operator++();
143 }
144 
145 
146 inline bool
148 {
149  return hasCurrentValue_;
150 }
151 
152 
155 {
156  if ( currentValue_ != 0 )
157  return *currentValue_;
158  else
159  return handleBadDeref();
160 }
161 
162 
163 #endif
MonitorPointIterator(const MonitorContainer &rootContainer, int maxDepth=0, const std::vector< std::string > skip=std::vector< std::string >())
Constructor.
void reset()
Reset iterator back to beginning.
MonitorPoint & getMonitorPoint() const
Get the current monitor point.
Abstract base class for a monitor point.
Definition: MonitorPoint.h:68
A generic monitor system container base class.
bool operator++()
Iterator (prefix version)
bool hasMonitorPoint() const
Test for monitor points in current state of iterator.
Iterator for monitor point hierarchy that returns monitor points.