NodeCfg.hh
1.64 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
/**
* CfgNode.hh
*
* Created on: 17 oct. 2012
* Author: AKKA IS
*/
#ifndef CFGNODE_HH_
#define CFGNODE_HH_
#include <string>
#include <map>
#include <boost/shared_ptr.hpp>
// XML include
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/xmlstring.h>
#include "FileConfigurator.hh"
namespace AMDA
{
namespace XMLConfigurator
{
/**
* Class CfgNode
* Description : Node configurator
*/
class NodeCfg
{
public:
virtual ~NodeCfg() {}
virtual void proceed(xmlNodePtr,const AMDA::Parameters::CfgContext& context) = 0;
static int getIsValid(const xmlNodePtr, const char* xsdFile);
};
typedef boost::shared_ptr<NodeCfg> NodeCfgSPtr;
typedef std::map<std::string, NodeCfgSPtr> CfgChildList;
class NodeGrpCfg : public NodeCfg {
public:
NodeGrpCfg() : NodeCfg() {}
virtual ~NodeGrpCfg() {
for (auto cfgChild : _cfgChildList) {
cfgChild.second.reset();
}
}
CfgChildList& getChildList() { return _cfgChildList; }
/**
* Add a node parser.
* @param xpath example "param/get/baseParam"
* @param node A NodeCfgSPtr to parse baseParam XML node
*/
void addNodeParser( const char* xpath, NodeCfgSPtr node);
void proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pCtx);
static void addNodeParser( CfgChildList* lChildList, const char* pXPath, NodeCfgSPtr pNode);
protected:
CfgChildList _cfgChildList;
};
} /* namespace XMLParameterConfigurator */
} /* namespace AMDA */
#endif /* CFGNODE_HH_ */