PlotNode.cc 2.5 KB
/*
 * PlotNode.cc
 *
 *  Created on: 29 oct. 2013
 *      Author: CS
 */

#include "PlotNode.hh"
#include "PostProcessingNode.hh"
#include "ParameterManager.hh"
#include "PlotOutput.hh"
#include "PageNode.hh"
#include "PlotLogger.hh"
#include "DefaultPlotConfiguration.hh"
#include "CommonNode.hh"

namespace plot {

PlotNode::PlotNode() :
		NodeGrpCfg() {
	getChildList()["outputStructure"] = AMDA::XMLConfigurator::NodeCfgSPtr(new OutputStructureNode());
	getChildList()["filePrefix"] = AMDA::XMLConfigurator::NodeCfgSPtr(new FilePrefixNode());
	getChildList()["page"] = AMDA::XMLConfigurator::NodeCfgSPtr(new PageNode());
	getChildList()["postProcess"] = AMDA::XMLConfigurator::NodeCfgSPtr(
			new postprocessing::PostProcessingNode<PlotOutput>());
}

PlotNode::~PlotNode() {

}

void PlotNode::proceed(xmlNodePtr pNode,
		const AMDA::Parameters::CfgContext& pContext) {
	AMDA::Parameters::ParameterManager* lParameterManager = pContext.get<
			AMDA::Parameters::ParameterManager*>();

	// create plot output and add it to the context and to
	// the output manager

	AMDA::Parameters::CfgContext lContext;
	PlotOutput* plotOutput = new PlotOutput(*lParameterManager);

	xmlChar* value;

	// -- writeContextFile
	if ((value = xmlGetProp(pNode, (const xmlChar *) "writeContextFile")))
	{
		plotOutput->setWriteContextFile(strcmp ((const char *) value, "true") == 0);
		xmlFree(value);
	}
	//writeDataFile
	if ((value = xmlGetProp(pNode, (const xmlChar *) "writeDataFile")))
	{
		plotOutput->setWriteDataFile(strcmp ((const char *) value, "true") == 0);
		xmlFree(value);
	}

	lContext.push<PlotOutput*>(plotOutput);
	lContext.push<AMDA::Parameters::ParameterManager*>(lParameterManager);
	lContext.push<std::string*>(&plotOutput->getFilePrefix());
	AMDA::Parameters::ParamOutputSPtr lParamOutput(plotOutput);
	AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode, lContext);
	lParameterManager->getParamOutputList().push_back(lParamOutput);
}

void OutputStructureNode::proceed(xmlNodePtr pNode,
			const AMDA::Parameters::CfgContext& pContext) {
		LOG4CXX_DEBUG(gLogger, "OutputStructureNode::proceed")

		PlotOutput* lPlotOutput =
				pContext.get<PlotOutput*>();
		lPlotOutput->setOutputStructure(
				(const char*) pNode->children->content);
	}

void FilePrefixNode::proceed(xmlNodePtr pNode,
			const AMDA::Parameters::CfgContext& pContext) {
		LOG4CXX_DEBUG(gLogger, "FilePrefixNode::proceed")

		PlotOutput* lPlotOutput =
				pContext.get<PlotOutput*>();
		lPlotOutput->setFilePrefix(
				(const char*) pNode->children->content);
}

} /* namespace plot */