ParamOutput.hh 2.59 KB
/**
 * ParamOutput.hh
 *
 *  Created on: 18 oct. 2012
 *      Author: AKKA IS
 */

#ifndef PARAMOUTPUT_HH_
#define PARAMOUTPUT_HH_

#include <map>
#include <list>
#include <boost/shared_ptr.hpp>
#include <memory>

#include "ParameterManager.hh"
#include "ParamData.hh"
#include "VisitorOfParamData.hh"
#include "DataClient.hh"
#include "Parameter.hh"
#include "PostProcessingAble.hh"

#include "log4cxx/logger.h"

namespace AMDA {
namespace Parameters {

class Parameter;

typedef boost::shared_ptr<Parameter> ParameterSPtr;

/**
 * Exception specific for ParseMainArguments
 */
struct ParamOutput_exception: virtual AMDA_exception {
};

/**
 * AMDA::Parameters::ParamOutput
 */
class ParamOutput: public AMDA::Parameters::DataClient,
		public postprocessing::PostProcessingAble {
public:

	ParamOutput(ParameterManager& pParameterManager);
	virtual ~ParamOutput();

	/**
	 * set information sampling
	 */
	void setSampling(const std::string &samplingMode, double samplingValue,
			float gapThreshold) {
		_samplingMode = samplingMode;
		_samplingValue = samplingValue;
		_gapThreshold = gapThreshold;
	}
	void setWorkPath(const std::string &workPath) {
		_workPath = workPath;
	}

	// Others methods
	/**
	 * @brief initializes time attribute
	 */
	virtual void init(TimeIntervalListSPtr pTimeIntervalList);

	void process();
	/**
	 * @brief generate output, get data with _parameter->getAsync and write data with the design pattern visitor
	 */
	virtual void apply() = 0;

	virtual void terminate();

protected:
	/**
	 * @brief initializes all parameter to process
	 */
	virtual void init() = 0;

	static log4cxx::LoggerPtr _logger;

	/**
	 * @brief _timeInterval: List of time interval on which to do output.
	 */
	TimeIntervalListSPtr _timeIntervalList;

	/**
	 * @brief _timeInterval: List of time interval for which time interval is less than sampling time.
	 */
	TimeIntervalListSPtr _timeIntervalListTooSmall;

	/**
	 * @brief _currentTimeInterval: Identify on which time interval ParamOutput instance is working.
	 */
	TimeIntervalList::iterator _currentTimeInterval;

	/**
	 * sampling mode of _parameter
	 * by default: "" <==> no sampling
	 */
	std::string _samplingMode;

	/**
	 * path where output are created
	 * by default: "."
	 */
	std::string _workPath;

	/**
	 * sampling value of _parameter
	 */
	double _samplingValue;

	/**
	 * gap threshold of _parameter
	 */
	float _gapThreshold;

	ParamDataIndexInfo _paramDataIndexInfo;

	ParameterManager& _parameterManager;

};

double getSamplingInTreeParameter(AMDA::Parameters::ParameterSPtr pParam);

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