ParamsNode.hh 2.29 KB
/*
 * ParamsNode.hh
 *
 *  Created on: 21 nov. 2013
 *      Author: CS
 */

#ifndef PARAMSNODE_HH_
#define PARAMSNODE_HH_

#include "NodeCfg.hh"
#include "PlotLogger.hh"
#include "CommonNode.hh"
#include "DefaultPlotConfiguration.hh"
#include "PanelPlotOutput.hh"
#include "DrawingPropertiesNode.hh"
#include "SeriesNode.hh"
#include "SpectroNode.hh"
#include "IntervalsNode.hh"

namespace plot {

template<class PlotType>
class ParamNode: public AMDA::XMLConfigurator::NodeGrpCfg {
public:
	ParamNode() :
			AMDA::XMLConfigurator::NodeGrpCfg() {
		getChildList()["default"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new DrawingPropertiesNode<PlotType>());
		getChildList()["serie"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new SeriesNode<PlotType>());
		getChildList()["spectro"] = AMDA::XMLConfigurator::NodeCfgSPtr(
						new SpectroNode<PlotType>());
		getChildList()["intervals"] = AMDA::XMLConfigurator::NodeCfgSPtr(
						new IntervalsNode<PlotType>());
		getChildList()["colorserie"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new ColorSeriesNode<PlotType>());
	}

	virtual ~ParamNode() {
	}

	void proceed(xmlNodePtr pNode,
			const AMDA::Parameters::CfgContext& pContext) {
		LOG4CXX_DEBUG(gLogger, "ParamNode::proceed");
		PlotType* plotOutput = pContext.get<PlotType*>();
		xmlChar* name = NULL;
		// -- param id
		name = xmlGetProp(pNode, (const xmlChar *) "id");
		if (name) {
			plotOutput->addParam((const char*) name);
		}

		// initialize drawing default properties object:
		DrawingProperties props;
		// take default value during init...
		DefaultPlotConfiguration::getInstance().applyDefaultDrawingProperties(
				plotOutput->typeName(),
				props
				);
		// add default properties to parameter
		plotOutput->getParameter((const char*)name).setDefaultProperties( props );

		AMDA::Parameters::CfgContext context;
		context.push<xmlChar*>(name);
		context.push<PlotType*>(plotOutput);
		AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode, context);

		if (name) {
			xmlFree (name);
		}
	}
};

template<class PlotType>
class ParamsNode: public AMDA::XMLConfigurator::NodeGrpCfg {
public:
	ParamsNode() :
			AMDA::XMLConfigurator::NodeGrpCfg() {
		getChildList()["param"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new ParamNode<PlotType>());
	}

	virtual ~ParamsNode() {
	}
};

} /* namespace plot */
#endif /* PARAMSNODE_HH_ */