nidas  v1.2-1520
NidsIterators.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2006, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 #ifndef NIDAS_CORE_NIDSITERATORS_H
27 #define NIDAS_CORE_NIDSITERATORS_H
28 
29 #include <list>
30 // #include <set>
31 #include <vector>
32 
33 namespace nidas { namespace core {
34 
35 class Project;
36 class DSMServer;
37 class DSMService;
38 class Site;
39 class Variable;
40 
46 {
47 public:
48  SiteIterator(const Project*);
49 
50  SiteIterator();
51 
52  bool hasNext();
53 
54  Site* next() { return *_siteItr++; }
55 
56 private:
57 
58  const std::list<Site*>* _sites;
59 
60  std::list<Site*>::const_iterator _siteItr;
61 };
62 
67 {
68 public:
69  DSMServerIterator(const Project*);
70 
71  DSMServerIterator(const Site*);
72 
74 
75  bool hasNext();
76 
77  DSMServer* next() { return *_serverItr++; }
78 
79 private:
80 
81  const std::list<DSMServer*>* _servers;
82 
83  std::list<DSMServer*>::const_iterator _serverItr;
84 
86 };
87 
92 {
93 public:
95 
96  DSMServiceIterator(const Site*);
97 
99 
101 
102  bool hasNext();
103 
104  DSMService* next() { return *_dsmServiceItr++; }
105 
106 private:
107 
109 
110  const std::list<DSMService*>* _services;
111 
112  std::list<DSMService*>::const_iterator _dsmServiceItr;
113 };
114 
115 class SampleIOProcessor;
116 
117 class DSMConfig;
118 
119 
125 {
126 public:
127  DSMConfigIterator(const Project*);
128 
129  DSMConfigIterator(const Site*);
130 
132 
133  bool hasNext();
134 
135  const DSMConfig* next() { return *_dsmItr++; }
136 
137 private:
138 
140 
141  const std::list<const DSMConfig*>* _dsms;
142 
143  std::list<const DSMConfig*>::const_iterator _dsmItr;
144 };
145 
150 {
151 public:
152  ProcessorIterator(const Project*);
153 
154  ProcessorIterator(const Site*);
155 
157 
159 
161 
163 
164  bool hasNext();
165 
166  SampleIOProcessor* next() { return *_procItr++; }
167 
168 private:
169 
171 
173 
174  const std::list<SampleIOProcessor*>* _processors;
175 
176  std::list<SampleIOProcessor*>::const_iterator _procItr;
177 };
178 
179 class DSMSensor;
180 
186 {
187 public:
188  SensorIterator(const Project*);
189 
190  SensorIterator(const Site*);
191 
192  SensorIterator(const DSMConfig*);
193 
194  SensorIterator();
195 
196  bool hasNext();
197 
198  DSMSensor* next() { return *_sensorItr++; }
199 
200 private:
201 
203 
204  const std::list<DSMSensor*>* _sensors;
205 
206  std::list<DSMSensor*>::const_iterator _sensorItr;
207 };
208 
209 class SampleSource;
210 class SampleIOProcessor;
211 class SampleTag;
212 
218 {
219 public:
220 
227  _stags(x._stags),_sampleTagItr(_stags.begin())
228  {
229  /* Must define a copy constructor since _stags
230  * is a list and not a pointer. The default copy
231  * constructor is OK for all the other iterators, since they
232  * contain a pointer to a container which is part of
233  * Project::getInstance(), and so remains valid
234  * (hopefully) over the life of the iterator.
235  * In this class _stags is a new list, so we must reset
236  * _sampleTagItr to point to the beginning of the new list.
237  */
238  }
239 
241  {
242  /* Must define an assignment operator for the same reason
243  * mentioned above in the copy constructor.
244  */
245  if (this != &x) {
247  _stags = x._stags;
248  _sampleTagItr = _stags.begin();
249  }
250  return *this;
251  }
252 
253  SampleTagIterator(const Project*);
254 
256 
258 
259  SampleTagIterator(const Site*);
260 
262 
264 
266 
267  bool hasNext();
268 
269  const SampleTag* next() { return *_sampleTagItr++; }
270 
271 private:
272 
274 
276 
277  std::list<const SampleTag*> _stags;
278 
279  std::list<const SampleTag*>::const_iterator _sampleTagItr;
280 };
281 
287 {
288 public:
289 
290  VariableIterator(const Project*);
291 
292  VariableIterator(const DSMServer*);
293 
295 
296  VariableIterator(const Site*);
297 
298  VariableIterator(const DSMConfig*);
299 
301 
302  VariableIterator(const SampleTag*);
303 
311  {
312  }
313 
318  {
319  if (&rhs != this) {
321  _variables = rhs._variables;
323  }
324  return *this;
325  }
326 
327  bool hasNext();
328 
329  const Variable* next() { return *_variableItr++; }
330 
331 private:
332 
334 
335  const std::vector<const Variable*>* _variables;
336 
337  std::vector<const Variable*>::const_iterator _variableItr;
338 };
339 
340 }} // namespace nidas namespace core
341 
342 #endif
const DSMConfig * next()
Definition: NidsIterators.h:135
Class for iterating over the DSMServers of a Project.
Definition: NidsIterators.h:66
DSMServiceIterator()
Definition: NidsIterators.cc:86
VariableIterator & operator=(const VariableIterator &rhs)
Excplicit assignment operator to satisfy -Weffc++.
Definition: NidsIterators.h:317
SampleTagIterator _sampleTagIterator
Definition: NidsIterators.h:333
DSMServer * next()
Definition: NidsIterators.h:77
ProcessorIterator _processorIterator
Definition: NidsIterators.h:275
const std::list< Site * > * _sites
Definition: NidsIterators.h:58
DSMService * next()
Definition: NidsIterators.h:104
SiteIterator _siteIterator
Definition: NidsIterators.h:85
const std::list< const DSMConfig * > * _dsms
Definition: NidsIterators.h:141
std::list< DSMSensor * >::const_iterator _sensorItr
Definition: NidsIterators.h:206
A measurement site.
Definition: Site.h:49
const std::list< DSMServer * > * _servers
Definition: NidsIterators.h:81
bool hasNext()
Definition: NidsIterators.cc:315
bool hasNext()
Definition: NidsIterators.cc:141
ProcessorIterator()
Definition: NidsIterators.cc:135
DSMConfigIterator()
Definition: NidsIterators.cc:185
DSMConfigIterator _dsmIterator
Definition: NidsIterators.h:172
Class describing a sampled variable.
Definition: Variable.h:46
bool hasNext()
Definition: NidsIterators.cc:267
Class that should include all that is configurable about a DSM.
Definition: DSMConfig.h:55
Pure virtual interface for a source of Samples.
Definition: SampleSource.h:48
bool hasNext()
Definition: NidsIterators.cc:169
Class for iterating over the Variables of a Project, Site, DSMConfig, DSMSensor, or SampleTag...
Definition: NidsIterators.h:286
const std::vector< const Variable * > * _variables
Definition: NidsIterators.h:335
const SampleTag * next()
Definition: NidsIterators.h:269
std::list< Site * >::const_iterator _siteItr
Definition: NidsIterators.h:60
bool hasNext()
Definition: NidsIterators.cc:217
SensorIterator _sensorIterator
Definition: NidsIterators.h:273
bool hasNext()
Definition: NidsIterators.cc:189
std::list< DSMServer * >::const_iterator _serverItr
Definition: NidsIterators.h:83
SampleIOProcessor * next()
Definition: NidsIterators.h:166
std::list< const SampleTag * >::const_iterator _sampleTagItr
Definition: NidsIterators.h:279
SensorIterator()
Definition: NidsIterators.cc:213
VariableIterator(const VariableIterator &x)
Excplicit copy constructor to satisfy -Weffc++.
Definition: NidsIterators.h:307
SiteIterator()
Definition: NidsIterators.cc:165
const std::list< DSMSensor * > * _sensors
Definition: NidsIterators.h:204
VariableIterator(const Project *)
Definition: NidsIterators.cc:289
Class for iterating over the Processors of a DSMServer or DSMConfig.
Definition: NidsIterators.h:149
Class for iterating over the DSMServices of a DSMServer.
Definition: NidsIterators.h:91
const Variable * next()
Definition: NidsIterators.h:329
DSMConfigIterator _dsmIterator
Definition: NidsIterators.h:202
SampleTagIterator(const SampleTagIterator &x)
Copy constructor.
Definition: NidsIterators.h:224
std::list< const SampleTag * > _stags
Definition: NidsIterators.h:277
DSMServiceIterator _serviceIterator
Definition: NidsIterators.h:170
std::vector< const Variable * >::const_iterator _variableItr
Definition: NidsIterators.h:337
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition: DSMSensor.h:87
Class for iterating over the Sites of a Project, or the Sites served by a DSMServer.
Definition: NidsIterators.h:45
SampleTagIterator()
Definition: NidsIterators.cc:261
const std::list< SampleIOProcessor * > * _processors
Definition: NidsIterators.h:174
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition: NidsIterators.h:217
SiteIterator _siteIterator
Definition: NidsIterators.h:139
DSMServerIterator _dsmServerIterator
Definition: NidsIterators.h:108
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
Interface of a processor of samples.
Definition: SampleIOProcessor.h:49
Class for iterating over the DSMSensors of a Project, Site, or DSMConfig.
Definition: NidsIterators.h:185
DSMServerIterator()
Definition: NidsIterators.cc:54
Definition: Project.h:60
std::list< SampleIOProcessor * >::const_iterator _procItr
Definition: NidsIterators.h:176
const std::list< DSMService * > * _services
Definition: NidsIterators.h:110
bool hasNext()
Definition: NidsIterators.cc:91
A provider of services to a DSM.
Definition: DSMServer.h:50
Class for iterating over the DSMConfigs of a Project or Site.
Definition: NidsIterators.h:124
Base class for a service, as built from a &lt;service&gt; XML tag.
Definition: DSMService.h:47
SampleTagIterator & operator=(const SampleTagIterator &x)
Definition: NidsIterators.h:240
bool hasNext()
Definition: NidsIterators.cc:58
std::list< DSMService * >::const_iterator _dsmServiceItr
Definition: NidsIterators.h:112
Site * next()
Definition: NidsIterators.h:54
std::list< const DSMConfig * >::const_iterator _dsmItr
Definition: NidsIterators.h:143
DSMSensor * next()
Definition: NidsIterators.h:198