ResamplingNode.cc 1.39 KB
/*
 * ResamplingNode.cc
 *
 *  Created on: Aug 19, 2014
 *      Author: AKKA
 */


#include "ResamplingNode.hh"

#include <libxml/tree.h>
#include <iosfwd>

#include "NodeCfg.hh"
#include "PlotLogger.hh"
#include "SeriesProperties.hh"
#include "CommonNode.hh"



namespace plot {

void ResamplingNode::proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& pContext_){
	LOG4CXX_DEBUG(gLogger, "ResamplingNode::proceed");
//	std::cout << "reading line node ..."<< std::endl;
	DrawingProperties* props = pContext_.get<DrawingProperties*>();
	// read attributes :
	xmlChar* value = NULL;

	// TODO see if we have some default config values to retrieve...

	// overwrites default values if any...
	// type
	value = xmlGetProp(pNode_, (const xmlChar *)"type");
	if( value ){
		try{
			props->getResamplingProperties().setType( stoResamplingType.at(std::string((const char*)value)) );
//			std::cout << "@type="<< value<< std::endl;
		}
		catch( std::out_of_range& err ){
			std::ostringstream msg {};
			msg << "ResamplingNode::proceed invalid resampling type value:" << value <<". Using default value.";
			LOG4CXX_DEBUG(gLogger, msg.str());
		}
		xmlFree(value);
	}

	// value
	value = xmlGetProp(pNode_, (const xmlChar *)"value");
	if( value ){
		props->getResamplingProperties().setValue( atol((const char*)value) );
//		std::cout << "@value="<< value<< std::endl;
		xmlFree(value);
	}
}

} /* namespace plot */