/** * Resampling.hh * * Created on: 31 oct. 2012 * Author: AKKA IS */ #ifndef Resampling_HH_ #define Resampling_HH_ #include #include "ParamData.hh" #include "DataTypeMath.hh" #include "VisitorOfParamData.hh" #include "Operation.hh" #include "TimeInterval.hh" namespace AMDA { namespace Parameters { namespace Resampling { /** * Define type Resampling. */ class ResamplingAbstract: public Operation { public: /** * @brief constructor */ ResamplingAbstract(Process& pProcess, double pStartTime, double pTimeInt, bool pUseNearestValue) : Operation(pProcess), _startTime(pStartTime), _timeInt(pTimeInt), _isNewInt(true), _useNearestValue(pUseNearestValue) { } /** * @brief destructor. */ virtual ~ResamplingAbstract() { } /** * @brief compute static data */ virtual void init() = 0; /** * @overload Operation::reset(double pStartTime, double pTimeInt) * @brief reset static data to process another TimeInterval */ virtual void reset() { Operation::reset(); resetResampling(); //_startTime = 0; //_timeInt = 0; _isNewInt = true; } /* * @brief return sampling value */ virtual double getSampling() = 0; /* * @brief reset resampling */ virtual void resetResampling() = 0; protected: /** * @brief start time */ double _startTime; /** *@brief interval time */ double _timeInt; /** *@brief tag to know if a new time interval is set */ bool _isNewInt; /* * @brief Define the resampling strategy */ bool _useNearestValue; }; /** * Simple Resampling abstract class, depand of paramData type */ template class ResamplingSimpleAbstract: public ResamplingAbstract { public: /** * @brief Element type of paramData */ typedef typename TParamData::ElementType ElementType; /** * @brief Constructor */ ResamplingSimpleAbstract(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList, double gapSize, TParamData ¶m, bool pUseNearestValue) : ResamplingAbstract( pProcess, pTimeIntervalList->front()._startTime, (pTimeIntervalList->front()._stopTime - pTimeIntervalList->front()._startTime),pUseNearestValue), _targetTime(0.0), _timeIntervalList(pTimeIntervalList), _currentTimeInterval(_timeIntervalList->begin()), _markerMinTime(0.0), _markerMaxTime(0.0), _samplingMode(INTERPOLATION), _nearestTime(NAN), _lastTime(0), _leftEffect(true), _paramOutput(new TParamData()), _paramInput(param), _gapSize(gapSize) { _paramDataOutput = _paramOutput; } /** * @brief Destructor */ virtual ~ResamplingSimpleAbstract() { } ; /** * @brief Type List of Element type of paramData */ typedef std::list ListValue; /** * @overload ResamplingAbstract::ResamplingAbstract::write() */ void write(ParamDataIndexInfo &pParamDataIndexInfo) { if (_isNewInt) { initStartTimeTarget(); _markerMinTime = _targetTime - getSampling() / 2.0; if (_markerMinTime < _startTime) _markerMinTime = _startTime; _markerMaxTime = _targetTime + getSampling() / 2.0; _isNewInt = false; } if ((pParamDataIndexInfo._nbDataToProcess > 0)) { //init _val with the first data value (to init dimensions) if (pParamDataIndexInfo._startIndex == 0) { _val = _paramInput.get(pParamDataIndexInfo._startIndex); _nearestValue = _paramInput.get(pParamDataIndexInfo._startIndex); _val << NotANumber(); _nearestValue << NotANumber(); } switch (_samplingMode) { case AVERAGE : writeAverage(pParamDataIndexInfo); // a rare case, it is the last data package but the data are all inside // a single resampling interval and no _paramOutput->push is done // force push for last data, and future call to terminate() will do nothing... if (_markerMaxTime >= _startTime + _timeInt && _paramInput.getTime(pParamDataIndexInfo._startIndex) >= _markerMinTime) terminated(); break; case NEARESTVALUE : writeNearestValue(pParamDataIndexInfo); break; case INTERPOLATION : writeInterpolation(pParamDataIndexInfo); break; } } else { terminated(); } } /** * @brief compute and write last value, right effect */ virtual void terminated() { switch (_samplingMode) { case INTERPOLATION : { double timeMax = _startTime + _timeInt; //Fix side-off effects - Right boundary - CONSTANTS if ((_targetTime <= timeMax) && !isFinished()) { if ( ( _targetTime - _lastTime) <= _gapSize) { _val = _valMoins1; } else { _val << NotANumber(); } do { _paramOutput->pushTime(_targetTime); _paramOutput->push(_val); _val << NotANumber(); } while (goToNextTimeTarget() && (_targetTime <= timeMax)); } break; } case AVERAGE : if (!_mem.empty()) { _val = average(_mem); _paramOutput->push(_val); _paramDataOutput->pushTime(_targetTime); _mem.clear(); goToNextTimeTarget(); } break; case NEARESTVALUE : if (!isNAN(_nearestTime)) { _paramOutput->push(_nearestValue); _paramDataOutput->pushTime(_targetTime); _nearestTime << NotANumber(); goToNextTimeTarget(); } break; } } /** * @brief compute and write new value in average mode */ void writeNearestValue(ParamDataIndexInfo &pParamDataIndexInfo) { for (unsigned int index = pParamDataIndexInfo._startIndex; index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; index++) { double timeCurrent = _paramInput.getTime(index); if (timeCurrent < _markerMaxTime) { if (isNAN(_nearestTime)) { _nearestValue = _paramInput.get(index); _nearestTime = timeCurrent; } else if (abs(_nearestTime-_targetTime) > abs(timeCurrent-_targetTime)) { _nearestValue = _paramInput.get(index); _nearestTime = timeCurrent; } } else { _paramOutput->push(_nearestValue); _paramDataOutput->pushTime(_targetTime); _markerMinTime = _markerMaxTime; if(!goToNextTimeTarget()) break; _markerMaxTime = _markerMinTime + getSampling(); while (_markerMaxTime < timeCurrent) { if ((timeCurrent - _lastTime < _gapSize) && !isNAN(_paramInput.get(index)) && !isNAN(_valMoins1)) { //Interpolation double coefT = (float) (_targetTime - _lastTime) / (timeCurrent - _lastTime); _val = _valMoins1 + (_paramInput.get(index) - _valMoins1) * coefT; } else _val << NotANumber(); _paramOutput->push(_val); _paramDataOutput->pushTime(_targetTime); _markerMinTime = _markerMaxTime; _nearestTime << NotANumber(); if(!goToNextTimeTarget()) break; _markerMaxTime = _markerMinTime + getSampling(); } _nearestValue = _paramInput.get(index); _nearestTime = timeCurrent; } _lastTime = _paramInput.getTime(index); _valMoins1 = _paramInput.get(index); } } /** * @brief compute and write new value in average mode */ void writeAverage(ParamDataIndexInfo &pParamDataIndexInfo) { for (unsigned int index = pParamDataIndexInfo._startIndex; index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; index++) { double timeCurrent = _paramInput.getTime(index); if (timeCurrent < _markerMaxTime) { //if a values are added in the last call _mem.push_back(_paramInput.get(index)); } else { if (!_mem.empty()) _val = average(_mem); else if ((timeCurrent - _lastTime < _gapSize) && !isNAN(_paramInput.get(index)) && !isNAN(_valMoins1)) { //Interpolation double coefT = (float) (_targetTime - _lastTime) / (timeCurrent - _lastTime); _val = _valMoins1 + (_paramInput.get(index) - _valMoins1) * coefT; } else _val << NotANumber(); _paramOutput->push(_val); _paramDataOutput->pushTime(_targetTime); _markerMinTime = _markerMaxTime; if(!goToNextTimeTarget()) break; _markerMaxTime = _markerMinTime + getSampling(); _mem.clear(); while (_markerMaxTime < timeCurrent) { if ((timeCurrent - _lastTime < _gapSize) && !isNAN(_paramInput.get(index)) && !isNAN(_valMoins1)) { //Interpolation double coefT = (float) (_targetTime - _lastTime) / (timeCurrent - _lastTime); _val = _valMoins1 + (_paramInput.get(index) - _valMoins1) * coefT; } else _val << NotANumber(); _paramOutput->push(_val); _paramDataOutput->pushTime(_targetTime); _markerMinTime = _markerMaxTime; if(!goToNextTimeTarget()) break; _markerMaxTime = _markerMinTime + getSampling(); } _mem.push_back(_paramInput.get(index)); } _lastTime = _paramInput.getTime(index); _valMoins1 = _paramInput.get(index); } } /** * @brief compute and write new value in interpolation mode */ void writeInterpolation(ParamDataIndexInfo &pParamDataIndexInfo) { for (unsigned int index = pParamDataIndexInfo._startIndex; index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; index++) { double timeCurrent = _paramInput.getTime(index); //Fix side-off effects - Left boundary - CONSTANTS if (_leftEffect) { while (_targetTime <= timeCurrent) { if (timeCurrent - _targetTime <= _gapSize) { _val = _paramInput.get(index); } else { _val << NotANumber(); } _paramDataOutput->pushTime(_targetTime); _paramOutput->push(_val); if (!goToNextTimeTarget()) break; } _leftEffect = false; } else { //if no data to be added if (_targetTime <= timeCurrent) { while (_targetTime <= timeCurrent) { double deltaT = (float) (timeCurrent - _lastTime); if (deltaT <= _gapSize) { if (isNAN(_paramInput.get(index)) || isNAN(_valMoins1)) { _val << NotANumber(); } else { double coefT = (float) (_targetTime - _lastTime) / deltaT; _val = _valMoins1 + (_paramInput.get(index) - _valMoins1) * coefT; } } else { _val << NotANumber(); } _paramDataOutput->pushTime(_targetTime); _paramOutput->push(_val); if (!goToNextTimeTarget()) break; } } } _lastTime = _paramInput.getTime(index); _valMoins1 = _paramInput.get(index); } } /** * @overload ResamplingAbstract::ResamplingAbstract::init() */ virtual void init() { //Compute Sampling mode if (_useNearestValue) { _samplingMode = NEARESTVALUE; _nearestValue = ElementType(); _nearestTime << NotANumber(); } else { float minSampling = _paramInput.getMinSampling(); if ((minSampling * 2) < getSampling()) { _samplingMode = AVERAGE; } } _isNewInt = true; } /** * @overload ResamplingAbstract::reset(double pStartTime, double pTimeInt) */ virtual void resetResampling() { if (_currentTimeInterval == _timeIntervalList->end()) return; // Get next TimeInteval; ++_currentTimeInterval; if (_currentTimeInterval != _timeIntervalList->end()) { _startTime = (*_currentTimeInterval)._startTime; _timeInt = (*_currentTimeInterval)._stopTime - _startTime; } _samplingMode = INTERPOLATION; _lastTime = 0; _leftEffect = true; _valMoins1 = ElementType(); _val = ElementType(); _mem.clear(); init(); } virtual void initStartTimeTarget() = 0; virtual bool goToNextTimeTarget() = 0; virtual bool isFinished() = 0; /** * @brief sampling mode */ enum SamplingMode { INTERPOLATION, AVERAGE, NEARESTVALUE }; protected : /** * @brief target average compute time */ double _targetTime; private: /** * @brief stored val to compute average in average mode */ ListValue _mem; TimeIntervalListSPtr _timeIntervalList; TimeIntervalList::iterator _currentTimeInterval; /**< * @brief marker of an averge interval min */ double _markerMinTime; /**< * @brief marker of an averge interval max */ double _markerMaxTime; /**< * @brief current sampling mode */ SamplingMode _samplingMode; /**< * @brief last computed value */ ElementType _val; /** * @brief nearest time */ double _nearestTime; /** * @brief nearest value */ ElementType _nearestValue; /**< * @brief last input value */ ElementType _valMoins1; /**< * @brief time of last input value */ double _lastTime; /** * @brief left effect indicator in interpolation mode */ bool _leftEffect; /** * @brief real ParamData Output */ TParamData *_paramOutput; /** * @brief real ParamData Input */ TParamData& _paramInput; /** * @brief gap size for input data */ double _gapSize; } ; /** * Resampling implementation with a given sampling time , depand of paramData type */ template class ResamplingWithSamplingTime : public ResamplingSimpleAbstract { public: /** * @brief Constructor */ ResamplingWithSamplingTime(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList, double sampling, double gapSize, TParamData ¶m, bool pUseNearestValue) : ResamplingSimpleAbstract(pProcess, pTimeIntervalList, gapSize, param, pUseNearestValue), _sampling(sampling) { } /** * @brief Destructor */ virtual ~ResamplingWithSamplingTime() { } virtual void initStartTimeTarget() { ResamplingSimpleAbstract::_targetTime = ResamplingSimpleAbstract::_startTime; } virtual bool goToNextTimeTarget() { ResamplingSimpleAbstract::_targetTime += _sampling; return true; } virtual double getSampling() { return _sampling; } virtual bool isFinished() { return false; } private: /** * @brief Ask sampling value */ double _sampling; } ; /** * Resampling implementation with a given reference parameter for time definition , depand of paramData type */ template class ResamplingWithRefParam: public ResamplingSimpleAbstract { public: /** * @brief Constructor */ ResamplingWithRefParam(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList, TParamData ¶m, ParamData &refParamData, double gapSize, bool pUseNearestValue) : ResamplingSimpleAbstract(pProcess, pTimeIntervalList, gapSize, param, pUseNearestValue), _crtRefIndex(0), _refParamData(refParamData) { } /** * @brief Destructor */ virtual ~ResamplingWithRefParam() { } virtual void initStartTimeTarget() { _crtRefIndex = _refParamData.getIndexInfo()._startIndex; if (isFinished()) { ResamplingSimpleAbstract::_targetTime = ResamplingSimpleAbstract::_startTime; return; } while (ResamplingSimpleAbstract::_startTime > _refParamData.getTime(_crtRefIndex)) { ++_crtRefIndex; if (isFinished()) { ResamplingSimpleAbstract::_targetTime = ResamplingSimpleAbstract::_startTime; return; } } ResamplingSimpleAbstract::_targetTime = _refParamData.getTime(_crtRefIndex); } virtual bool goToNextTimeTarget() { ++_crtRefIndex; if (isFinished()) return false; ResamplingSimpleAbstract::_targetTime = _refParamData.getTime(_crtRefIndex); return true; } virtual double getSampling() { return _refParamData.getMinSampling(); } virtual bool isFinished() { return (_crtRefIndex >= _refParamData.getDataNumber()); } virtual void init() { //_crtRefIndex = 0; ResamplingSimpleAbstract::init(); } private: /** * @brief current index in reference data */ unsigned int _crtRefIndex; /** * @brief pointer to reference parameter data */ ParamData& _refParamData; } ; /** * create the real Resampling implementation with visitor design pattern */ class CreateResampling: public VisitorOfParamData { public: enum ResamplingType { RT_WITHSAMPLINGTIME, RT_WITHREFTIMELIST }; /** * @brief constructor */ CreateResampling(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList, double sampling, double gapSize, ParamData ¶mData, bool useNearestValue) : _type(ResamplingType::RT_WITHSAMPLINGTIME), _process(pProcess), _paramData(paramData), _resampling(NULL), _timeIntervalList( pTimeIntervalList), _sampling(sampling), _gapSize( gapSize), _refParamData(paramData), _useNearestValue(useNearestValue) { _paramData.accept(*this); } /** * @brief constructor */ CreateResampling(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList, ParamData ¶mData, ParamData& refParamData, double gapSize, bool useNearestValue) : _type(ResamplingType::RT_WITHREFTIMELIST), _process(pProcess), _paramData(paramData), _resampling(NULL), _timeIntervalList( pTimeIntervalList), _sampling(0.), _gapSize( gapSize),_refParamData(refParamData), _useNearestValue(useNearestValue) { _paramData.accept(*this); } /** * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) */ virtual void visit(ParamDataScalaireShort *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) */ virtual void visit(ParamDataScalaireFloat *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *) */ virtual void visit(ParamDataScalaireDouble *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *) */ virtual void visit(ParamDataScalaireLongDouble *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataScalaireInt *) */ virtual void visit(ParamDataScalaireInt *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataLogicalData *) */ virtual void visit(ParamDataLogicalData *) { BOOST_THROW_EXCEPTION( AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg( "CreateResampling operation not supported")); } /** * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) */ virtual void visit(ParamDataTab1DShort *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) */ virtual void visit(ParamDataTab1DFloat *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) */ virtual void visit(ParamDataTab1DDouble *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) */ virtual void visit(ParamDataTab1DLongDouble *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) */ virtual void visit(ParamDataTab1DInt *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) */ virtual void visit(ParamDataTab1DLogicalData *) { BOOST_THROW_EXCEPTION( AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg( "CreateResampling operation not supported")); } /** * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) */ virtual void visit(ParamDataTab2DShort *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) */ virtual void visit(ParamDataTab2DFloat *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) */ virtual void visit(ParamDataTab2DDouble *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) */ virtual void visit(ParamDataTab2DLongDouble *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) */ virtual void visit(ParamDataTab2DInt *) { switch (_type) { case ResamplingType::RT_WITHSAMPLINGTIME : _resampling = new ResamplingWithSamplingTime(_process, _timeIntervalList, _sampling, _gapSize, dynamic_cast(_paramData), _useNearestValue); break; case ResamplingType::RT_WITHREFTIMELIST : _resampling = new ResamplingWithRefParam(_process, _timeIntervalList, dynamic_cast(_paramData), _refParamData, _gapSize, _useNearestValue); break; } } /** * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) */ virtual void visit(ParamDataTab2DLogicalData *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DLogicalData data not supported")); } /** * @brief Good resampling getter */ ResamplingAbstract* getResampling() const { return _resampling; } private: ResamplingType _type; Process &_process; ParamData &_paramData; ResamplingAbstract *_resampling; TimeIntervalListSPtr _timeIntervalList; double _sampling; double _gapSize; ParamData& _refParamData; bool _useNearestValue; }; } /* Resampling */ } /* AMDA */ } /* Parameters */ #endif /* Resampling_HH_ */