/** * Parameter.hh * * Created on: 16 oct. 2012 * Author: AKKA IS */ #ifndef PARAMETER_HH_ #define PARAMETER_HH_ #include #include #include #include #include #include "DataWriter.hh" #include "ParamDataIndexInfo.hh" #include "TimeStamp.hh" namespace AMDA { namespace Parameters { class Parameter; class ParamOutput; class ParamData; class DataClient; class ParameterManager; class ParamInterval; class CalibrationInfoWriter; typedef boost::shared_ptr ParameterSPtr; typedef boost::shared_ptr ParamOutputSPtr; typedef boost::shared_ptr ParamDataSPtr; typedef boost::shared_ptr DataClientSPtr; typedef boost::shared_ptr DataWriterSPtr; struct SemiVariableTable { std::vector tabHeader; std::map> tabValues; bool calculateBounds = true; }; /** * AMDA::Parameters::Parameter */ class Parameter { public: typedef std::set ParameterList; typedef std::list CalibrationInfoWriterList; typedef std::vector InfoValues; typedef boost::shared_ptr InfoValuesSPtr; typedef std::map InfoList; Parameter(ParameterManager& pParamMng, std::string idParam); virtual ~Parameter(); // Get methods /** * Get ParamData for DataClient */ ParamDataSPtr& getParamData(DataClient*); /** * get sampling value in sec */ double getTimeResolution() { return _timeResolution; } /** * get gap threshold factor */ double getGapThreshold() { return _gapThreshold; } /** * @brief get list of CalibrationInfoWriter */ const CalibrationInfoWriterList& getCalibrationInfoWriterList() const { return _calibrationInfoWriterList; } CalibrationInfoWriterList& getCalibrationInfoWriterList() { return _calibrationInfoWriterList; } /** * Get additional information list. */ const InfoList& getInfoList() const { return _infoList; } InfoList& getInfoList() { return _infoList; } // Set methods /** * Set the DataWriter to fill the ParamData */ void setDataWriter(const DataWriterSPtr& dataWriter) { _dataWriter = dataWriter; } /** * set sampling value in sec */ void setTimeResolution(double pTimeResolution) { _timeResolution = pTimeResolution; } /** * set gap threshold factor */ void setGapThreshold(double pGapThreshold) { _gapThreshold = pGapThreshold; } /** * Add additional Information values. */ void setInfoValues(std::string pInfoName, InfoValuesSPtr& pInfoValues) { _infoList.insert(std::pair(pInfoName, pInfoValues)); } // Others methods void openConnection(DataClient *); void closeConnection(DataClient *); const std::string& getId() const { return _id; } const std::string& getInfoId() const { return _infoId; } void setInfoId(const std::string& infoId) { _infoId = infoId; } /** *@brief get _dataWriter *@details can be a copy after establishConnection phase */ DataWriterSPtr& getDataWriterTemplate() { return _dataWriter; } /** * @brief Place interval on existing or creates * @return the last time of all file object which can modify the type of ParamData of Parameter */ TimeStamp init(DataClient* pDataClient, TimeIntervalListSPtr pTimeIntervalList); /** * @return nbData Available or 0 if no Data * blocking operation */ boost::shared_future getAsync(DataClient * pClient); ParameterManager& getParameterManager() { return _parameterManager; } void addParameter(ParameterSPtr pParentParameter) { _parameterList.insert(pParentParameter); } ParameterList& getParameterList() { return _parameterList; } void delegateOtherTaskTo(ParameterSPtr& pParam); void setIsTableIndexParam(bool isTableIndexParam) { _isTableIndexParam = isTableIndexParam; } bool isTableIndexParam() { return _isTableIndexParam; } protected: typedef std::map DataClientList; typedef std::vector IntervalList; private: /** * Id of parameter (name of xml file) */ std::string _id; /** * info id of parameter */ std::string _infoId; /** * The implementation is responssable to get Data * This acquisition must be make by ParamGet to get data in base * or Process to computed data. */ DataWriterSPtr _dataWriter; /** * an instance of parameter manager */ ParameterManager& _parameterManager; /** * */ ParameterList _parameterList; /** * Stored for each DataClient, information of this DataClient (startTime, IntTime, ...) */ IntervalList _intervalList; /** * DataClient list , this data client used ParamData. For each DataClient, Parameter stored data of this client. * The client subscribe via openConnection. after, it's put information via init method. */ DataClientList _dataClientList /** * when ( _clientInitCall == _dataClientList.size()) _intervalList is activ */; unsigned int _clientInitCall; /** * ask sampling, give by xml parameter file */ double _timeResolution; /** * ask gap threshold, give by xml parameter file */ double _gapThreshold; /** * list of functor to write callibration info */ CalibrationInfoWriterList _calibrationInfoWriterList; /** * List of additional information */ InfoList _infoList; static bool _isTableIndexParam; private: bool establishConnectionToDo; }; } /* namespace Parameters */ } /* namespace AMDA */ #endif /* PARAMETER_HH_ */