nidas v1.2.3
ProjectConfigs.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
27#ifndef NIDAS_CORE_PROJECTCONFIGS_H
28#define NIDAS_CORE_PROJECTCONFIGS_H
29
30#include <nidas/util/UTime.h>
32#include "XMLException.h"
33#include "XMLParser.h"
34#include "Project.h"
35
36// #include <xercesc/dom/DOMDocument.hpp>
37// #include <xercesc/dom/DOMNode.hpp>
38#include <xercesc/dom/DOMElement.hpp>
39#include <xercesc/dom/DOMException.hpp>
40// #include <xercesc/dom/DOMNamedNodeMap.hpp>
41
42#include <list>
43
44namespace nidas { namespace core {
45
46class Project;
47
49{
50public:
51
53
54 const std::string& getName() const { return _name; }
55
56 void setName(const std::string& val) { _name = val; }
57
58 const std::string& getXMLName() const { return _xmlName; }
59
60 void setXMLName(const std::string& val) { _xmlName = val; }
61
65 const nidas::util::UTime& getBeginTime() const { return _beginTime; }
66
68
72 const nidas::util::UTime& getEndTime() const { return _endTime; }
73
74 void setEndTime(const nidas::util::UTime& val) { _endTime = val; }
75
83 void addEnvironmentVariable(const std::string& name, const std::string& value);
84
85 std::map<std::string,std::string> getEnvironmentVariables() const
86 {
87 return _envVars;
88 }
89
94 void putenv() const;
95
102 void initProject(Project& project) const;
103
107 void fromDOMElement(const xercesc::DOMElement*);
108
112 xercesc::DOMElement*
113 toDOMParent(xercesc::DOMElement* parent) const;
114
118 xercesc::DOMElement*
119 toDOMElement(xercesc::DOMElement* node) const;
120
121private:
122
123 std::string _name;
124
125 std::string _xmlName;
126
128
130
131 std::map<std::string,std::string> _envVars;
132
133};
134
139public:
143 bool operator() (const ProjectConfig* x, const ProjectConfig *y)
144 const {
145 return x->getBeginTime() < y->getEndTime();
146 }
147};
148
152public:
155
159 const ProjectConfig* getConfig(const nidas::util::UTime& begin) const;
160
164 const ProjectConfig* getConfig(const std::string& name) const;
165
166 const std::list<const ProjectConfig*>& getConfigs() const;
167
181
188 throw();
189
190 void removeConfig(const ProjectConfig* val);
191
196 void parseXML(const std::string& xmlFileName);
197
202 void writeXML(const std::string& xmlFileName);
203
207 void fromDOMElement(const xercesc::DOMElement*);
208
212 xercesc::DOMElement*
213 toDOMParent(xercesc::DOMElement* parent) const;
214
218 xercesc::DOMElement*
219 toDOMElement(xercesc::DOMElement* node) const;
220
221private:
222
223 std::string _xmlName;
224
225 std::list<const ProjectConfig*> _constConfigs;
226
227 std::list<ProjectConfig*> _configs;
228
229};
230
231}} // namespace nidas namespace core
232
233#endif
Sample time tag comparator.
Definition ProjectConfigs.h:138
bool operator()(const ProjectConfig *x, const ProjectConfig *y) const
Return true if x is less than y.
Definition ProjectConfigs.h:143
Definition ProjectConfigs.h:49
const nidas::util::UTime & getEndTime() const
Returns UTime::MAX if unset.
Definition ProjectConfigs.h:72
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node) const
Definition ProjectConfigs.cc:419
std::string _xmlName
Definition ProjectConfigs.h:125
const std::string & getName() const
Definition ProjectConfigs.h:54
void setName(const std::string &val)
Definition ProjectConfigs.h:56
const nidas::util::UTime & getBeginTime() const
Returns UTime::MIN if unset.
Definition ProjectConfigs.h:65
nidas::util::UTime _endTime
Definition ProjectConfigs.h:129
ProjectConfig()
Definition ProjectConfigs.cc:44
void setEndTime(const nidas::util::UTime &val)
Definition ProjectConfigs.h:74
const std::string & getXMLName() const
Definition ProjectConfigs.h:58
nidas::util::UTime _beginTime
Definition ProjectConfigs.h:127
void addEnvironmentVariable(const std::string &name, const std::string &value)
Add an environment variable to this ProjectConfig.
Definition ProjectConfigs.cc:313
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent) const
Definition ProjectConfigs.cc:409
void fromDOMElement(const xercesc::DOMElement *)
Definition ProjectConfigs.cc:330
void initProject(Project &project) const
Definition ProjectConfigs.cc:49
void putenv() const
Update the process environment with the current list of environment variables in the ProjectConfig.
Definition ProjectConfigs.cc:318
void setBeginTime(const nidas::util::UTime &val)
Definition ProjectConfigs.h:67
std::string _name
Definition ProjectConfigs.h:123
std::map< std::string, std::string > getEnvironmentVariables() const
Definition ProjectConfigs.h:85
void setXMLName(const std::string &val)
Definition ProjectConfigs.h:60
std::map< std::string, std::string > _envVars
Definition ProjectConfigs.h:131
Definition ProjectConfigs.h:151
std::list< ProjectConfig * > _configs
Definition ProjectConfigs.h:227
void writeXML(const std::string &xmlFileName)
Definition ProjectConfigs.cc:237
const std::list< const ProjectConfig * > & getConfigs() const
Definition ProjectConfigs.cc:195
std::list< const ProjectConfig * > _constConfigs
Definition ProjectConfigs.h:225
void removeConfig(const ProjectConfig *val)
Definition ProjectConfigs.cc:152
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node) const
Definition ProjectConfigs.cc:301
void fromDOMElement(const xercesc::DOMElement *)
Definition ProjectConfigs.cc:219
void parseXML(const std::string &xmlFileName)
Definition ProjectConfigs.cc:200
ProjectConfigs()
Definition ProjectConfigs.cc:74
const ProjectConfig * getConfig(const nidas::util::UTime &begin) const
Definition ProjectConfigs.cc:167
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent) const
Definition ProjectConfigs.cc:289
void addConfigByTime(ProjectConfig *val)
Add a project configuration, inserting it in the list, which should be sorted by time.
Definition ProjectConfigs.cc:97
std::string _xmlName
Definition ProjectConfigs.h:223
void addConfigByName(ProjectConfig *val)
Add a project configuration, replacing an existing configuration if the name matches,...
Definition ProjectConfigs.cc:134
~ProjectConfigs()
Definition ProjectConfigs.cc:78
Definition Project.h:60
A class for parsing, formatting and doing operations on time, based on Unix time conventions,...
Definition UTime.h:95
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