ParamOutputDataMining.hh
7.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/*
* ParamOutputDataMining.hh
*
* Created on: 23 août 2013
* Author: CS
*/
#ifndef PARAMOUTPUTDATAMINING_HH_
#define PARAMOUTPUTDATAMINING_HH_
#include <vector>
#include <string>
#include <list>
// Parameters
#include "ParamOutput.hh"
#include "VisitorOfParamData.hh"
// DataMining
#include "ParamNode.hh"
#include "DataMiningValidInterval.hh"
#include "DataMiningInvalidInterval.hh"
// TimeTable
#include "TimeTable.hh"
using namespace AMDA::Parameters;
using namespace TimeTableCatalog;
namespace AMDA {
namespace Parameters {
class ParameterManager;
} // namespace Parameters
namespace ParamOutputImpl {
/**
* @brief Implement ParamOutput to store logical state of an equation in file.
*/
namespace DataMining {
typedef std::list<DataMiningValidInterval> DataMiningValidIntervalList;
typedef std::list<DataMiningInvalidInterval> DataMiningInvalidIntervalList;
/**
* AMDA::ParamOutputImpl::DataMining::ParamOutputDataMining
*/
class ParamOutputDataMining: public AMDA::Parameters::ParamOutput, public VisitorOfParamData {
// Declare mapping between output request parameter and timetable parameter class
static const std::map<std::string, TimeTable::TIME_FORMAT> TIME_FORMAT_MAP;
static const std::map<std::string, std::string> FILE_FORMAT_MAP;
/**
* @brief Check if the output treatment must be aborted.
* The treatment is aborted only if an other output of the same type than this
* work on the same param name and has an higher priority.
*/
bool cancelIntervalCreation();
/**
* @note Create instance of DataMiningType
*/
void createDataMiningWriter();
/**
* @note Process data where time interval list is valid (greater or equal than sampling time).
*/
void processValidInterval();
/**
* @note Process data where time interval list is invalid (less than sampling time).
*/
void processInvalidInterval();
public:
enum PRIORITY {
PARAM,
REQUEST,
HIGHER_PRIORITY_VALUE // this must never be used; it's used in "apply" method
};
/**
* Exception specific for AMDA::XMLConfigurator module
*/
struct exception: virtual AMDA::AMDA_exception { };
ParamOutputDataMining(AMDA::Parameters::ParameterManager& pParameterManager);
virtual ~ParamOutputDataMining();
// Getter methods
const std::string& getFileFormat() { return _fileFormat; }
TimeTable::TIME_FORMAT getTimeFormat()const { return _timeFormat; }
const std::string& getOutputStructure() { return _outputStructure; }
const std::string& getParamName() const { return _paramName; }
PRIORITY getOutputPriority() { return _taskPriority; }
float getSamplingValue() const { return _samplingValue; }
const std::string getSamplingMode() const { return _samplingMode; }
const std::string getFileName() const { return _fileName; }
float getGapThreshold() const { return _gapThreshold; }
std::string getExpression() const { return _expression; }
ParameterSPtr getParameter() { return _parameter; }
// Setter methods
void setFileFormat(const std::string& pFileFormat);
void setTimeFormat(TimeTable::TIME_FORMAT pTimeFormat) { _timeFormat = pTimeFormat; }
void setTimeFormat(std::string pTimeFormat);
void setOutputStructure(const std::string& pOutputStructure) { _outputStructure = pOutputStructure; }
void setParamName(const std::string& pParamName) { _paramName = pParamName; }
void setOutputPriority(PRIORITY pTaskPriority) { _taskPriority = pTaskPriority; }
void setFileName(const std::string &pFileName) { _fileName = pFileName; }
void setParameter(ParameterSPtr pParameter) { _parameter = pParameter; }
// Others methods
void establishConnection();
// Visit methods
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataScalaireShort *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataScalaireFloat *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataScalaireDouble *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataScalaireLongDouble *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataScalaireInt *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataLogicalData *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataTab1DShort *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataTab1DFloat *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataTab1DDouble *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataTab1DLongDouble *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataTab1DInt *);
/**
* @overload VisitorOfParamData::visit()
*/
void visit(AMDA::Parameters::ParamDataTab1DLogicalData *);
/**
* @overload VisitorOfParamData::visit(ParamDataTab2DShort *)
*/
void visit(AMDA::Parameters::ParamDataTab2DShort *);
/**
* @overload VisitorOfParamData::visit(ParamDataTab2DFloat *)
*/
void visit(AMDA::Parameters::ParamDataTab2DFloat *);
/**
* @overload VisitorOfParamData::visit(ParamDataTab2DDouble *)
*/
void visit(AMDA::Parameters::ParamDataTab2DDouble *);
/**
* @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *)
*/
void visit(AMDA::Parameters::ParamDataTab2DLongDouble *);
/**
* @overload VisitorOfParamData::visit(ParamDataTab2DInt *)
*/
void visit(AMDA::Parameters::ParamDataTab2DInt *);
/**
* @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *)
*/
void visit(AMDA::Parameters::ParamDataTab2DLogicalData *);
protected:
/**
* @overload ParamOutput::init()
*/
virtual void init();
/**
* @brief Write time table content in a file.
* @note this step is required and must be called by the main thread (and not child thread) /
* because of the behavior when cleaning several time parser in libxml2 (when cleaning parser,/
* a call to method that need to write in a file will cause segmentation fault;/
* this context is only valid in a child thread).
*/
void terminate();
/**
* @overload ParamOutput::apply()
*/
virtual void apply();
ParameterSPtr _parameter;
/**
* @brief _fileFormat format of the Time Table file. Can be ASCII or Internal XML.
*/
std::string _fileFormat;
/**
* @brief _timeFormat is the format used to format time in TimeTable
*/
TimeTable::TIME_FORMAT _timeFormat;
/**
* @brief _outputStructure describe structure of a file. One file for each interval or one file per interval
*/
std::string _outputStructure;
/**
* @brief _fileName is the name of the output TimeTable file
*/
std::string _fileName;
/**
* @brief Id of the parameter
*/
std::string _paramName;
// OutputFormatTime _typeFormatTime;
/**
* @brief Expression
*/
std::string _expression;
bool _firstVisit;
PRIORITY _taskPriority;
DataMiningValidIntervalList _dataMiningValidIntervalList;
DataMiningInvalidIntervalList _dataMiningInvalidIntervalList;
//DataMiningValidIntervalList _dataMiningValidIntervalList;
};
} // namespace DataMining
} // namespace ParamOutputImpl
} /* namespace AMDA */
#endif /* PARAMOUTPUTDATAMINING_HH_ */