Blame view

src/Parameters/ParameterManager.hh 5.81 KB
fbe3c2bb   Benjamin Renard   First commit
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
/**
 * 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;

5ddc9ffe   Benjamin Renard   NetCDF file reade...
58
59
60
61
62
63
64
      /*
       * @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;

fbe3c2bb   Benjamin Renard   First commit
65
66
67
68
69
70
71
72
      /**
       * @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
       */
854a7fcf   Benjamin Renard   First implementat...
73
      ParameterSPtr  getSampledParameter(const std::string& pIDParam, const std::string &samplingMode = "", float samplingValue = 0.0, float gapThreshold = 0.0, bool isUserProcess = true);
fbe3c2bb   Benjamin Renard   First commit
74
75
76
77

      /**
       * get a resampled parameter under a reference parameter
       */
854a7fcf   Benjamin Renard   First implementat...
78
      ParameterSPtr getSampledParameterUnderRefParam(const std::string& pIDParam, const std::string& pIDRefParam, bool isUserProcess);
fbe3c2bb   Benjamin Renard   First commit
79
80
81
82

      /**
       * get a parameter from an expression
       */
854a7fcf   Benjamin Renard   First implementat...
83
      ParameterSPtr getParameterFromExpression(const std::string& pExpression, double gapThreshold = NAN, bool isUserProcess = true);
fbe3c2bb   Benjamin Renard   First commit
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

      /**
       * 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.
	 */
897858c8   Benjamin Renard   Support multi TT ...
111
	void addInputInterval(double pStartTime, double pStopTime, int pIndex, std::string& pttPath, std::string& pttName, int pttTotalIntervals);
fbe3c2bb   Benjamin Renard   First commit
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

	/**
	 * @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);

fbe3c2bb   Benjamin Renard   First commit
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
	/**
	 * 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);

78249cd2   Benjamin Renard   Fix special chara...
154
155
156
157
	void addParamInParameterList(ParameterSPtr& pParam);

	ParameterSPtr findParamInParameterList(const std::string& paramId);

193183ca   Benjamin Renard   Give the possibil...
158
159
160
161
162
163
164
165
	void addParamTimeRestriction(const std::string& paramId, double restriction) {
		_paramsTimeRestrictions[paramId] = restriction;
	}

	std::map<std::string, double> getParamsTimeRestrictions() {
		return _paramsTimeRestrictions;
	}

fbe3c2bb   Benjamin Renard   First commit
166
167
168
	/**
	 * @return The real parameter if the process is empty.
	 */
91edc9c0   Benjamin Renard   Add process to tr...
169
	ParameterSPtr& checkIfIsANeededParameter(ParameterSPtr& pParamResult);
fbe3c2bb   Benjamin Renard   First commit
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

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;

897858c8   Benjamin Renard   Support multi TT ...
198
	/*
86fbae45   Benjamin Renard   Compute param Id ...
199
200
201
202
203
	 * @brief store paramId correction to compute it only once and improve execution time
	 */
	std::map<std::string,std::string> _paramIdCorrectionMap;

	/*
fbe3c2bb   Benjamin Renard   First commit
204
205
206
	  * @brief default value for the gap threshold of all parameters
	  */
	 double _defaultGapThreshold;
193183ca   Benjamin Renard   Give the possibil...
207
208
209
210
211

	/*
	 * @bried define some parameters time restrictions
	 */
	std::map<std::string, double> _paramsTimeRestrictions;
fbe3c2bb   Benjamin Renard   First commit
212
213
214
215
216
    };

  } /* namespace Parameters */
} /* namespace AMDA */
#endif /* PARAMTERMANAGER_HH_ */