MetadataInfo.h
Go to the documentation of this file.
1/*!
2 * \file MetadataInfo.h
3 * \brief Define MetadataInfo class used by modules
4 *
5 * Changelog:
6 * - 1. 2018-3-16 - lj - Simplify code, and add In/Output parameters related for MPI version.
7 *
8 * \author Junzhi Liu, Liangjun Zhu
9 * \version 1.1
10 */
11#ifndef SEIMS_METADATA_INFO_H
12#define SEIMS_METADATA_INFO_H
13
14#include <vector>
15
16#include "basic.h"
17#include "MetadataInfoConst.h"
18
19using namespace ccgl;
20using std::vector;
21
22/*!
23 * \ingroup module_setting
24 * \struct ModelClass
25 * \brief Module basic description
26 */
27struct ModelClass {
28 ModelClass(): Name(""), Description("") {
29 }
30
31 string Name;
32 string Description;
33};
34
35/*!
36 * \ingroup module_setting
37 * \struct Information
38 *
39 * \brief Module development information class
40 */
42 Information() : Id(""), Name(""), Description(""), Version(""), Author(""),
43 EMail(""), Website(""), Helpfile("") {
44 }
45
46 string Id; ///< Module ID
47 string Name; ///< Module Name
48 string Description; ///< Module Description
49 string Version; ///< Module Version
50 string Author; ///< Author
51 string EMail; ///< Email
52 string Website; ///< Website
53 string Helpfile; ///< Helpfile
54};
55
56/*!
57 * \ingroup module_setting
58 * \struct baseParameter
59 *
60 * \brief Basic model parameter information
61 */
64 }
65
66 string Name; ///< Name
67 string Units; ///< Units
68 string Description; ///< Description
69 dimensionTypes Dimension; ///< Data dimension type
70};
71
72/*!
73 * \ingroup module_setting
74 * \struct Parameter
75 *
76 * \brief Model parameter information class
77 */
79 Parameter() : Source("") {
80 }
81
82 string Source; ///< Source type
83};
84
85/*!
86 * \ingroup module_setting
87 * \struct InputVariable
88 *
89 * \brief Input variable information class
90 */
92 InputVariable() : tfType(TF_None) {
93 }
94
95 transferTypes tfType;
96};
97
98/*!
99 * \ingroup module_setting
100 * \struct OutputVariable
101 * \brief Output variable information class
102 */
104 OutputVariable() : tfType(TF_None) {
105 }
106
107 transferTypes tfType;
108};
109
110/*!
111 * \ingroup module_setting
112 * \struct InOutputVariable
113 * \brief Input and output variable information class
114 */
117 }
118};
119
120/*!
121 * \ingroup module_setting
122 * \class MetadataInfo
123 * \brief Metadata information of module
124 */
126public:
127 MetadataInfo() { m_strSchemaVersion = "0.4"; }
128
130
131 string SchemaVersion() { return m_strSchemaVersion; }
132
133 void SetClass(const char* name, const char* description);
134
135 string GetClassName() { return m_oClass.Name; }
136
137 string GetClassDescription() { return m_oClass.Description; }
138
139 void SetID(const char* ID) { m_Info.Id = ID; }
140
141 string GetID() { return m_Info.Id; }
142
143 void SetName(const char* name) { m_Info.Name = name; }
144
145 string GetName() { return m_Info.Name; }
146
147 void SetDescription(const char* description) { m_Info.Description = description; }
148
149 string GetDescription() { return m_Info.Description; }
150
151 void SetVersion(const char* version) { m_Info.Version = version; }
152
153 string GetVersion() { return m_Info.Version; }
154
155 void SetAuthor(const char* author) { m_Info.Author = author; }
156
157 string GetAuthor() { return m_Info.Author; }
158
159 void SetEmail(const char* email) { m_Info.EMail = email; }
160
161 string GetEmail() { return m_Info.EMail; }
162
163 void SetWebsite(const char* site) { m_Info.Website = site; }
164
165 string GetWebsite() { return m_Info.Website; }
166
167 void SetHelpfile(const char* file) { m_Info.Helpfile = file; }
168
169 string GetHelpfile() { return m_Info.Helpfile; }
170
171 /************ INPUT PARAMETERS FROM OTHER MODULES ************/
172
173 int GetInputCount() { return CVT_INT(m_vInputs.size()); }
174
175 int AddInput(const char* name, const char* units, const char* desc, const char* source, dimensionTypes dimType,
176 transferTypes tfType = TF_None);
177
178 string GetInputName(int index) { return index >= 0 && index < m_vInputs.size() ? m_vInputs[index].Name : ""; }
179
180 string GetInputUnits(int index) { return index >= 0 && index < m_vInputs.size() ? m_vInputs[index].Units : ""; }
181
182 string GetInputDescription(int index) {
183 return index >= 0 && index < m_vInputs.size() ? m_vInputs[index].Description : "";
184 }
185
186 string GetInputSource(int index) {
187 return index >= 0 && index < m_vInputs.size() ? m_vInputs[index].Source : "";
188 }
189
190 dimensionTypes GetInputDimension(int index) {
191 return index >= 0 && index < m_vInputs.size() ? m_vInputs[index].Dimension : DT_Unknown;
192 }
193
194 transferTypes GetInputTfType(int index) {
195 return index >= 0 && index < m_vInputs.size() ? m_vInputs[index].tfType : TF_None;
196 }
197
198 InputVariable GetInput(int index) {
199 return index >= 0 && index < m_vInputs.size() ? m_vInputs[index] : InputVariable();
200 }
201
202 /************ OUTPUT PARAMETERS ************/
203
204 int GetOutputCount() { return CVT_INT(m_vOutputs.size()); }
205
206 int AddOutput(const char* name, const char* units, const char* desc, dimensionTypes dimType,
207 transferTypes tfType = TF_None);
208
209 string GetOutputName(int index) { return index >= 0 && index < m_vOutputs.size() ? m_vOutputs[index].Name : ""; }
210
211 string GetOutputUnits(int index) {
212 return index >= 0 && index < m_vOutputs.size() ? m_vOutputs[index].Units : "";
213 }
214
215 string GetOutputDescription(int index) {
216 return index >= 0 && index < m_vOutputs.size() ? m_vOutputs[index].Description : "";
217 }
218
219 dimensionTypes GetOutputDimension(int index) {
220 return index >= 0 && index < m_vOutputs.size() ? m_vOutputs[index].Dimension : DT_Unknown;
221 }
222
223 transferTypes GetOutputTfType(int index) {
224 return index >= 0 && index < m_vOutputs.size() ? m_vOutputs[index].tfType : TF_None;
225 }
226
227 OutputVariable GetOutput(int index) {
228 return index >= 0 && index < m_vOutputs.size() ? m_vOutputs[index] : OutputVariable();
229 }
230
231 /************ IN/OUTPUT PARAMETERS ************/
232
233 int GetInOutputCount() { return CVT_INT(m_vInOutputs.size()); }
234
235 int AddInOutput(const char* name, const char* units, const char* desc, dimensionTypes dimType,
236 transferTypes tfType = TF_None);
237
238 string GetInOutputName(int index) {
239 return index >= 0 && index < m_vInOutputs.size() ? m_vInOutputs[index].Name : "";
240 }
241
242 string GetInOutputUnits(int index) {
243 return index >= 0 && index < m_vInOutputs.size() ? m_vInOutputs[index].Units : "";
244 }
245
246 string GetInOutputDescription(int index) {
247 return index >= 0 && index < m_vInOutputs.size() ? m_vInOutputs[index].Description : "";
248 }
249
250 dimensionTypes GetInOutputDimension(int index) {
251 return index >= 0 && index < m_vInOutputs.size() ? m_vInOutputs[index].Dimension : DT_Unknown;
252 }
253
254 transferTypes GetInOutputTfType(int index) {
255 return index >= 0 && index < m_vInOutputs.size() ? m_vInOutputs[index].tfType : TF_None;
256 }
257
258 InOutputVariable GetInOutput(int index) {
259 return index >= 0 && index < m_vInOutputs.size() ? m_vInOutputs[index] : InOutputVariable();
260 }
261
262 /************ PARAMETERS FROM DATABASE ************/
263
264 int GetParameterCount() { return CVT_INT(m_vParameters.size()); }
265
266 int AddParameter(const char* name, const char* units, const char* desc, const char* source, dimensionTypes dimType);
267
268 string GetParameterName(int index) {
269 return index >= 0 && index < m_vParameters.size() ? m_vParameters[index].Name : "";
270 }
271
272 string GetParameterUnits(int index) {
273 return index >= 0 && index < m_vParameters.size() ? m_vParameters[index].Units : "";
274 }
275
276 string GetParameterDescription(int index) {
277 return index >= 0 && index < m_vParameters.size() ? m_vParameters[index].Description : "";
278 }
279
280 string GetParameterSource(int index) {
281 return index >= 0 && index < m_vParameters.size() ? m_vParameters[index].Source : "";
282 }
283
284 dimensionTypes GetParameterDimension(int index) {
285 return index >= 0 && index < m_vParameters.size() ? m_vParameters[index].Dimension : DT_Unknown;
286 }
287
288 Parameter GetParameter(int index) {
289 return index >= 0 && index < m_vParameters.size() ? m_vParameters[index] : Parameter();
290 }
291
292 /************ DEPENDENT MODULES ************/
293
294 int GetDependencyCount() { return CVT_INT(m_vDependencies.size()); }
295
296 int AddDependency(const char* name, const char* description);
297
298 string GetDependencyName(int index) {
299 return index >= 0 && index < m_vDependencies.size() ? m_vDependencies[index].Name : "";
300 }
301
302 string GetDependencyDescription(int index) {
303 return index >= 0 && index < m_vDependencies.size() ? m_vDependencies[index].Description : "";
304 }
305
306 ModelClass GetDependency(int index) {
307 return index >= 0 && index < m_vDependencies.size() ? m_vDependencies[index] : ModelClass();
308 }
309
310 string GetXMLDocument();
311
312 void OpenTag(string name, string attributes, int indent, string* sb);
313
314 void CloseTag(string name, int indent, string* sb);
315
316 void FullTag(const string& name, int indent, string& content, string* sb);
317
318 void WriteClass(int indent, string* sb);
319
320 void WriteInformation(int indent, string* sb);
321
322 void WriteInputs(int indent, string* sb);
323
324 void WriteOutputs(int indent, string* sb);
325
326 void WriteInOutputs(int indent, string* sb);
327
328 void WriteParameters(int indent, string* sb);
329
330 void WriteDependencies(int indent, string* sb);
331
332 void WriteXMLHeader(string* sb);
333
334 void DimensionTag(string tag, int indent, dimensionTypes dimType, string* sb);
335
336 void TransferTypeTag(string tag, int indent, transferTypes tfType, string* sb);
337
338private:
339 string m_strSchemaVersion; ///< latest XML schema version supported by this class
340 ModelClass m_oClass; ///< class name for the module
341 Information m_Info; ///< the general information for the module
342 vector<Parameter> m_vParameters; ///< list of parameters for the module
343 vector<InputVariable> m_vInputs; ///< list of input parameters for the module
344 vector<OutputVariable> m_vOutputs; ///< list of output parameters for the module
345 vector<InOutputVariable> m_vInOutputs; ///< list of In/Output parameters for the module for MPI version
346 vector<ModelClass> m_vDependencies; ///< list of dependency classes for the module
347};
348
349#endif /* SEIMS_METADATA_INFO_H */
Define some const variables used by MetadataInfo class.
@ TF_None
Default, which means no need to be transferred.
Definition: MetadataInfoConst.h:87
@ DT_Unknown
Unknown type.
Definition: MetadataInfoConst.h:64
Basic definitions.
#define CVT_INT(param)
A reference to the postfix of executable file for RELWITHDEBINFO mode.
Definition: basic.h:325
Base type of all interfaces.
Definition: basic.h:407
string EMail
Email.
Definition: MetadataInfo.h:51
string Version
Module Version.
Definition: MetadataInfo.h:49
string Author
Author.
Definition: MetadataInfo.h:50
string Units
Units.
Definition: MetadataInfo.h:67
string Id
Module ID.
Definition: MetadataInfo.h:46
string Description
Description.
Definition: MetadataInfo.h:68
string Helpfile
Helpfile.
Definition: MetadataInfo.h:53
string Source
Source type.
Definition: MetadataInfo.h:82
string Description
Module Description.
Definition: MetadataInfo.h:48
string Name
Module Name.
Definition: MetadataInfo.h:47
string Name
Name.
Definition: MetadataInfo.h:66
dimensionTypes Dimension
Data dimension type.
Definition: MetadataInfo.h:69
string Website
Website.
Definition: MetadataInfo.h:52
Metadata information of module.
Definition: MetadataInfo.h:125
transferTypes
Float values be transferred across subbasins for MPI version.
Definition: MetadataInfoConst.h:86
dimensionTypes
enum of dimension data types
Definition: MetadataInfoConst.h:63
Input and output variable information class.
Definition: MetadataInfo.h:115
Module development information class.
Definition: MetadataInfo.h:41
Input variable information class.
Definition: MetadataInfo.h:91
Module basic description.
Definition: MetadataInfo.h:27
Output variable information class.
Definition: MetadataInfo.h:103
Model parameter information class.
Definition: MetadataInfo.h:78
Basic model parameter information.
Definition: MetadataInfo.h:62
Common Cross-platform Geographic Library (CCGL)