MexVexElsDecode.hh.ben 2.37 KB
/*
 * MexVexElsDecode.hh
 *
 *  Created on: Oct 13, 2016
 *      Author: elena / benjamin
 */

#ifndef MEXVEXELSDECODE_HH_
#define MEXVEXELSDECODE_HH_

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

namespace AMDA {
namespace Parameters {
namespace MexVexElsDecode {

/**
 * @class MexVexElsDecode
 * @brief 
 * @details This class implement the interface Operation.
 */

template<typename DataType>
class MexVexElsDecode : public Operation {

public:
	/**
	 * @brief Constructor.
	 * @details Create the ParamData type of the input ParamData.
	 */
	MexVexElsDecode(Process& pProcess, ParamDataSpec<std::vector<DataType> >& paramInput)
	: Operation(pProcess),
	  _paramInput(paramInput),
	  _paramOutput(new ParamDataSpec<std::vector<DataType>>()){
	  _paramDataOutput=_paramOutput;
	}

	virtual ~MexVexElsDecode() {
		
	}

	/**
	 * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
	 */
  void  write(ParamDataIndexInfo &pParamDataIndexInfo) {
	  
	  ParameterSPtr crtParam = _process.getParameterManager().getParameter("EnergyTable");
	  ParamData* lModeParamInput = crtParam->getParamData(&_process).get();
	  
	  for (unsigned int _index = pParamDataIndexInfo._startIndex ;
			  _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
			  ++_index)
	  {
		  double crtTime = _paramInput.getTime(_index);
		  std::vector<DataType> inputElt = _paramInput.get(_index);
	  
		  int mode = (dynamic_cast<ParamDataScalaireShort*>(lModeParamInput))->get(_index);

		  if (mode == 1) {
			  for (int i = 0; i < 4; ++i){
			       typename std::vector<DataType>::const_iterator first = inputElt.begin() + 31 * i;
				typename std::vector<DataType>::const_iterator last = inputElt.begin() + 31 * (i + 1);
				std::vector<DataType> splitVec(first, last);
				_paramOutput->pushTime(crtTime+i);
				_paramOutput->getDataList().push_back(splitVec);
			}
		}
		else
		{
		  _paramOutput->pushTime(crtTime);
		  _paramOutput->getDataList().push_back(inputElt);
		}
	  }
  }

  
private:
	/**<
	 * @brief It is the channel of data derived
	 */
  ParamDataSpec<std::vector<DataType> > &_paramInput;

	/**<
	 * @brief It is the channel of the data derived
	 */
  ParamDataSpec<std::vector<DataType>> *_paramOutput;

};

} /* namespace MexVexElsDecode */
} /* namespace Parameters */
} /* namespace AMDA */
#endif /* MEXVEXELSDECODE_HH_ */