nidas v1.2.3
Site.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 ** 2005, 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
27#ifndef NIDAS_CORE_SITE_H
28#define NIDAS_CORE_SITE_H
29
30#include "DOMable.h"
31#include "DSMConfig.h"
32#include "Parameter.h"
33#include "Dictionary.h"
34
35#include <list>
36#include <map>
37
38namespace nidas { namespace core {
39
40class Project;
41class DSMServer;
42class DSMConfig;
43class DSMSensor;
44
49class Site : public DOMable {
50public:
51 Site();
52
53 virtual ~Site();
54
58 void setName(const std::string& val) { _name = val; }
59
60 const std::string& getName() const { return _name; }
61
68 void setNumber(int val) { _number = val; }
69
70 int getNumber() const { return _number; }
71
75 bool operator == (const Site& x) const
76 {
77 if (this == &x) return true;
78 return _name == x._name &&
79 _suffix == x._suffix &&
80 _number == x._number;
81 }
82
86 bool operator != (const Site& x) const
87 {
88 return !operator == (x);
89 }
90
94 bool operator < (const Site& x) const
95 {
96 if (operator == (x)) return false;
97 return _name.compare(x._name) < 0;
98 }
99
104 void setSuffix(const std::string& val) { _suffix = val; }
105
106 const std::string& getSuffix() const { return _suffix; }
107
111 const Project* getProject() const { return _project; }
112
114
118 void setProject(Project* val) { _project = val; }
119
126 {
127 _dsms.push_back(dsm);
128 _ncDsms.push_back(dsm);
129 }
130
132 {
133 std::list<const DSMConfig*>::iterator di;
134 for (di = _dsms.begin(); di != _dsms.end(); )
135 if (dsm == *di) di = _dsms.erase(di);
136 else ++di;
137 for (std::list<DSMConfig*>::iterator di = _ncDsms.begin();
138 di != _ncDsms.end(); )
139 if (dsm == *di) {
140 DSMConfig* deletableDSMConfig = *di;
141 di = _ncDsms.erase(di);
142 // The DSM configuration has been removed from both lists, now delete the object.
143 delete deletableDSMConfig;
144 }
145 else ++di;
146 }
147
148 const std::list<const DSMConfig*>& getDSMConfigs() const
149 {
150 return _dsms;
151 }
152
153 const std::list<DSMConfig*>& getDSMConfigs()
154 {
155 return _ncDsms;
156 }
157
161 void addServer(DSMServer* srvr) { _servers.push_back(srvr); }
162
163 const std::list<DSMServer*>& getServers() const { return _servers; }
164
170 DSMServer* findServer(const std::string& hostname) const;
171
175 const DSMConfig* findDSM(unsigned int id) const;
176
180 const DSMConfig* findDSM(const std::string& name) const;
181
185 DSMSensor* findSensor(unsigned int id) const;
186
192 void initSensors();
193
199 void initSensors(DSMConfig* dsm);
200
206 virtual void addParameter(Parameter* val);
207
208 virtual const Parameter* getParameter(const std::string& name) const;
209
210 virtual const std::list<const Parameter*>& getParameters() const;
211
217 virtual bool getApplyVariableConversions() const
218 {
219 return _applyCals;
220 }
221
233 std::string expandString(const std::string& input) const
234 {
235 return _dictionary.expandString(input);
236 }
237
242 bool getTokenValue(const std::string& token,std::string& value) const
243 {
244 return _dictionary.getTokenValue(token,value);
245 }
246
248 {
249 return _dictionary;
250 }
251
253
255
257
259
261
263
265
269 void validate();
270
274 void fromDOMElement(const xercesc::DOMElement*);
275
279 xercesc::DOMElement*
280 toDOMParent(xercesc::DOMElement* parent, bool complete) const;
281
285 xercesc::DOMElement*
286 toDOMElement(xercesc::DOMElement* node, bool complete) const;
287
288private:
289
294
295 std::string _name;
296
298
299 std::string _suffix;
300
301 class MyDictionary : public Dictionary {
302 public:
303 MyDictionary(Site* site): _site(site) {}
306 {
307 if (&rhs != this) {
308 *(Dictionary*) this = rhs;
309 _site = rhs._site;
310 }
311 return *this;
312 }
313 bool getTokenValue(const std::string& token, std::string& value) const;
314 private:
317
318 std::list<const DSMConfig*> _dsms;
319
320 std::list<DSMConfig*> _ncDsms;
321
322 std::list<DSMServer*> _servers;
323
327 std::map<std::string,Parameter*> _parameterMap;
328
333 std::list<const Parameter*> _constParameters;
334
338 Site(const Site&);
339
344
345protected:
350
351};
352
353}} // namespace nidas namespace core
354
355#endif
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method,...
Definition DOMable.h:51
Class for iterating over the DSMConfigs of a Project or Site.
Definition NidsIterators.h:125
Class that should include all that is configurable about a DSM.
Definition DSMConfig.h:55
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition DSMSensor.h:88
Class for iterating over the DSMServers of a Project.
Definition NidsIterators.h:67
A provider of services to a DSM.
Definition DSMServer.h:50
Class for iterating over the DSMServices of a DSMServer.
Definition NidsIterators.h:92
Interface for a Dictionary class, which can return a string value for a string token name.
Definition Dictionary.h:38
std::string expandString(const std::string &input) const
Utility function that scans a string for tokens like ${XXXX}, or $XXX followed by any characters from...
Definition Dictionary.cc:34
Definition Parameter.h:47
Class for iterating over the Processors of a DSMServer or DSMConfig.
Definition NidsIterators.h:150
Definition Project.h:60
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition NidsIterators.h:218
Class for iterating over the DSMSensors of a Project, Site, or DSMConfig.
Definition NidsIterators.h:186
Definition Site.h:301
MyDictionary(const MyDictionary &x)
Definition Site.h:304
MyDictionary & operator=(const MyDictionary &rhs)
Definition Site.h:305
MyDictionary(Site *site)
Definition Site.h:303
bool getTokenValue(const std::string &token, std::string &value) const
Definition Site.cc:449
Site * _site
Definition Site.h:315
A measurement site.
Definition Site.h:49
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent, bool complete) const
Definition Site.cc:337
const std::list< DSMServer * > & getServers() const
Definition Site.h:163
bool operator<(const Site &x) const
Less than operator for Site, compares the names.
Definition Site.h:94
void fromDOMElement(const xercesc::DOMElement *)
Definition Site.cc:153
void initSensors()
Initialize all sensors for a Site.
Definition Site.cc:107
Site(const Site &)
Copy not supported.
bool operator==(const Site &x) const
Equivalence operator for Site, checks name.
Definition Site.h:75
void addDSMConfig(DSMConfig *dsm)
A Site contains one or more DSMs.
Definition Site.h:125
const Project * getProject() const
Provide pointer to Project.
Definition Site.h:111
std::list< DSMConfig * > _ncDsms
Definition Site.h:320
std::list< const Parameter * > _constParameters
List of const pointers to Parameters for providing via getParameters().
Definition Site.h:333
const std::list< DSMConfig * > & getDSMConfigs()
Definition Site.h:153
Site()
Definition Site.cc:43
std::string expandString(const std::string &input) const
Utility function to expand ${TOKEN} or $TOKEN fields in a string.
Definition Site.h:233
int getNumber() const
Definition Site.h:70
DSMServerIterator getDSMServerIterator() const
Definition Site.cc:69
const DSMConfig * findDSM(unsigned int id) const
Find a DSM by id.
Definition Site.cc:401
Project * getProject()
Definition Site.h:113
void setNumber(int val)
Identify the Site by number.
Definition Site.h:68
std::list< DSMServer * > _servers
Definition Site.h:322
SensorIterator getSensorIterator() const
Definition Site.cc:89
bool _applyCals
Should NIDAS apply calibrations, or defer them to other processing.
Definition Site.h:349
DSMServer * findServer(const std::string &hostname) const
Look for a server on this aircraft that either has no name or whose name matches hostname.
Definition Site.cc:372
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node, bool complete) const
Definition Site.cc:347
ProcessorIterator getProcessorIterator() const
Definition Site.cc:79
std::string _name
Definition Site.h:295
std::list< const DSMConfig * > _dsms
Definition Site.h:318
virtual ~Site()
Definition Site.cc:52
SampleTagIterator getSampleTagIterator() const
Definition Site.cc:94
const std::list< const DSMConfig * > & getDSMConfigs() const
Definition Site.h:148
DSMConfigIterator getDSMConfigIterator() const
Definition Site.cc:84
void setProject(Project *val)
Set the current project for this Site.
Definition Site.h:118
bool getTokenValue(const std::string &token, std::string &value) const
Implement a lookup for tokens that I know about, like $SITE, and $AIRCRAFT.
Definition Site.h:242
virtual const Parameter * getParameter(const std::string &name) const
Definition Site.cc:141
Site & operator=(const Site &)
Assignment not supported.
virtual bool getApplyVariableConversions() const
Do we want DSMSensor::process methods at this site to apply variable conversions? Currently on raf....
Definition Site.h:217
void validate()
Definition Site.cc:261
bool operator!=(const Site &x) const
Non-equivalence operator for Site.
Definition Site.h:86
void removeDSMConfig(DSMConfig *dsm)
Definition Site.h:131
virtual const std::list< const Parameter * > & getParameters() const
Definition Site.cc:148
nidas::core::Site::MyDictionary _dictionary
void setName(const std::string &val)
Set the name of the Site.
Definition Site.h:58
DSMServiceIterator getDSMServiceIterator() const
Definition Site.cc:74
DSMSensor * findSensor(unsigned int id) const
Find a DSMSensor by the full id, both the DSM id and the sensor id.
Definition Site.cc:430
VariableIterator getVariableIterator() const
Definition Site.cc:99
void addServer(DSMServer *srvr)
A Site has one or more DSMServers.
Definition Site.h:161
const std::string & getName() const
Definition Site.h:60
std::map< std::string, Parameter * > _parameterMap
Mapping of Parameters, by name.
Definition Site.h:327
void setSuffix(const std::string &val)
Set the suffix for the Site.
Definition Site.h:104
Project * _project
Pointer back to my project.
Definition Site.h:293
int _number
Definition Site.h:297
const Dictionary & getDictionary() const
Definition Site.h:247
const std::string & getSuffix() const
Definition Site.h:106
virtual void addParameter(Parameter *val)
Add a parameter to this Site.
Definition Site.cc:135
std::string _suffix
Definition Site.h:299
Class for iterating over the Variables of a Project, Site, DSMConfig, DSMSensor, or SampleTag.
Definition NidsIterators.h:287
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31