Blame view

src/Info/ParamTable.hh 9.75 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
        /**
         * @brief Structure that's define a table bound
         */
        typedef struct {
            int index;
            double min;
            double max;
c2e1eb0f   Erdogan Furkan   More compliant now
35
            double center;
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
36
        } t_TableBound;
fbe3c2bb   Benjamin Renard   First commit
37

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

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

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

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

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

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

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

91edc9c0   Benjamin Renard   Add process to tr...
59
60
            int getDim(void);

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

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

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

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

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

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

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

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

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

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
87
            void addRelatedParams(ParameterManager *parameterManager, std::string paramId, std::list<std::string>relatedParams);
d924031c   Hacene SI HADJ MOHAND   progress
88
89
            
            bool isInvertedOrder(ParameterManager *parameterManager);
f2db3c16   Benjamin Renard   Support variable ...
90

91edc9c0   Benjamin Renard   Add process to tr...
91
92
            ParameterSPtr createRelatedParameter(ParameterManager *parameterManager);

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
93
94
95
        protected:
            /** logger of paramTable */
            static log4cxx::LoggerPtr _logger;
f2db3c16   Benjamin Renard   Support variable ...
96

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

91edc9c0   Benjamin Renard   Add process to tr...
99
100
            int _dim;

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

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

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

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

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

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

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
122
123
124
125
126
127
128
        /**
         * @class ParamBoundsTable
         * @brief Implementation of a ParamTable for a table defined by a list
         * @details
         */
        class ParamBoundsTable : public ParamTable {
        public:
91edc9c0   Benjamin Renard   Add process to tr...
129
            ParamBoundsTable(const char *paramId, int dim);
3fe8b83d   Benjamin Renard   Get parameter inf...
130

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
137
138
            static std::string _boundsParamKey;
        };
fbe3c2bb   Benjamin Renard   First commit
139

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
140
141
142
143
144
145
146
        /**
         * @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:
91edc9c0   Benjamin Renard   Add process to tr...
147
            ParamCenterTable(const char *paramId, int dim, double size);
f5c53312   Benjamin Renard   Get calib info in...
148

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
157
158
159
        private:
            double _size;
        };
65c661e8   Benjamin Renard   Table definition ...
160

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
161
162
163
164
165
166
167
        /**
         * @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:
91edc9c0   Benjamin Renard   Add process to tr...
168
            ParamCenterWidthTable(const char *paramId, int dim);
3fe8b83d   Benjamin Renard   Get parameter inf...
169

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
176
177
178
            static std::string _centersParamKey;
            static std::string _widthsParamKey;
        };
fbe3c2bb   Benjamin Renard   First commit
179

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
180
181
182
183
184
185
186
        /**
         * @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:
91edc9c0   Benjamin Renard   Add process to tr...
187
            ParamCenterAutoTable(const char *paramId, int dim, bool log);
fbe3c2bb   Benjamin Renard   First commit
188

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
195
196
197
198
199
200
201
202
203
204
            static std::string _centersParamKey;

        private:
            bool _log;
        };

        class EmbeddedCenterTable : public ParamTable {
        public:
            
            
91edc9c0   Benjamin Renard   Add process to tr...
205
            EmbeddedCenterTable(const char *paramId, int dim,  std::vector<double> & centersValues, bool logMode = false);
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
206
207
208
209
210
211
212
213
214
            
            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;
            
f3cd5351   Hacene SI HADJ MOHAND   us ok
215
216
            std::vector<double>  _centersValues;
            
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
217
        private:
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
218
219
220
221
222
223
224
225
226
227
228
            
            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:
91edc9c0   Benjamin Renard   Add process to tr...
229
            ParamMinMaxTable(const char *paramId, int dim);
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
230
231
232
233
234
235
236
237
238
239

            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...
240
         * @class LinkTable
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
241
242
243
244
245
         * @brief Implementation of a ParamTable that is a link to an existing ParamTable
         * @details
         */
        class LinkTable : public ParamTable {
        public:
91edc9c0   Benjamin Renard   Add process to tr...
246
            LinkTable(const char *paramId, int dim, const char* originParamId);
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
247
248

            virtual int getSize(ParameterManager *parameterManager);
e7ea756d   Benjamin Renard   Implements tables...
249

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
252
253
254
            void setOriginTableDim(int originTableDim) {
                _originTableDim = originTableDim;
            }
e7ea756d   Benjamin Renard   Implements tables...
255

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

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

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
268
269
270
271
        private:
            std::string _originParamId;
            int _originTableDim;
            std::map<std::string, std::string> _emptyTableParam;
e7ea756d   Benjamin Renard   Implements tables...
272

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
276
    } /* namespace Info */
fbe3c2bb   Benjamin Renard   First commit
277
278
279
} /* namespace AMDA */

#endif /* PARAMTABLE_HH_ */