ParamGet.hh 2.25 KB
/*
 * ParamGet.hh
 *
 *  Created on: 15 oct. 2012
 *      Author: casimir
 */

#ifndef PARAMGET_HH_
#define PARAMGET_HH_


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

#include "AMDA_exception.hh"
#include "DataWriter.hh"


namespace AMDA {
namespace Parameters {

//used class
class Parameter;


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

/**
 * @brief Abstract class to Get parameter value
 * @details must be implemented for get value in a dataBase, file, or any way
 */
class ParamGet : public AMDA::Parameters::DataWriter {
public:
	/**
	 * Constructor
	 */
	ParamGet(Parameter & parameter);

	/**
	 * Constructor by copy
	 */
	ParamGet(const ParamGet &pParamGet, Parameter & parameter);

	/**
	 * Destructor
	 */
	virtual ~ParamGet();

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

	/*
	 * @brief set the resampling strategy to use
	 */
	void setUseNearestValue(bool useNearestValue)
	{
		_useNearestValue = useNearestValue;
	}

        double getGlobalStart() {
            return _globalStart;
        }

        double getGlobalStop() {
            return _globalStop;
        }

        void setGlobalStart(double globalStart) {
            _globalStart = globalStart;
        }

        void setGlobalStop(double globalStop) {
            _globalStop = globalStop;
        }

protected:

	static log4cxx::LoggerPtr _logger;

private:
	bool _useNearestValue;

        double _globalStart;

        double _globalStop;
};

typedef boost::shared_ptr<ParamGet> ParamGetSPtr;

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

	/**
	 * constructor by copy
	 */
	ParamGet_CRTP(const ParamGet &pDataWriter, Parameter &parameter) : ParamGet(pDataWriter,parameter) {}

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




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