DownloadParamNode.hh
3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* DownloadParamNode.hh
*
* Created on: Jan 8, 2013
* Author: AKKA IS
*/
#ifndef DOWNLOADPARAMNODE_HH_
#define DOWNLOADPARAMNODE_HH_
#include <log4cxx/logger.h>
#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 ParamOutputType>
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 *>();
paramProperties->addIndexDef((const char*) pNode->children->content);
}
};
/**
* @class CalibrationInfoNode
* @brief read the "calibration_info" node which is a string.
*/
template<class ParamOutputType>
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 *>();
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<DownloadOutput>());
getChildList()["calibration_info"] = AMDA::XMLConfigurator::NodeCfgSPtr(
new CalibrationInfoNode<DownloadOutput>());
}
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<DownloadProperties *>();
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 *> (paramProperties);
NodeGrpCfg::proceed(pNode, lContext);
}
};
} // namespace Download
} // namespace ParamOutputImpl
} // namespace AMDA
#endif /* PARAMNODE_HH_ */