Blame view

src/Info/ParamInfo.hh 10.4 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * ParamInfo.hh
 *
 *  Created on: Oct 6, 2014
 *      Author: m.mazel
 */

#ifndef PARAMINFO_HH_
#define PARAMINFO_HH_

#include <iostream>
#include <sstream>
#include <set>
#include <boost/shared_ptr.hpp>
f6e36c21   Hacene SI HADJ MOHAND   working for one r...
15
#include <algorithm>
65414a1c   Hacene SI HADJ MOHAND   working for mav
16
#include "log4cxx/logger.h"
fbe3c2bb   Benjamin Renard   First commit
17
18
19
20
21
22

#include "InfoLogger.hh"
#include "ParamTable.hh"
#include "StatusInfo.hh"
#include "ParameterIndexesTool.hh"

f6e36c21   Hacene SI HADJ MOHAND   working for one r...
23

fbe3c2bb   Benjamin Renard   First commit
24
25
26
27
28
29
30
31
32
33
34
35
namespace AMDA {
namespace Info {

//Info keys for params
#define PARAMETER_ID           "PARAMETER_ID"
#define PARAMETER_NAME         "PARAMETER_NAME"
#define PARAMETER_SHORT_NAME   "PARAMETER_SHORT_NAME"
#define PARAMETER_COMPONENTS   "PARAMETER_COMPONENTS"
#define PARAMETER_UNITS        "PARAMETER_UNITS"
#define PARAMETER_COORDSYS     "PARAMETER_COORDINATE_SYSTEM"
#define PARAMETER_TENSOR       "PARAMETER_TENSOR_ORDER"
#define PARAMETER_SICONV       "PARAMETER_SI_CONVERSION"
fbe3c2bb   Benjamin Renard   First commit
36
37
38
39
40
41
42
43
#define PARAMETER_FILLVALUE    "PARAMETER_FILL_VALUE"
#define PARAMETER_UCD          "PARAMETER_UCD"
#define PARAMETER_STATUS_NAME  "PARAMETER_STATUS_NAME"
#define PARAMETER_STATUS_MIN   "PARAMETER_STATUS_MIN"
#define PARAMETER_STATUS_MAX   "PARAMETER_STATUS_NAX"
#define PARAMETER_PROCESS_INFO "PARAMETER_PROCESS_INFO"
#define PARAMETER_PROCESS_DESC "PARAMETER_PROCESS_DESC"
#define PARAMETER_LINKED_PARAM "PARAMETER_LINKED_PARAMS"
a133a1e6   Hacene SI HADJ MOHAND   adding other info
44
#define TABLES_DESCRIPTION "TABLES_DESCRIPTION"
10690dc6   Hacene SI HADJ MOHAND   presentation rm_6616
45
#define PARAMETER_INFO "INFO_TABLE"
c7f96386   Hacene SI HADJ MOHAND   6036
46
#define UNSPECIFIED_UNIT "unspecified"
fbe3c2bb   Benjamin Renard   First commit
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

/**
 * @class ParamInfo
 * @brief Information about a parameter.
 * @details
 */
class ParamInfo {
public:
	ParamInfo () :
		_id(""),
		_name(""),
		_short_name(""),
		_components(""),
		_units(""),
		_coordinates_system(""),
		_tensor_order(0),
		_si_conversion(""),
6d3dba6e   Benjamin Renard   Fix bug with fill...
64
		_original_fill_value(NAN),
fbe3c2bb   Benjamin Renard   First commit
65
66
67
68
69
70
		_fill_value(NAN),
		_ucd(""),
		_statusDef(),
		_processInfo(""),
		_processDesc(""),
		_linkedParamList(),
8c8ac7bf   Benjamin Renard   Write mission/ins...
71
72
		_dataset_id(""),
		_instrument_id("")
fbe3c2bb   Benjamin Renard   First commit
73
74
75
76
77
78
	{}

	ParamInfo(const ParamInfo& info) : _id(info._id), _name(info._name),
		_short_name(info._short_name), _components(info._components),
		_units(info._units), _coordinates_system(info._coordinates_system),
		_tensor_order(info._tensor_order), _si_conversion(info._si_conversion),
6d3dba6e   Benjamin Renard   Fix bug with fill...
79
		_tables(info._tables), _original_fill_value(info._original_fill_value), _fill_value(info._fill_value), _ucd(info._ucd), _statusDef(info._statusDef),
fbe3c2bb   Benjamin Renard   First commit
80
		_processInfo(info._processInfo), _processDesc(info._processDesc), _linkedParamList(info._linkedParamList),
8c8ac7bf   Benjamin Renard   Write mission/ins...
81
		_dataset_id(info._dataset_id), _instrument_id(info._instrument_id)
fbe3c2bb   Benjamin Renard   First commit
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
	{}

	friend std::ostream& operator<<(std::ostream& out_, const ParamInfo& dsi);

	/*
	 * @brief Get parameter Id
	 */
	const std::string& getId() const {
		return _id;
	}

	/*
	 * @brief Set parameter Id
	 */
	void setId(const std::string& id) {
		_id = id;
	}

	/*
	 * @brief Get parameter name
	 */
	const std::string& getName() const {
		return _name;
	}

	/*
	 * @brief Set parameter name
	 */
	void setName(const std::string& name) {
		_name = name;
	}

	/*
	 * @brief Get parameter short name
	 */
	const std::string& getShortName() const {
		return _short_name;
	}

	/*
	 * @brief Set parameter short name
	 */
	void setShortName(const std::string& shortName) {
		_short_name = shortName;
	}

	/*
	 * @brief Get parameter components
	 */
	std::string getComponents(AMDA::Common::ParameterIndexComponent componentIndex=AMDA::Common::ParameterIndexComponent(-1,-1)) {
		if ((componentIndex.getDim1Index() == -1) && (componentIndex.getDim2Index() == -1)) {
			return _components;
		}
		else {
			if (_components.empty() == false) {
				// Extract values separated by a comma
				std::stringstream sStream(_components);
				std::vector<std::string> componentList;
				std::string element;

				if (componentIndex.getDim2Index() == -1)
				{
					while (std::getline(sStream, element, ',')) {
						componentList.push_back(element);
					}

					// Return the componenet associated with the index
					if (((int) componentList.size()) > componentIndex.getDim1Index()) {
						return componentList.at (componentIndex.getDim1Index());
					} else {
						return std::string();
					}
				}
				else
				{
					while (std::getline(sStream, element, ';')) {
						componentList.push_back(element);
					}

					if ((componentIndex.getDim1Index() < 0) ||
						(componentIndex.getDim1Index() > (int) componentList.size()))
						return componentList.at (componentIndex.getDim1Index());

					sStream.str(componentList.at(componentIndex.getDim1Index()));
					componentList.clear();

					while (std::getline(sStream, element, ',')) {
						componentList.push_back(element);
					}

					// Return the componenet associated with the index
					if (((int) componentList.size()) > componentIndex.getDim2Index()) {
						return componentList.at (componentIndex.getDim2Index());
					} else {
						return std::string();
					}
				}
			} else {
				return std::string();
			}
		}
	}

	/*
	 * @brief Set parameter components
	 */
	void setComponents(const std::string& components) {
		_components = components;
	}

	/*
	 * @brief Get parameter units
	 */
	const std::string& getUnits() const {
		return _units;
	}

	/*
	 * @brief Set parameter units
	 */
	void setUnits(const std::string& units) {
		_units = units;
	}

	/*
	 * @brief Get parameter cordinate system
	 */
	const std::string& getCoordinatesSystem() const {
		return _coordinates_system;
	}

	/*
	 * @brief Set parameter coordinate system
	 */
	void setCoordinatesSystem(const std::string& coordinatesSystem) {
		_coordinates_system = coordinatesSystem;
	}

	/*
	 * @brief Get parameter tensor order
	 */
	int getTensorOrder() const {
		return _tensor_order;
	}

	/*
	 * @brief Set parameter tensor order
	 */
	void setTensorOrder(int tensorOrder) {
		_tensor_order = tensorOrder;
	}

	/*
	 * @brief Get parameter SI conversion
	 */
	const std::string& getSiConversion() const {
		return _si_conversion;
	}

	/*
	 * @brief Set parameter SI conversion
	 */
	void setSiConversion(const std::string& siConversion) {
		_si_conversion = siConversion;
	}

	/*
	 * @brief Get parameter table from dimension
	 */
	boost::shared_ptr<ParamTable> getTable(int dim) {
		return _tables[dim];
	}

	/*
	 * @brief Add a table to the parameter for a given dimension
	 */
	void addTable(int dim, boost::shared_ptr<ParamTable>& tableSPtr) {
f6e36c21   Hacene SI HADJ MOHAND   working for one r...
259
	                   _tables[dim] = tableSPtr;
fbe3c2bb   Benjamin Renard   First commit
260
261
262
	}

	/*
7f7e3b39   Benjamin Renard   Fix a bug with st...
263
264
265
266
267
268
269
	 * @brief Get all parameter tables
	 */
	std::map<int, boost::shared_ptr<ParamTable>>& getTables() {
		return _tables;
	}

	/*
6d3dba6e   Benjamin Renard   Fix bug with fill...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
	 * @brief Get parameter original fill value (fill value defined in the parameter XML file)
	 */
	double getOriginalFillValue() const {
		return _original_fill_value;
	}

	/*
	 * @brief Set parameter original fill value (fill value defined in the parameter XML file)
	 */
	void setOriginalFillValue(double fillValue) {
		_original_fill_value = fillValue;
	}

	/*
fbe3c2bb   Benjamin Renard   First commit
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
	 * @brief Get parameter fill value
	 */
	double getFillValue() const {
		return _fill_value;
	}

	/*
	 * @brief Set parameter fill value
	 */
	void setFillValue(double fillValue) {
		_fill_value = fillValue;
	}

	/*
	 * @brief Get parameter UCD
	 */
	const std::string& getUcd() const {
		return _ucd;
	}

	/*
	 * @brief Set parameter UCD
	 */
	void setUcd(const std::string& ucd) {
		_ucd = ucd;
	}

	/*
	 * @brief Add parameter status for a given min/max values
	 */
7f62f27f   Benjamin Renard   Add the possibili...
314
	void addStatus(double minVal, double maxVal, std::string name, std::string color = "") {
fbe3c2bb   Benjamin Renard   First commit
315
316
317
		StatusInfo info;
		info.setRange(minVal,maxVal);
		info.setName(name);
7f62f27f   Benjamin Renard   Add the possibili...
318
		info.setColor(color);
fbe3c2bb   Benjamin Renard   First commit
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
		_statusDef.push_back(info);
	}

	/*
	 * @brief Get list of parameter status
	 */
	const std::vector<StatusInfo>& getStatusDef() const {
		return _statusDef;
	}

	/*
	 * @brief Set information about parameter process
	 */
	void setProcessInfo(const std::string& processInfo) {
		_processInfo = processInfo;
	}

	/*
	 * @brief Get information about parameter process
	 */
	const std::string& getProcessInfo() const {
		return _processInfo;
	}

eddfb311   Erdogan Furkan   9326 - Modificita...
343
344
345
346
347
348
349
350
351
352
353
354
355
	void addAdditionalInfo(std::string key, std::string value)
	{
		_additionalInfo[key] = value;
	}

	/*
	 * @brief Get information about parameter process
	 */
	const std::map<std::string, std::string> getAdditionInfo() const
	{
		return _additionalInfo;
	}

fbe3c2bb   Benjamin Renard   First commit
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
	/*
	 * @brief Set a description of the parameter process
	 */
	void setProcessDescription(const std::string& processDesc) {
		_processDesc = processDesc;
	}

	/*
	 * @brief Get the description of the parameter process
	 */
	const std::string& getProcessDescription() const {
		return _processDesc;
	}

	/*
	 * @brief Get a list of linked parameters to this parameter
	 */
1758e0e2   Benjamin Renard   Prevent parameter...
373
	const std::vector<std::string>& getLinkedParamList() const {
fbe3c2bb   Benjamin Renard   First commit
374
375
376
377
378
379
380
381
		return _linkedParamList;
	}

	/*
	 * @brief Add a parameter id to the linked parameter list
	 */
	void addLinkedParamId(const std::string& paramId)
	{
1758e0e2   Benjamin Renard   Prevent parameter...
382
		_linkedParamList.push_back(paramId);
fbe3c2bb   Benjamin Renard   First commit
383
384
	}

23cd82f6   Erdogan Furkan   Almost done
385
386
387
388
389
	void resetLinkedParamList()
	{
		_linkedParamList.clear();
	}

fbe3c2bb   Benjamin Renard   First commit
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
	/*
	 * @brief Get the associated dataset id
	 */
	const std::string& getDatasetId() const {
		return _dataset_id;
	}

	/*
	 * @brief Set the associated dataset id
	 */
	void setDatasetId(const std::string& datasetId) {
		_dataset_id = datasetId;
	}

	/*
8c8ac7bf   Benjamin Renard   Write mission/ins...
405
406
407
408
409
410
411
412
413
414
415
416
417
418
 	 * @brief Get the associated instrument id (for informational purposes, can be used to write in a legend for example)
 	 */
	const std::string& getInstrumentId() const {
		return _instrument_id;
	}

	/*
 	 * @brief Set the associated instrument id (for informational purposes, can be used to write in a legend for example)
 	 */
	void setInstrumentId(const std::string& instrumentId) {
		_instrument_id = instrumentId;
	}

	/*
fbe3c2bb   Benjamin Renard   First commit
419
420
421
	 * @brief Get a map with parameter info
	 */
	std::vector<std::pair<std::string,std::string>> getInfoMap(ParameterManager *parameterManager);
65414a1c   Hacene SI HADJ MOHAND   working for mav
422
423
424
425
        	/*
	 * @brief Get a map with variable table info
	 */
	std::vector<std::pair<std::string,std::string>> getTableInfoMap(ParameterManager *parameterManager);
fbe3c2bb   Benjamin Renard   First commit
426
427
428
429
430
431
432
433
434
435
436

protected:
	std::string _id;
	std::string _name;
	std::string _short_name;
	std::string _components;
	std::string _units;
	std::string _coordinates_system;
	int			_tensor_order;
	std::string _si_conversion;
	std::map<int, boost::shared_ptr<ParamTable>> _tables;
6d3dba6e   Benjamin Renard   Fix bug with fill...
437
	double          _original_fill_value;
fbe3c2bb   Benjamin Renard   First commit
438
439
440
441
442
	double		_fill_value;
	std::string _ucd;
	std::vector<StatusInfo> _statusDef;
	std::string _processInfo;
	std::string _processDesc;
1758e0e2   Benjamin Renard   Prevent parameter...
443
	std::vector<std::string> _linkedParamList;
fbe3c2bb   Benjamin Renard   First commit
444
	std::string _dataset_id;
8c8ac7bf   Benjamin Renard   Write mission/ins...
445
	std::string _instrument_id;
eddfb311   Erdogan Furkan   9326 - Modificita...
446
447
	std::map<std::string, std::string> _additionalInfo;
	static log4cxx::LoggerPtr _logger;
fbe3c2bb   Benjamin Renard   First commit
448
449
450
451
452
453
454
455
456
457
};

typedef boost::shared_ptr<ParamInfo> ParamInfoSPtr;
typedef std::map<std::string,ParamInfoSPtr> ParamInfoMap;

} /* namespace Info */
} /* namespace AMDA */


#endif /* PARAMINFO_HH_ */