OutputIntervalTrueNode.hh 1.71 KB
/*
 * OutputIntervalTrueNode.hh
 *
 *  Created on: Oct 31, 2012
 *      Author: f.casimir
 */

#ifndef OutputIntervalTrueNode_HH_
#define OutputIntervalTrueNode_HH_

#include "NodeCfg.hh"

#include "DownloadParamNode.hh"

namespace AMDA {
namespace ParamOutputImpl {
namespace Download {

class OutputIntervalTrueNode: public AMDA::XMLConfigurator::NodeGrpCfg {
public:
	OutputIntervalTrueNode();
	void proceed(xmlNodePtr pNode,
			const AMDA::Parameters::CfgContext& pContext);
};

template<class ParamOutputType>
class SingleParamNode: public AMDA::XMLConfigurator::NodeGrpCfg {
public:
	SingleParamNode() :
			AMDA::XMLConfigurator::NodeGrpCfg() {
		getChildList()["index"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new IndexNode<ParamOutputType>());
		getChildList()["calibration_info"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new CalibrationInfoNode<ParamOutputType>());
	}

	void proceed(xmlNodePtr pNode,
			const AMDA::Parameters::CfgContext& pContext) {
		LOG4CXX_DEBUG(gLogger, "SingleParamNode::proceed")
		xmlChar* lParamName = NULL;

		try {
			if (!(lParamName = xmlGetProp(pNode, (const xmlChar *) "id"))) {
				ERROR_EXCEPTION(
						AMDA::XMLConfigurator::ERROR_MANDATORY_ATTRIBUTE_MISSING
								<< pNode->name << "@"
								<< AMDA::XMLConfigurator::PARAMNAME)
			}
			std::string lStrParamName((const char*) lParamName);
			ParamOutputType* lParamOutput = pContext.get<ParamOutputType*>();
			lParamOutput->setParamName(lStrParamName);

		} catch (...) {
			if (lParamName) {
				xmlFree(lParamName);
			}
			throw;
		}
		if (lParamName) {
			xmlFree(lParamName);
		}
		NodeGrpCfg::proceed(pNode, pContext);
	}
};

} // namespace Download
} // namespace ParamOutputImpl
} // namespace AMDA
#endif // OutputIntervalTrueNode_HH_