DataWriter.cc 1.64 KB
/**
 * DataWriter.cc
 *
 *  Created on: Nov 14, 2012
 *      Author: AKKA IS
 */

#include "DataWriter.hh"


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

namespace AMDA {
namespace Parameters {

log4cxx::LoggerPtr DataWriter::_logger(log4cxx::Logger::getLogger("AMDA-Kernel.DataWriter"));

DataWriter::DataWriter(Parameter &parameter)  :
		_parameter(parameter),
		_signatureTrigger(""), _timeRestriction(NAN)  {

}

DataWriter::DataWriter(const DataWriter &pDataWriter, Parameter &pParameter)  :
		_parameter(pParameter),
		_timeIntervalList(pDataWriter._timeIntervalList),
		_paramData(),
		_signatureTrigger(pDataWriter._signatureTrigger), _timeRestriction(pDataWriter._timeRestriction) {
//_paramData not copied, must a be different instance of pDataWriter
}

DataWriter::~DataWriter() {
}

TimeStamp   DataWriter::init(TimeIntervalListSPtr pTimeIntervalList) {
	LOG4CXX_DEBUG(_logger, "DataWriter => Initialise data writer for parameter: " << _parameter.getId());
	_timeIntervalList = pTimeIntervalList;
	TimeStamp timeStamp = init();
	updateInfo(_parameter);
    return timeStamp;
}

ParameterManager &DataWriter::getParameterManager() {
	return _parameter.getParameterManager();
}

void DataWriter::updateInfo(Parameter & /*parameter*/) {
	//nothing to do - each param getter can override this method to update specific param info
}

void DataWriter::applyTimeRestriction(unsigned int startIndex, unsigned int nbDataToProcess) {
	for (unsigned int _index = startIndex ; _index < startIndex + nbDataToProcess; ++_index)
	{
		if (_paramData->getTime(_index) >= _timeRestriction) {
			_paramData->setNAN(_index);
		}
	}
}

} /* namespace Parameters */
} /* namespace AMDA */