ParamPlotParser.cc 1.55 KB
/*
 * ParamPlotParser.cc
 *
 *  Created on: Oct 6, 2014
 *      Author: m.mazel
 */

#include "NodeCfg.hh"
#include "AMDA_exception.hh"
#include "ParamPlotParser.hh"
#include "ParamParamPlotNode.hh"

using namespace AMDA::XMLConfigurator;

namespace plot {

///////////////////////////////////////////////////////////////////////////////

class ParamOutputNode : public NodeGrpCfg {
public:

	ParamOutputNode () : NodeGrpCfg() {
		getChildList()["plot"] = NodeCfgSPtr(new ParamParamPlotNode);
	}

	void proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) {
		LOG4CXX_INFO(gLogger, "ParamOutputNode::proceed");

		// Proceed nodes
		NodeGrpCfg::proceed(pNode, pContext);
	}
};

///////////////////////////////////////////////////////////////////////////////

ParamPlotParser::ParamPlotParser (const char* pXSDFile) : XMLConfigurator(pXSDFile,true)
{
	// read ParamInfo node
	NodeGrpCfg* lRequestNode = new NodeGrpCfg();
	getXmlConfiguratorMap()["param"] = RootNodeCfgSPtr(lRequestNode);
	lRequestNode->getChildList()["output"] = NodeCfgSPtr(new ParamOutputNode);
}

///////////////////////////////////////////////////////////////////////////////

void ParamPlotParser::parse (const std::string& paramFile, const AMDA::Parameters::CfgContext& pContext) {
	LOG4CXX_INFO(gLogger, "ParamPlotParser::parse parsing " << paramFile);

	// Check schema validity and parse xml file
	try {
		XMLConfigurator::proceed(paramFile.c_str(), pContext);
	}
	catch (...) {
		LOG4CXX_INFO(gLogger, "ParamPlotParser::parse error while parsing file " << paramFile);
	}
}

} /* namespace plot */