nidas  v1.2-1520
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 
44 namespace nidas { namespace core {
45 
46 class Project;
47 
49 {
50 public:
51 
52  ProjectConfig();
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 
62  const nidas::util::UTime& getBeginTime() const { return _beginTime; }
63 
64  void setBeginTime(const nidas::util::UTime& val) { _beginTime = val; }
65 
66  const nidas::util::UTime& getEndTime() const { return _endTime; }
67 
68  void setEndTime(const nidas::util::UTime& val) { _endTime = val; }
69 
77  void addEnvironmentVariable(const std::string& name, const std::string& value);
78 
79  std::map<std::string,std::string> getEnvironmentVariables() const
80  {
81  return _envVars;
82  }
83 
88  void putenv() const;
89 
93  void initProject(Project& project) const throw(nidas::core::XMLException,
95 
96  void fromDOMElement(const xercesc::DOMElement*)
97  throw(nidas::util::InvalidParameterException);
98 
99  xercesc::DOMElement*
100  toDOMParent(xercesc::DOMElement* parent) const
101  throw(xercesc::DOMException);
102 
103  xercesc::DOMElement*
104  toDOMElement(xercesc::DOMElement* node) const
105  throw(xercesc::DOMException);
106 
107 private:
108 
109  std::string _name;
110 
111  std::string _xmlName;
112 
113  nidas::util::UTime _beginTime;
114 
115  nidas::util::UTime _endTime;
116 
117  std::map<std::string,std::string> _envVars;
118 
119 };
120 
125 public:
129  bool operator() (const ProjectConfig* x, const ProjectConfig *y)
130  const {
131  return x->getBeginTime() < y->getEndTime();
132  }
133 };
134 
138 public:
139  ProjectConfigs();
140  ~ProjectConfigs();
141 
142  const ProjectConfig* getConfig(const nidas::util::UTime& begin) const
144 
145  const ProjectConfig* getConfig(const std::string& name) const
147 
148  const std::list<const ProjectConfig*>& getConfigs() const;
149 
160  void addConfigByTime(ProjectConfig* val)
162 
168  void addConfigByName(ProjectConfig* val)
169  throw();
170 
171  void removeConfig(const ProjectConfig* val);
172 
173  void parseXML(const std::string& xmlFileName)
176 
177  void writeXML(const std::string& xmlFileName)
179 
180  void fromDOMElement(const xercesc::DOMElement*)
182 
183  xercesc::DOMElement*
184  toDOMParent(xercesc::DOMElement* parent) const
185  throw(xercesc::DOMException);
186 
187  xercesc::DOMElement*
188  toDOMElement(xercesc::DOMElement* node) const
189  throw(xercesc::DOMException);
190 
191 
192 private:
193 
194  std::string _xmlName;
195 
196  std::list<const ProjectConfig*> _constConfigs;
197 
198  std::list<ProjectConfig*> _configs;
199 
200 };
201 
202 }} // namespace nidas namespace core
203 
204 #endif
std::string _xmlName
Definition: ProjectConfigs.h:111
void initProject(Project &project) const
Definition: ProjectConfigs.cc:50
Definition: ProjectConfigs.h:48
A class for parsing, formatting and doing operations on time, based on Unix time conventions, where leap seconds are ignored, so that there are always 60 seconds in a minute, 3600 seconds in an hour and 86400 seconds in a day.
Definition: UTime.h:76
void setEndTime(const nidas::util::UTime &val)
Definition: ProjectConfigs.h:68
nidas::util::UTime _endTime
Definition: ProjectConfigs.h:115
void setXMLName(const std::string &val)
Definition: ProjectConfigs.h:60
Exception which can be built from an xerces::XMLException, xercesc::SAXException, or xercesc::DOMExce...
Definition: XMLException.h:43
void setName(const std::string &val)
Definition: ProjectConfigs.h:56
std::string _name
Definition: ProjectConfigs.h:109
const nidas::util::UTime & getBeginTime() const
Definition: ProjectConfigs.h:62
std::list< const ProjectConfig * > _constConfigs
Definition: ProjectConfigs.h:196
void fromDOMElement(const xercesc::DOMElement *)
Definition: ProjectConfigs.cc:341
std::map< std::string, std::string > _envVars
Definition: ProjectConfigs.h:117
Definition: ProjectConfigs.h:137
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node) const
Definition: ProjectConfigs.cc:432
const std::string & getName() const
Definition: ProjectConfigs.h:54
const nidas::util::UTime & getEndTime() const
Definition: ProjectConfigs.h:66
std::string _xmlName
Definition: ProjectConfigs.h:194
Sample time tag comparator.
Definition: ProjectConfigs.h:124
void setBeginTime(const nidas::util::UTime &val)
Definition: ProjectConfigs.h:64
Definition: IOException.h:37
std::list< ProjectConfig * > _configs
Definition: ProjectConfigs.h:198
std::map< std::string, std::string > getEnvironmentVariables() const
Definition: ProjectConfigs.h:79
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent) const
Definition: ProjectConfigs.cc:421
ProjectConfig()
Definition: ProjectConfigs.cc:43
void addEnvironmentVariable(const std::string &name, const std::string &value)
Add an environment variable to this ProjectConfig.
Definition: ProjectConfigs.cc:324
nidas::util::UTime _beginTime
Definition: ProjectConfigs.h:113
Definition: Project.h:60
void putenv() const
Update the process environment with the current list of environment variables in the ProjectConfig...
Definition: ProjectConfigs.cc:329
const std::string & getXMLName() const
Definition: ProjectConfigs.h:58
Definition: InvalidParameterException.h:35