/** * DownloadParamNode.hh * * Created on: Jan 8, 2013 * Author: AKKA IS */ #ifndef DOWNLOADPARAMNODE_HH_ #define DOWNLOADPARAMNODE_HH_ #include #include "NodeCfg.hh" #include "DownloadLogger.hh" #include "Constant.hh" #include "DownloadOutput.hh" #include "DownloadProperties.hh" namespace AMDA { namespace ParamOutputImpl { namespace Download { /** * @class IndexNode * @brief read the "index" node which is an integer. */ template class IndexNode: public AMDA::XMLConfigurator::NodeCfg { public: void proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "IndexNode::proceed") ParamProperties *paramProperties = pContext.get(); paramProperties->addIndexDef((const char*) pNode->children->content); } }; /** * @class CalibrationInfoNode * @brief read the "calibration_info" node which is a string. */ template class CalibrationInfoNode: public AMDA::XMLConfigurator::NodeCfg { public: void proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "CalibrationInfoNode::proceed") ParamProperties *paramProperties = pContext.get(); paramProperties->addCalibrationInfo((const char*) pNode->children->content); } }; /** * @class DownloadParamNode * @brief read the "param" node which may be a complexe node and has an "id" attribute. */ class DownloadParamNode: public AMDA::XMLConfigurator::NodeGrpCfg { public: DownloadParamNode() : AMDA::XMLConfigurator::NodeGrpCfg() { getChildList()["index"] = AMDA::XMLConfigurator::NodeCfgSPtr( new IndexNode()); getChildList()["calibration_info"] = AMDA::XMLConfigurator::NodeCfgSPtr( new CalibrationInfoNode()); } void proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "DownloadParamNode::proceed") xmlChar* lParamName = NULL; ParamProperties *paramProperties = NULL; try { lParamName = xmlGetProp(pNode, (const xmlChar *) "id"); if (lParamName == NULL) { ERROR_EXCEPTION( AMDA::XMLConfigurator::ERROR_MANDATORY_ATTRIBUTE_MISSING << pNode->name << "@" << AMDA::XMLConfigurator::PARAMNAME) } DownloadProperties *downloadProperties = pContext.get(); paramProperties = downloadProperties->getParamPropertiesFromOriginalId((const char*) lParamName); if (paramProperties == NULL) { //create new paramProperties paramProperties = new ParamProperties (); paramProperties->setOriginalId((const char*) lParamName); // Add param properties to download properties downloadProperties->addParamProperties(paramProperties); } xmlFree(lParamName); } catch (...) { throw; } AMDA::Parameters::CfgContext lContext (pContext); lContext.push (paramProperties); NodeGrpCfg::proceed(pNode, lContext); } }; } // namespace Download } // namespace ParamOutputImpl } // namespace AMDA #endif /* PARAMNODE_HH_ */