Process.hh 3.54 KB
/*
 * Process.hh
 *
 *  Created on: Oct 31, 2012
 *      Author: f.casimir
 */

#ifndef PROCESS_HH_
#define PROCESS_HH_

#include <vector>

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


#include "AMDA_exception.hh"
#include "DataWriter.hh"
#include "DataClient.hh"
#include "Parameter.hh"

namespace AMDA {
namespace Parameters {

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

class Operation;



/**
 * @class Process
 * @brief Interface to implemented a Process, a Process is used to compute a new ParamData with input data.
 * @details an implementation must implemented AMDA::Parameters::DataWriter and AMDA::Parameters::DataClien interface
 */
class Process : public AMDA::Parameters::DataWriter, public AMDA::Parameters::DataClient {
public:
	typedef std::vector<std::string > AttributeList;
	/**
	 *
	 * Default constructor.
	 */
	Process(Parameter &parameter);
	/**
	 *
	 * Default constructor.
	 */
	Process(const Process &process, Parameter &parameter);

	/**
	 * Default destructor.
	 */
	virtual ~Process();

	// Get methods
	const std::string& getExpression() const { return _expression; }
	const std::string& getDescription() const { return _description; }
	Operation* getOperation() {	return _operation; }
	ParameterSPtr getReferenceParameter() { return _refParameterSPtr; }
	AttributeList& getAttributList() { return _attributList; }

	bool isUserProcess() {
		return _isUserProcess;
	}

	// Set methods
	void setExpression(const std::string& expression) {	_expression = expression; }
	void setDescription(const std::string& description) { _description = description; }
	void setOperation(Operation* pOperation) {	_operation = pOperation; }
	void setReferenceParameter( ParameterSPtr refParameterSPtr) { _refParameterSPtr = refParameterSPtr;}
	void setGapThreshold(double gapThreshold) {	_gapThreshold = gapThreshold; }

	/**
	 * Set flag to know if it's a process built especially for a user
	 */
	void setIsUserProcess(bool isUserProcess) {
		_isUserProcess = isUserProcess;
	}

	// Others methods

	virtual bool isEmptyExpression() { return _expression.empty(); }

	void setAttributList(AttributeList pAttributList) { _attributList = pAttributList; }
                    
                   
                  AMDA::Parameters::SemiVariableTable getSemiVariableTable(){
                       return _semiVariableTable;
                   }
                   void setSemiVariableTable(SemiVariableTable semiVariableTable){
                       _semiVariableTable = semiVariableTable;
                   }


protected:
	static log4cxx::LoggerPtr _logger;


	 /**
	  * to store attribut of process write in _expression
	  */
                    AttributeList _attributList;
	std::string _expression;
	std::string _description;
	Operation *_operation;
	ParameterSPtr _refParameterSPtr;
	double _gapThreshold;
	bool _isUserProcess;
                     AMDA::Parameters::SemiVariableTable _semiVariableTable;
};

typedef boost::shared_ptr<Process> ProcessSPtr;

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

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

    virtual DataWriter *clone(Parameter &parameter) const {
        return new Derived(static_cast<Derived const&>(*this),parameter);
    }
};

} /* namespace Parameters */

} /* namespace AMDA */
#endif /* PROCESS_HH_ */