/** * ParamterManager.hh * * Created on: 15 oct. 2012 * Author: AKKA IS */ #ifndef PARAMTERMANAGER_HH_ #define PARAMTERMANAGER_HH_ #include #include #include #include #include #include "ParamGet.hh" #include "log4cxx/logger.h" #include "TimeInterval.hh" namespace AMDA { namespace Parameters { class ParameterManager; typedef boost::shared_ptr ParameterManagerSPtr; class Parameter; typedef boost::shared_ptr ParameterSPtr; class ParamOutput; typedef boost::shared_ptr ParamOutputSPtr; typedef std::list ParamOutputList; // typedef std::list TimeIntervalList; // typedef boost::shared_ptr TimeIntervalListSPtr; struct ParameterManager_exception: virtual AMDA_exception { }; class ParameterManager { public: typedef std::map 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& dataList) ; /* * get a time interval data specified by the data key */ std::vector& 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 getParamsTimeRestrictions() { return _paramsTimeRestrictions; } protected: /** * @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>> _timeIntervalDataList; /* * @brief store paramId correction to compute it only once and improve execution time */ std::map _paramIdCorrectionMap; /* * @brief default value for the gap threshold of all parameters */ double _defaultGapThreshold; /* * @bried define some parameters time restrictions */ std::map _paramsTimeRestrictions; }; } /* namespace Parameters */ } /* namespace AMDA */ #endif /* PARAMTERMANAGER_HH_ */