ParameterManager.hh
5.81 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
/**
* ParamterManager.hh
*
* Created on: 15 oct. 2012
* Author: AKKA IS
*/
#ifndef PARAMTERMANAGER_HH_
#define PARAMTERMANAGER_HH_
#include <map>
#include <list>
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include "ParamGet.hh"
#include "log4cxx/logger.h"
#include "TimeInterval.hh"
namespace AMDA
{
namespace Parameters
{
class ParameterManager;
typedef boost::shared_ptr<ParameterManager> ParameterManagerSPtr;
class Parameter;
typedef boost::shared_ptr<Parameter> ParameterSPtr;
class ParamOutput;
typedef boost::shared_ptr<ParamOutput> ParamOutputSPtr;
typedef std::list<ParamOutputSPtr> ParamOutputList;
// typedef std::list<TimeTableCatalog::TimeInterval> TimeIntervalList;
// typedef boost::shared_ptr<TimeIntervalList> TimeIntervalListSPtr;
struct ParameterManager_exception: virtual AMDA_exception { };
class ParameterManager
{
public:
typedef std::map<std::string,ParameterSPtr> ParameterList;
ParameterManager();
virtual ~ParameterManager();
/*
* @brief Mutex used to protect multi-thread access to CDF lib (CDF lib is not thread-safe!)
* This mutex is a part of the ParameterManager to be shared between by FileWriterCDF (DownloadOutput plugin)
* and class and FileReaderCDF (ParamGetLocalFile)
*/
static boost::mutex mutexCDFLib;
/*
* @brief Mutex used to protect multi-thread access to netCDF lib (netCDF lib is not thread-safe!)
* This mutex is a part of the ParameterManager to be shared between by FileWriterNetCDF (DownloadOutput plugin)
* and class and FileReaderNetCDF (ParamGetLocalFile)
*/
static boost::mutex mutexNetCDFLib;
/**
* @return no return, do a getParameter
*/
void createParameter( const std::string& pIDParam);
/**
* get the parameter or if sampling information is asked, create the sampling parameter
*/
ParameterSPtr getSampledParameter(const std::string& pIDParam, const std::string &samplingMode = "", float samplingValue = 0.0, float gapThreshold = 0.0, bool isUserProcess = true);
/**
* get a resampled parameter under a reference parameter
*/
ParameterSPtr getSampledParameterUnderRefParam(const std::string& pIDParam, const std::string& pIDRefParam, bool isUserProcess);
/**
* get a parameter from an expression
*/
ParameterSPtr getParameterFromExpression(const std::string& pExpression, double gapThreshold = NAN, bool isUserProcess = true);
/**
* get a parameter identify by parameterName
*/
ParameterSPtr getParameter(const std::string& pIDParam);
// Others methods
/**
* Create a new Parameter.
* @return false if already exist otherwise true.
*/
bool addParameter(Parameter* pParentParameter, const std::string& pIDParam, ParameterSPtr& pParamResult);
ParamOutputList& getParamOutputList() {
return _paramOutputList;
}
void execute(std::string workingPath);
/**
* @brief Retrieve list of time interval
*/
TimeIntervalListSPtr getInputIntervals();
/**
* @brief add time interval to the list.
*/
void addInputInterval(double pStartTime, double pStopTime, int pIndex, std::string& pttPath, std::string& pttName, int pttTotalIntervals);
/**
* @brief add time interval to the list.
*/
void addInputInterval(const TimeTableCatalog::TimeInterval& pTimeInterval);
/*
* @brief add time interval data to the list
*/
void addInputIntervalDataList(const int pIndex, const std::string& pDataKey, const std::vector<std::string>& dataList) ;
/*
* get a time interval data specified by the data key
*/
std::vector<std::string>& getInputIntervalDataList(const int pIndex, const std::string& pDataKey);
/**
* get the computed gap size
*/
double getComputedGapSize(double gapThreshold, double minSampling);
/*
* @brief get the default value of the gap threshold
*/
double getDefaultGapThreshold()
{
return _defaultGapThreshold;
}
/*
* @brief set the default value of the gap threshold
*/
void setDefaultGapThreshold(double defaultGapThreshold)
{
_defaultGapThreshold = defaultGapThreshold;
}
/*
* @brief Apply some correction in a parameter ID
*/
void applyParamIdCorrection(std::string& paramId);
void addParamInParameterList(ParameterSPtr& pParam);
ParameterSPtr findParamInParameterList(const std::string& paramId);
void addParamTimeRestriction(const std::string& paramId, double restriction) {
_paramsTimeRestrictions[paramId] = restriction;
}
std::map<std::string, double> getParamsTimeRestrictions() {
return _paramsTimeRestrictions;
}
/**
* @return The real parameter if the process is empty.
*/
ParameterSPtr& checkIfIsANeededParameter(ParameterSPtr& pParamResult);
private:
/**
* logger
*/
static log4cxx::LoggerPtr _logger;
/**
* Store created parameters
*/
ParameterList _parameterList;
/**
* List of request paramOutput
*/
ParamOutputList _paramOutputList;
/**
* @brief _timeIntervalList List of input interval contained in timetable defined in the XML request file.
*/
TimeIntervalListSPtr _timeIntervalList;
/*
* @brief additional data associated to each time interval of the _timeIntervalList
*/
std::map<int, std::map<std::string, std::vector<std::string>>> _timeIntervalDataList;
/*
* @brief store paramId correction to compute it only once and improve execution time
*/
std::map<std::string,std::string> _paramIdCorrectionMap;
/*
* @brief default value for the gap threshold of all parameters
*/
double _defaultGapThreshold;
/*
* @bried define some parameters time restrictions
*/
std::map<std::string, double> _paramsTimeRestrictions;
};
} /* namespace Parameters */
} /* namespace AMDA */
#endif /* PARAMTERMANAGER_HH_ */