Blame view

src/Info/ParamTable.hh 9.42 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"

a133a1e6   Hacene SI HADJ MOHAND   adding other info
15
#define PARAMETER_TABLE        "PARAMETER_TABLE_"
0051287c   Hacene SI HADJ MOHAND   starting us
16
17
18
#define PARAMETER_TABLE_UNITS  "PARAMETER_TABLE_UNITS"
#define PARAMETER_TABLE_MINVAL "PARAMETER_TABLE_MIN_VALUES"
#define PARAMETER_TABLE_MAXVAL "PARAMETER_TABLE_MAX_VALUES"
72d1e9e7   Hacene SI HADJ MOHAND   moitie de l'us
19
#define  VARIABLE_PARAMETER_TABLE  "PARAMETER_TABLE_"
0051287c   Hacene SI HADJ MOHAND   starting us
20

65414a1c   Hacene SI HADJ MOHAND   working for mav
21
22
using namespace log4cxx;

fbe3c2bb   Benjamin Renard   First commit
23
namespace AMDA {
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
24
    namespace Info {
fbe3c2bb   Benjamin Renard   First commit
25

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
26
        using namespace AMDA::Parameters;
fbe3c2bb   Benjamin Renard   First commit
27

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
28
29
30
31
32
33
34
35
        /**
         * @brief Structure that's define a table bound
         */
        typedef struct {
            int index;
            double min;
            double max;
        } t_TableBound;
fbe3c2bb   Benjamin Renard   First commit
36

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
37
38
39
40
41
42
43
44
        /**
         * @class ParamTable
         * @brief Abstract class used to define a Parameter table .
         * @details
         */
        class ParamTable {
        public:
            ParamTable(const char *paramId);
fbe3c2bb   Benjamin Renard   First commit
45

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
46
            virtual ~ParamTable();
fbe3c2bb   Benjamin Renard   First commit
47

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
48
            virtual int getSize(ParameterManager *parameterManager) = 0;
fbe3c2bb   Benjamin Renard   First commit
49

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
50
            virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
3fe8b83d   Benjamin Renard   Get parameter inf...
51

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
52
            virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>*paramsTableData = NULL) = 0;
fbe3c2bb   Benjamin Renard   First commit
53

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
54
            void setParameterLink(ParameterSPtr parameter);
fbe3c2bb   Benjamin Renard   First commit
55

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
56
            std::string getParamId(void);
7f7e3b39   Benjamin Renard   Fix a bug with st...
57

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
58
            void setName(std::string name);
fbe3c2bb   Benjamin Renard   First commit
59

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
60
            virtual std::string getName(ParameterManager *parameterManager);
fbe3c2bb   Benjamin Renard   First commit
61

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
62
            void setUnits(std::string name);
fbe3c2bb   Benjamin Renard   First commit
63

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
64
            virtual std::string getUnits(ParameterManager *parameterManager);
fbe3c2bb   Benjamin Renard   First commit
65

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
66
            void setIsVariable(bool isVariable);
f2db3c16   Benjamin Renard   Support variable ...
67

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
68
            virtual bool isVariable(ParameterManager *parameterManager);
236cd24c   Hacene SI HADJ MOHAND   working in full v...
69

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
70
            void setIsFullVariable(bool isVariable);
f2db3c16   Benjamin Renard   Support variable ...
71

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
72
            virtual bool isFullVariable(ParameterManager *parameterManager);
f2db3c16   Benjamin Renard   Support variable ...
73

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
74
            void addTableParam(std::string key, std::string name);
f2db3c16   Benjamin Renard   Support variable ...
75

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
76
            virtual std::string getTableParamByKey(ParameterManager *parameterManager, std::string key);
f2db3c16   Benjamin Renard   Support variable ...
77

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
78
            virtual std::map<std::string, std::string>& getTableParams(ParameterManager *parameterManager);
fbe3c2bb   Benjamin Renard   First commit
79

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
80
            void addTableInfo(ParameterManager *parameterManager, int dim, std::vector<std::pair<std::string, std::string>>&infoMap);
fbe3c2bb   Benjamin Renard   First commit
81

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
82
            void addSemiVariableTableInfo(ParameterManager *parameterManager, int dim, std::string paramId, std::string key, std::vector<std::pair<std::string, std::string>>&infoMap);
fbe3c2bb   Benjamin Renard   First commit
83

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
84
            void addRelatedParams(ParameterManager *parameterManager, std::string paramId, std::list<std::string>relatedParams);
f2db3c16   Benjamin Renard   Support variable ...
85

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
86
87
88
        protected:
            /** logger of paramTable */
            static log4cxx::LoggerPtr _logger;
f2db3c16   Benjamin Renard   Support variable ...
89

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
90
            std::string _paramId;
f2db3c16   Benjamin Renard   Support variable ...
91

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
92
            std::string _tableName;
f2db3c16   Benjamin Renard   Support variable ...
93

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
94
            std::string _tableUnits;
f2db3c16   Benjamin Renard   Support variable ...
95

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
96
            std::list<std::string> _printedTables;
0051287c   Hacene SI HADJ MOHAND   starting us
97

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
98
            bool _variable;
fbe3c2bb   Benjamin Renard   First commit
99

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
100
            bool _fullVariable = false;
fbe3c2bb   Benjamin Renard   First commit
101

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
102
            std::map<std::string, std::string> _tableParams;
3fe8b83d   Benjamin Renard   Get parameter inf...
103

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
104
            std::vector<double> getTableParamValuesByKey(ParameterManager *parameterManager, std::map<std::string, std::vector<double>>*paramsTableData, std::string key);
fbe3c2bb   Benjamin Renard   First commit
105

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
106
            std::vector<double> getConstantTableParamValuesByKey(ParameterManager *parameterManager, std::string key);
fbe3c2bb   Benjamin Renard   First commit
107

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
108
            std::vector<double> getVariableTableParamValuesByKey(ParameterManager *parameterManager, std::map<std::string, std::vector<double>>*paramsTableData, std::string key);
fbe3c2bb   Benjamin Renard   First commit
109

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
110
111
            virtual void addVariableTableInfo(ParameterManager *parameterManager, int dim, std::vector<std::pair<std::string, std::string>>&infoMap);
        };
fbe3c2bb   Benjamin Renard   First commit
112

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
113
114
115
116
117
118
119
120
        /**
         * @class ParamBoundsTable
         * @brief Implementation of a ParamTable for a table defined by a list
         * @details
         */
        class ParamBoundsTable : public ParamTable {
        public:
            ParamBoundsTable(const char *paramId);
3fe8b83d   Benjamin Renard   Get parameter inf...
121

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
122
            virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
fbe3c2bb   Benjamin Renard   First commit
123

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
124
            virtual int getSize(ParameterManager *parameterManager);
f2db3c16   Benjamin Renard   Support variable ...
125

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
126
            virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>*paramsTableData = NULL);
fbe3c2bb   Benjamin Renard   First commit
127

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
128
129
            static std::string _boundsParamKey;
        };
fbe3c2bb   Benjamin Renard   First commit
130

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
131
132
133
134
135
136
137
138
        /**
         * @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:
            ParamCenterTable(const char *paramId, double size);
f5c53312   Benjamin Renard   Get calib info in...
139

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
140
            virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
3fe8b83d   Benjamin Renard   Get parameter inf...
141

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
142
            virtual int getSize(ParameterManager *parameterManager);
f5c53312   Benjamin Renard   Get calib info in...
143

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
144
            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...
145

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
146
            static std::string _centersParamKey;
f5c53312   Benjamin Renard   Get calib info in...
147

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
148
149
150
        private:
            double _size;
        };
65c661e8   Benjamin Renard   Table definition ...
151

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
152
153
154
155
156
157
158
159
        /**
         * @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:
            ParamCenterWidthTable(const char *paramId);
3fe8b83d   Benjamin Renard   Get parameter inf...
160

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
161
            virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
65c661e8   Benjamin Renard   Table definition ...
162

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
163
            virtual int getSize(ParameterManager *parameterManager);
65c661e8   Benjamin Renard   Table definition ...
164

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
165
            virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>*paramsTableData = NULL);
65c661e8   Benjamin Renard   Table definition ...
166

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
167
168
169
            static std::string _centersParamKey;
            static std::string _widthsParamKey;
        };
fbe3c2bb   Benjamin Renard   First commit
170

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
171
172
173
174
175
176
177
178
        /**
         * @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:
            ParamCenterAutoTable(const char *paramId, bool log);
fbe3c2bb   Benjamin Renard   First commit
179

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
180
            virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
fbe3c2bb   Benjamin Renard   First commit
181

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
182
            virtual int getSize(ParameterManager *parameterManager);
e7ea756d   Benjamin Renard   Implements tables...
183

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
184
            virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>*paramsTableData = NULL);
e7ea756d   Benjamin Renard   Implements tables...
185

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
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
            static std::string _centersParamKey;

        private:
            bool _log;
        };

        class EmbeddedCenterTable : public ParamTable {
        public:
            
            
            EmbeddedCenterTable(const char *paramId,  std::vector<double> & centersValues, bool logMode = false);
            
            virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);

            virtual int getSize(ParameterManager *parameterManager);

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

            static std::string _paramKey;
            
        private:
            std::vector<double> & _centersValues;
            
            bool _log;
        };

        /**
         * @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:
            ParamMinMaxTable(const char *paramId);

            virtual int getSize(ParameterManager *parameterManager);

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

            static std::string _minParamKey;
            static std::string _maxParamKey;
        };

        /*
e7ea756d   Benjamin Renard   Implements tables...
230
         * @class LinkTable
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
231
232
233
234
235
236
237
238
         * @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);
e7ea756d   Benjamin Renard   Implements tables...
239

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
240
            virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map<std::string, std::vector<double>>*paramsTableData = NULL);
e7ea756d   Benjamin Renard   Implements tables...
241

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
242
243
244
            void setOriginTableDim(int originTableDim) {
                _originTableDim = originTableDim;
            }
e7ea756d   Benjamin Renard   Implements tables...
245

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
246
            virtual std::string getTableParamKeyForInfo(ParameterManager *parameterManager);
e7ea756d   Benjamin Renard   Implements tables...
247

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
248
            virtual std::string getName(ParameterManager *parameterManager);
e7ea756d   Benjamin Renard   Implements tables...
249

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
250
            virtual std::string getUnits(ParameterManager *parameterManager);
e7ea756d   Benjamin Renard   Implements tables...
251

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
252
            virtual bool isVariable(ParameterManager *parameterManager);
e7ea756d   Benjamin Renard   Implements tables...
253

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
254
            virtual bool isFullVariable(ParameterManager *parameterManager);
e7ea756d   Benjamin Renard   Implements tables...
255

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
256
            virtual std::map<std::string, std::string>& getTableParams(ParameterManager *parameterManager);
e7ea756d   Benjamin Renard   Implements tables...
257

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
258
259
260
261
        private:
            std::string _originParamId;
            int _originTableDim;
            std::map<std::string, std::string> _emptyTableParam;
e7ea756d   Benjamin Renard   Implements tables...
262

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
263
264
            ParamTable* getOriginParamTable(ParameterManager *parameterManager);
        };
e7ea756d   Benjamin Renard   Implements tables...
265

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
266
    } /* namespace Info */
fbe3c2bb   Benjamin Renard   First commit
267
268
269
} /* namespace AMDA */

#endif /* PARAMTABLE_HH_ */