Blame view

src/Info/ParamTable.hh 7.1 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * ParamTable.hh
 *
 *  Created on: 10 oct. 2014
 *  Author: AKKA
 */

#ifndef PARAMTABLE_HH_
#define PARAMTABLE_HH_

#include "ParameterManager.hh"

#include "log4cxx/logger.h"

0051287c   Hacene SI HADJ MOHAND   starting us
15
16
17
18
19
#define PARAMETER_TABLE        "PARAMETER_TABLE"
#define PARAMETER_TABLE_UNITS  "PARAMETER_TABLE_UNITS"
#define PARAMETER_TABLE_MINVAL "PARAMETER_TABLE_MIN_VALUES"
#define PARAMETER_TABLE_MAXVAL "PARAMETER_TABLE_MAX_VALUES"

fbe3c2bb   Benjamin Renard   First commit
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace AMDA {
namespace Info {

	using namespace AMDA::Parameters;

	/**
	 * @brief Structure that's define a table bound
	 */
	typedef struct {
		int index;
		double min;
		double max;
	} t_TableBound;

	/**
	 * @class ParamTable
	 * @brief Abstract class used to define a Parameter table .
	 * @details
	 */
	class ParamTable
	{
	public:
		ParamTable(const char *paramId);

		virtual ~ParamTable();

		virtual int getSize(ParameterManager *parameterManager) = 0;

e7ea756d   Benjamin Renard   Implements tables...
48
		virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
3fe8b83d   Benjamin Renard   Get parameter inf...
49

f2db3c16   Benjamin Renard   Support variable ...
50
		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL) = 0;
fbe3c2bb   Benjamin Renard   First commit
51
52
53

		void setParameterLink(ParameterSPtr parameter);

7f7e3b39   Benjamin Renard   Fix a bug with st...
54
55
		std::string getParamId(void);

fbe3c2bb   Benjamin Renard   First commit
56
57
		void setName(std::string name);

e7ea756d   Benjamin Renard   Implements tables...
58
		virtual std::string getName(ParameterManager *parameterManager);
fbe3c2bb   Benjamin Renard   First commit
59
60
61

		void setUnits(std::string name);

e7ea756d   Benjamin Renard   Implements tables...
62
		virtual std::string getUnits(ParameterManager *parameterManager);
fbe3c2bb   Benjamin Renard   First commit
63

f2db3c16   Benjamin Renard   Support variable ...
64
65
		void setIsVariable(bool isVariable);

e7ea756d   Benjamin Renard   Implements tables...
66
		virtual bool isVariable(ParameterManager *parameterManager);
f2db3c16   Benjamin Renard   Support variable ...
67
68
69

		void addTableParam(std::string key, std::string name);

e7ea756d   Benjamin Renard   Implements tables...
70
		virtual std::string getTableParamByKey(ParameterManager *parameterManager, std::string key);
f2db3c16   Benjamin Renard   Support variable ...
71

e7ea756d   Benjamin Renard   Implements tables...
72
		virtual std::map<std::string, std::string>& getTableParams(ParameterManager *parameterManager);
0051287c   Hacene SI HADJ MOHAND   starting us
73
                
f6e36c21   Hacene SI HADJ MOHAND   working for one r...
74
75
                                        virtual std::map<std::string, std::string>& getTableParameters();
                
0051287c   Hacene SI HADJ MOHAND   starting us
76
                                        void addTableInfo(ParameterManager *parameterManager, int dim, std::vector<std::pair<std::string,std::string>>& infoMap);
f2db3c16   Benjamin Renard   Support variable ...
77

fbe3c2bb   Benjamin Renard   First commit
78
79
80
81
82
83
84
85
86
	protected:
		/** logger of paramTable */
		static log4cxx::LoggerPtr _logger;

		std::string _paramId;

		std::string _tableName;

		std::string _tableUnits;
f2db3c16   Benjamin Renard   Support variable ...
87
88
89
90
91
92
93
94
95

		bool _variable;

		std::map<std::string, std::string> _tableParams;

		std::vector<double> getTableParamValuesByKey(ParameterManager *parameterManager, std::map<std::string, std::vector<double>>* paramsTableData, std::string key);

		std::vector<double> getConstantTableParamValuesByKey(ParameterManager *parameterManager, std::string key);

e7ea756d   Benjamin Renard   Implements tables...
96
		std::vector<double> getVariableTableParamValuesByKey(ParameterManager *parameterManager, std::map<std::string, std::vector<double>>* paramsTableData, std::string key);
0051287c   Hacene SI HADJ MOHAND   starting us
97
98

                                        virtual void addVariableTableInfo(ParameterManager *parameterManager, int dim, std::vector<std::pair<std::string,std::string>>& infoMap);
fbe3c2bb   Benjamin Renard   First commit
99
100
101
102
103
104
105
106
107
	};

	/**
	 * @class ParamBoundsTable
	 * @brief Implementation of a ParamTable for a table defined by a list
	 * @details
	 */
	class ParamBoundsTable : public ParamTable {
	public:
f2db3c16   Benjamin Renard   Support variable ...
108
		ParamBoundsTable(const char *paramId);
fbe3c2bb   Benjamin Renard   First commit
109

e7ea756d   Benjamin Renard   Implements tables...
110
		virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
3fe8b83d   Benjamin Renard   Get parameter inf...
111

fbe3c2bb   Benjamin Renard   First commit
112
113
		virtual int getSize(ParameterManager *parameterManager);

f2db3c16   Benjamin Renard   Support variable ...
114
		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);
fbe3c2bb   Benjamin Renard   First commit
115

f2db3c16   Benjamin Renard   Support variable ...
116
		static std::string _boundsParamKey;
fbe3c2bb   Benjamin Renard   First commit
117
118
119
120
121
122
123
124
125
	};

	/**
	 * @class ParamCenterTable
	 * @brief Implementation of a ParamTable for a table defined by a list of center value and a size
	 * @details
	 */
	class ParamCenterTable : public ParamTable {
	public:
f2db3c16   Benjamin Renard   Support variable ...
126
		ParamCenterTable(const char *paramId, double size);
fbe3c2bb   Benjamin Renard   First commit
127

e7ea756d   Benjamin Renard   Implements tables...
128
		virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
3fe8b83d   Benjamin Renard   Get parameter inf...
129

fbe3c2bb   Benjamin Renard   First commit
130
131
		virtual int getSize(ParameterManager *parameterManager);

f2db3c16   Benjamin Renard   Support variable ...
132
133
134
		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);

		static std::string _centersParamKey;
fbe3c2bb   Benjamin Renard   First commit
135
136

	private:
fbe3c2bb   Benjamin Renard   First commit
137
138
139
140
		double _size;
	};

	/**
f5c53312   Benjamin Renard   Get calib info in...
141
142
143
144
145
146
	 * @class ParamCenterWidthTable
	 * @brief Implementation of a ParamTable for a table defined by a list of center value and a list of band width
	 * @details
	 */
	class ParamCenterWidthTable : public ParamTable {
	public:
f2db3c16   Benjamin Renard   Support variable ...
147
		ParamCenterWidthTable(const char *paramId);
f5c53312   Benjamin Renard   Get calib info in...
148

e7ea756d   Benjamin Renard   Implements tables...
149
		virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
3fe8b83d   Benjamin Renard   Get parameter inf...
150

f5c53312   Benjamin Renard   Get calib info in...
151
152
		virtual int getSize(ParameterManager *parameterManager);

f2db3c16   Benjamin Renard   Support variable ...
153
		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);
f5c53312   Benjamin Renard   Get calib info in...
154

f2db3c16   Benjamin Renard   Support variable ...
155
156
		static std::string _centersParamKey;
		static std::string _widthsParamKey;
f5c53312   Benjamin Renard   Get calib info in...
157
158
159
	};

	/**
65c661e8   Benjamin Renard   Table definition ...
160
161
162
163
164
165
	 * @class ParamCenterAutoTable
	 * @brief Implementation of a ParamTable for a table defined by a list of center value. Bounds automatically computed to be at the center of two consecutive channels
	 * @details
	 */
	class ParamCenterAutoTable : public ParamTable {
	public:
f2db3c16   Benjamin Renard   Support variable ...
166
		ParamCenterAutoTable(const char *paramId, bool log);
65c661e8   Benjamin Renard   Table definition ...
167

e7ea756d   Benjamin Renard   Implements tables...
168
		virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
3fe8b83d   Benjamin Renard   Get parameter inf...
169

65c661e8   Benjamin Renard   Table definition ...
170
171
		virtual int getSize(ParameterManager *parameterManager);

f2db3c16   Benjamin Renard   Support variable ...
172
173
174
		virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);

		static std::string _centersParamKey;
65c661e8   Benjamin Renard   Table definition ...
175
176

	private:
65c661e8   Benjamin Renard   Table definition ...
177
178
179
180
		bool _log;
	};

	/**
fbe3c2bb   Benjamin Renard   First commit
181
182
183
184
185
186
	 * @class ParamMinMaxTable
	 * @brief Implementation of a ParamTable for a table defined by two list: one for min and one for max
	 * @details
	 */
	class ParamMinMaxTable : public ParamTable {
		public:
f2db3c16   Benjamin Renard   Support variable ...
187
			ParamMinMaxTable(const char *paramId);
fbe3c2bb   Benjamin Renard   First commit
188
189
190

			virtual int getSize(ParameterManager *parameterManager);

f2db3c16   Benjamin Renard   Support variable ...
191
			virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);
fbe3c2bb   Benjamin Renard   First commit
192

f2db3c16   Benjamin Renard   Support variable ...
193
194
			static std::string _minParamKey;
			static std::string _maxParamKey;
fbe3c2bb   Benjamin Renard   First commit
195
	};
e7ea756d   Benjamin Renard   Implements tables...
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


	/*
         * @class LinkTable
	 * @brief Implementation of a ParamTable that is a link to an existing ParamTable
	 * @details
	 */
	class LinkTable : public ParamTable {
		public:
			LinkTable(const char *paramId, const char* originParamId);

			virtual int getSize(ParameterManager *parameterManager);

			virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>* paramsTableData = NULL);

			void setOriginTableDim(int originTableDim) {
				_originTableDim = originTableDim;
			}

			virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);

			virtual std::string getName(ParameterManager *parameterManager);

			virtual std::string getUnits(ParameterManager *parameterManager);

			virtual bool isVariable(ParameterManager *parameterManager);

			virtual std::map<std::string, std::string>& getTableParams(ParameterManager *parameterManager);

		private:
			std::string _originParamId;
			int _originTableDim;
			std::map<std::string, std::string> _emptyTableParam;

			ParamTable* getOriginParamTable(ParameterManager *parameterManager);
	};

fbe3c2bb   Benjamin Renard   First commit
233
234
235
236
} /* namespace Info */
} /* namespace AMDA */

#endif /* PARAMTABLE_HH_ */