MultiParamProcess.hh 2.34 KB
/*
 * MultiParamProcess.hh
 *
 *  Created on: Jan 4, 2013
 *      Author: f.casimir
 */

#ifndef MULTIPARAMPROCESS_HH_
#define MULTIPARAMPROCESS_HH_

#include <string>
#include <map>

#include <boost/shared_ptr.hpp>
#include <log4cxx/logger.h>

#include "Process.hh"

namespace AMDA {
namespace Parameters {

class TimeStamp;

/**
 * abstract class to allow a process on multi parameter
 */
class MultiParamProcess: public Process {
public:
	typedef std::map<std::string,std::pair<ParameterSPtr,ParamDataIndexInfo>> ParameterList;

	MultiParamProcess(Parameter &parameter);
	MultiParamProcess(const MultiParamProcess &pProcess, Parameter &parameter);
	virtual ~MultiParamProcess();

	ParameterList& getParameterList() { return _paramNameList; }

	/**
	 *  @brief Connection to Parameter server.
	 *  @overload DataClient::establishConnection()
	 */
	void establishConnection();

	/**
	 *  @overload DataClient::init()
	 */
	virtual TimeStamp  init();

	/**
	 *  Write data in dataParam.
	 */
	virtual unsigned int write();

	/*
	 * @brief @ to know the resampling strategy to use. If it's true, the nearest value will be use
	 */
	virtual bool useNearestValue();

	/*
	 * @overload DataWriter::getMinSampling
	 */
	virtual double getMinSampling();

	/**
	 * @overload DataWriter::updateInfo - update parameter info in relation to the process
	 */
	virtual void updateInfo(Parameter & parameter);

protected:
	/**
	 * @brief list of parameter name
	 */
	ParameterList _paramNameList;
	/**
	 * @brief merge of paramDataIndexInfo of all parameter
	 */
	ParamDataIndexInfo _paramDataIndexInfo;

	/**
	 * @brief minSampling of all paramInput
	 */
	double _minSampling;
};

/**
 *  @brief This CRTP class implements clone() for Derived
 */
template <typename Derived>
class MultiParamProcess_CRTP : public MultiParamProcess {
public:
	/**
	 * Default constructor
	 */
	MultiParamProcess_CRTP(Parameter &parameter) : MultiParamProcess(parameter) {}

	/**
	 * constructeur by copy
	 */
	MultiParamProcess_CRTP(const MultiParamProcess &pProcess, Parameter &parameter) :
		MultiParamProcess(pProcess, parameter) {}

	/**
	 * clone an implementation of MultiParamProcess
	 */
    virtual DataWriter *clone(Parameter &parameter) const {
        return new Derived(static_cast<Derived const&>(*this),parameter);
    }
};
} /* namespace Parameters */
} /* namespace AMDA */
#endif /* MULTIPARAMPROCESS_HH_ */