SingleParamProcess.hh 2.16 KB
/*
 * SingleParamProcess.hh
 *
 *  Created on: Feb 6, 2013
 *      Author: f.casimir
 */

#ifndef SINGLEPARAMPROCESS_HH_
#define SINGLEPARAMPROCESS_HH_

#include "Process.hh"

namespace AMDA {
namespace Parameters {

class SingleParamProcess  : public Process {
public:
	SingleParamProcess(Parameter &parameter);
	SingleParamProcess(const SingleParamProcess &pProcess, Parameter &parameter);
	virtual ~SingleParamProcess();

	// Overload DataClient methods
	/**
	 * @overload DataClient::establishConnection()
	 */
	virtual void establishConnection();

	/**
	 * @overload Process::write()
	 */
	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 If the expression is not a Single parameter,
	 * it must ask the creation of a parameter responsible of the formula calculation.
	 */
	virtual void parse();

	/**
	 * @brief It the server of the data to shift.
	 */
	ParameterSPtr _parameterInput;

	/**
	 * @brief It is the channel of data to shift.
	 */
	ParamData *   _paramInput;

	/**
	 * @brief tag last data treatment
	 */
	bool _treatTerminated = false;

	/**
	 * @brief
	 */
	bool _expressionParsed;
};

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

	/**
	 * constructeur by copy
	 */
	SingleParamProcess_CRTP(const SingleParamProcess &pProcess, Parameter &parameter) :
		SingleParamProcess(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 /* SINGLEPARAMPROCESS_HH_ */