CurveFunctionWriter.cc 1.21 KB
/*
 * CurveFunctionWriter.cc
 *
 *  Created on: Sep 19, 2014
 *      Author: AKKA
 */

#include "CurveFunctionWriter.hh"
#include "Process.hh"
#include "ServicesServer.hh"

using namespace AMDA::Parameters;

namespace plot {

	CurveFunctionWriter::CurveFunctionWriter() {
	}

	CurveFunctionWriter::~CurveFunctionWriter() {
	}

	void CurveFunctionWriter::call(double resolution, CurveFunctionWriter::CurvePointList &curvePointList) {
		/// Execute function
		CurveFunctionProcess functor = ServicesServer::getInstance()->getService<CurveFunctionProcess>(_functionName);
		if ( ! functor) {
			std::stringstream oss;
			oss << "Curve function: '" << _functionName << "' not exist";
				BOOST_THROW_EXCEPTION(Process_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(oss.str()));
		} else {
			functor(resolution, _attributeList, curvePointList);
		}
	}
	
	void CurveFunctionWriter::setFunctionName(const std::string& name)
	{
		_functionName = name;
	}
	
	std::string CurveFunctionWriter::getFunctionName(void)
	{
		return _functionName;
	}
	
	void CurveFunctionWriter::addAttribute(const std::string& name,double value)
	{
		_attributeList[name] = value;
	}
} /* namespace plot */