TimeShifted.hh 1.53 KB
/*
 * TimeShifted.hh
 *
 *  Created on: Dec 3, 2012
 *      Author: f.casimir
 */

#ifndef TIMESHIFTED_HH_
#define TIMESHIFTED_HH_

#include "Parameter.hh"
#include "ParamData.hh"
#include "Operation.hh"

namespace AMDA {
namespace Parameters {

/**
 * @class TimeShifted
 * @brief It is responsible to shift data of any ParamData type.
 * @details This class implement the interface Operation.
 */
template<class TParamData>
class TimeShifted : public Operation {
public:
	/**
	 * @brief Constructor.
	 * @details Create the ParamData type of the input ParamData.
	 */
  TimeShifted(Process& pProcess, TParamData& paramInput, double second)
	: Operation(pProcess), _paramInput(paramInput), _paramOutput(new TParamData()), _second(second) {
	  _paramDataOutput=_paramOutput;
  }

	/**
	 * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
	 */
  void  write(ParamDataIndexInfo &pParamDataIndexInfo) {
    unsigned int index = pParamDataIndexInfo._startIndex;
    for (; index< pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; index++) {
    	_paramOutput->pushTime(_paramInput.getTime(index)+_second);
    	_paramOutput->getDataList().push_back(_paramInput.getDataList()[index]);
    }
  }

private:
	/**
	 * @brief It is the channel of data to shift.
	 */
  TParamData &_paramInput;
	/**
	 * @brief It is the channel of the data shifted.
	 */
  TParamData *_paramOutput;
  /**
   * @brief laps time to shift data.
   */
  double _second;
};

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