/** * DataWriter.hh * * Created on: Nov 14, 2012 * Author: AKKA IS */ #ifndef DATAWRITER_HH_ #define DATAWRITER_HH_ #include #include #include #include #include "TimeInterval.hh" namespace AMDA { namespace Parameters { //use class class Parameter; class ParamData; typedef boost::shared_ptr ParamDataSPtr; class ParameterManager; class DataWriter; typedef boost::shared_ptr DataWriterSPtr; typedef std::list TimeIntervalList; typedef boost::shared_ptr TimeIntervalListSPtr; class TimeStamp ; class DataWriter { public: /** * @brief default constructor */ DataWriter(Parameter ¶meter); /** * @brief constructor by copy */ DataWriter(const DataWriter &pDataWriter, Parameter ¶meter); /** * @brief destructor */ virtual ~DataWriter(); /** * @brief _paramData getter */ ParamDataSPtr& getParamData() { return _paramData; } /** * @brief parameterManager of _parameter getter */ ParameterManager &getParameterManager(); /** *@brief #_parameter getter */ Parameter *getParameter() { return &_parameter; } /** * @brief _paramData setter */ void setParamData(const ParamDataSPtr& paramData) { _paramData = paramData; } /** * @brief set _signatureTrigger * @details this string which permit to compute TimeStamp @see init() * Classically, is the parameter.xml file name. */ void setSignatureTrigger(const std::string& pSignatureTrigger) { _signatureTrigger = pSignatureTrigger; } // Others Methods /** * @brief initialization of get method * @details Initialize time data and call DataWriter::init() */ TimeStamp init(TimeIntervalListSPtr pTimeIntervalList); /** * @brief Write data in dataParam and return the number of data writed. */ virtual unsigned int write() = 0; /** * @brief Switch the current time interval and reset data. */ // virtual void switchTimeInterval() = 0; /** * @brief Write data in dataParam. */ virtual DataWriter *clone(Parameter ¶meter) const = 0; /** * @brief Write data in dataParam. */ virtual double getMinSampling() = 0; /** * @brief Get the resampling strategy. If it's true, the nearest value will be used during a resampling */ virtual bool useNearestValue() = 0; /** * @brief update parameter info */ virtual void updateInfo(Parameter & parameter); void setTimeRestriction(double restriction) { _timeRestriction = restriction; } double getTimeRestriction() { return _timeRestriction; } void applyTimeRestriction(unsigned int startIndex, unsigned int nbDataToProcess); protected: Parameter& _parameter; /** * @brief initialization of get method * create real ParamData */ virtual TimeStamp init() = 0; TimeIntervalListSPtr _timeIntervalList; /** * @brief ParamData output */ ParamDataSPtr _paramData; /** * @brief string which permit to compute TimeStamp @see init() */ std::string _signatureTrigger; static log4cxx::LoggerPtr _logger; double _timeRestriction; }; /** * This CRTP class implements clone() for Derived */ template class DataWriter_CRTP : public DataWriter { public: /** * @brief Default constructor */ DataWriter_CRTP(Parameter ¶meter) : DataWriter(parameter) {} /** * @brief Constructor by copy */ DataWriter_CRTP(const DataWriter &pDataWriter, Parameter ¶meter) : DataWriter(pDataWriter,parameter) {} /** * @overload Process::clone */ virtual DataWriter *clone(Parameter ¶meter) const { return new Derived(static_cast(*this),parameter); } }; } /* namespace Parameters */ } /* namespace AMDA */ #endif /* DATAWRITER_HH_ */