BinsNode.cc 1.83 KB
/*
 * Bins1DNode.cc
 *
 *  Created on: Jan 27, 2023
 *      Author: AKKODIS
 */

#include <libxml/tree.h>
#include <iosfwd>
#include "BinsNode.hh"


namespace plot {


	void ManualNode::proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& pContext_){
		LOG4CXX_DEBUG(gLogger, "ManualNode::proceed");
		HistogramSeriesProperties* props = pContext_.get<HistogramSeriesProperties*>();
		// read attributes :
		xmlChar* value = NULL;

		// overwrites default values if any...
		// xbinnumber
		value = xmlGetProp(pNode_, (const xmlChar *)"xbinnumber");
		if( value ){
			props->getManualProperties().setXBinNumber(std::stoul((const char*)value));
			xmlFree(value);
		}
		// -- stairs
		value = xmlGetProp(pNode_, (const xmlChar *) "stairs");
		if (value) {
			std::string strValue((const char*) value);
			std::transform(strValue.begin(), strValue.end(), strValue.begin(),
					::tolower);
			std::istringstream is(strValue);
			bool stairs;
			is >> std::boolalpha >> stairs;
			props->getManualProperties().setStairs(stairs);
			xmlFree(value);
		}
		else{
			props->getManualProperties().setStairs(false);
		}

		// ybinnumber
		if(_histogramType == "histogram2d"){
			value = xmlGetProp(pNode_, (const xmlChar *)"ybinnumber");
			if( value ){
				props->getManualProperties().setYBinNumber(std::stoul((const char*)value));
				xmlFree(value);
			}
		}
	}

	void BinsNode::proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& pContext_){
		LOG4CXX_DEBUG(gLogger, "BinsNode::proceed");
		HistogramSeriesProperties* props = pContext_.get<HistogramSeriesProperties*>();
		xmlChar* name = pContext_.get<xmlChar*>();

		//parse children nodes
		AMDA::Parameters::CfgContext context;
		context.push<xmlChar*>(name);
		context.push<HistogramSeriesProperties*>(props);
		AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, context);
	}

} /* namespace plot */