nidas  v1.2-1520
Datasets.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  ** 2014, 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_DATASETS_H
28 #define NIDAS_CORE_DATASETS_H
29 
31 #include "XMLException.h"
32 #include "XMLParser.h"
33 
34 #include <xercesc/dom/DOMElement.hpp>
35 #include <xercesc/dom/DOMException.hpp>
36 
37 #include <list>
38 
39 namespace nidas { namespace core {
40 
47 class Dataset
48 {
49 public:
50 
51  Dataset();
52 
53  const std::string& getName() const { return _name; }
54 
55  void setName(const std::string& val) { _name = val; }
56 
57  const std::string& getDescription() const { return _desc; }
58 
59  void setDescription(const std::string& val) { _desc = val; }
60 
61  float getResolutionSecs() const { return _resSecs; }
62 
63  void setResolutionSecs(float val) { _resSecs = val; }
64 
72  void addEnvironmentVariable(const std::string& name, const std::string& value);
73 
74  std::map<std::string,std::string> getEnvironmentVariables() const
75  {
76  return _envVars;
77  }
78 
83  void putenv() const;
84 
85  void fromDOMElement(const xercesc::DOMElement*)
86  throw(nidas::util::InvalidParameterException);
87 
88  xercesc::DOMElement*
89  toDOMParent(xercesc::DOMElement* parent) const
90  throw(xercesc::DOMException);
91 
92  xercesc::DOMElement*
93  toDOMElement(xercesc::DOMElement* node) const
94  throw(xercesc::DOMException);
95 
96 private:
97 
98  std::string _name;
99 
100  std::string _desc;
101 
102  float _resSecs;
103 
104  std::map<std::string,std::string> _envVars;
105 
106 };
107 
113 class Datasets {
114 public:
115  Datasets();
116 
117  const Dataset& getDataset(const std::string& name) const
119 
120  std::list<Dataset> getDatasets() const;
121 
122  void addDataset(const Dataset& val)
124 
125  void removeDataset(const Dataset& val);
126 
127  void parseXML(const std::string& xmlFileName,bool verbose=true)
130 
131  void writeXML(const std::string& xmlFileName)
133 
134  void fromDOMElement(const xercesc::DOMElement*)
136 
137  xercesc::DOMElement*
138  toDOMParent(xercesc::DOMElement* parent) const
139  throw(xercesc::DOMException);
140 
141  xercesc::DOMElement*
142  toDOMElement(xercesc::DOMElement* node) const
143  throw(xercesc::DOMException);
144 
145 
146 private:
147 
148  std::string _xmlName;
149 
150  std::map<std::string, Dataset> _datasetsByName;
151 
152 };
153 
154 }} // namespace nidas namespace core
155 
156 #endif
std::map< std::string, Dataset > _datasetsByName
Definition: Datasets.h:150
static int verbose
Definition: lidar_vel.cc:45
Exception which can be built from an xerces::XMLException, xercesc::SAXException, or xercesc::DOMExce...
Definition: XMLException.h:43
std::map< std::string, std::string > _envVars
Definition: Datasets.h:104
Dataset()
Definition: Datasets.cc:48
void setResolutionSecs(float val)
Definition: Datasets.h:63
A Dataset is a named collection of parameters, that are used in data processing.
Definition: Datasets.h:47
const std::string & getDescription() const
Definition: Datasets.h:57
void setName(const std::string &val)
Definition: Datasets.h:55
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent) const
Definition: Datasets.cc:289
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node) const
Definition: Datasets.cc:300
std::string _xmlName
Definition: Datasets.h:148
void setDescription(const std::string &val)
Definition: Datasets.h:59
void addEnvironmentVariable(const std::string &name, const std::string &value)
Add an environment variable to this Dataset.
Definition: Datasets.cc:207
void fromDOMElement(const xercesc::DOMElement *)
Definition: Datasets.cc:223
std::map< std::string, std::string > getEnvironmentVariables() const
Definition: Datasets.h:74
std::string _desc
Definition: Datasets.h:100
const std::string & getName() const
Definition: Datasets.h:53
Definition: IOException.h:37
std::string _name
Definition: Datasets.h:98
void putenv() const
Update the process environment with the current list of environment variables in the Dataset...
Definition: Datasets.cc:212
float getResolutionSecs() const
Definition: Datasets.h:61
float _resSecs
Definition: Datasets.h:102
A collection of Datasets.
Definition: Datasets.h:113
Definition: InvalidParameterException.h:35