Blame view

src/Info/ParamTable.hh 9.52 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);
d924031c   Hacene SI HADJ MOHAND   progress
85
86
            
            bool isInvertedOrder(ParameterManager *parameterManager);
f2db3c16   Benjamin Renard   Support variable ...
87

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

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

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

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

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

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

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

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

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
115
116
117
118
119
120
121
122
        /**
         * @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...
123

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
133
134
135
136
137
138
139
140
        /**
         * @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...
141

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

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
154
155
156
157
158
159
160
161
        /**
         * @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...
162

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
173
174
175
176
177
178
179
180
        /**
         * @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
181

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
            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;
            
f3cd5351   Hacene SI HADJ MOHAND   us ok
208
209
            std::vector<double>  _centersValues;
            
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
210
        private:
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
            
            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...
233
         * @class LinkTable
03aa741e   Hacene SI HADJ MOHAND   adding table but ...
234
235
236
237
238
239
240
241
         * @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...
242

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

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

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

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

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

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

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

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

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

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

03aa741e   Hacene SI HADJ MOHAND   adding table but ...
269
    } /* namespace Info */
fbe3c2bb   Benjamin Renard   First commit
270
271
272
} /* namespace AMDA */

#endif /* PARAMTABLE_HH_ */