Blame view

src/Info/StatusDefNode.cc 2.02 KB
fbe3c2bb   Benjamin Renard   First commit
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
/**
 * StatusDefNode.cc
 *
 *  Created on: 13 jan. 2015
 *      Author: AKKA
 */

#include <sstream>
#include <algorithm>
#include <boost/shared_ptr.hpp>

#include "StatusDefNode.hh"

#include "Config.hh"
#include "Parameter.hh"
#include "ParamInfo.hh"
#include "Constant.hh"

using namespace log4cxx;
using namespace AMDA::Parameters;
using namespace AMDA::XMLConfigurator;

namespace AMDA {
namespace Info {

class StatusInfoNode: public AMDA::XMLConfigurator::NodeCfg {
public:
	void proceed( xmlNodePtr pNode, const AMDA::Parameters::CfgContext& context) {
		LOG4CXX_DEBUG(gLogger, "StatusInfoNode::proceed");

		ParamInfo* pParamInfo =  context.get<ParamInfo*>();

		//Get min value
		xmlChar* value = xmlGetProp(pNode, (const xmlChar *) "minVal");
		double minVal = 0.0;
		if (value != NULL)
		{
			minVal = std::atof((const char*)value);
			xmlFree(value);
		}

		//Get max value
		value = xmlGetProp(pNode, (const xmlChar *) "maxVal");
		double maxVal = 0.0;
		if (value != NULL)
		{
			maxVal = std::atof((const char*)value);
			xmlFree(value);
		}
		else
			maxVal = minVal;

		//Get name
		value = xmlGetProp(pNode, (const xmlChar *) "name");
		std::string name = "";
		if (value != NULL)
		{
			name = std::string((const char*)value);
			xmlFree(value);
		}

7f62f27f   Benjamin Renard   Add the possibili...
62
63
64
65
66
67
68
69
70
71
		//Get color
		value = xmlGetProp(pNode, (const xmlChar *) "color");
		std::string color = "";
		if (value != NULL)
		{
			color = std::string((const char*)value);
			xmlFree(value);
		}

		pParamInfo->addStatus(minVal,maxVal,name, color);
fbe3c2bb   Benjamin Renard   First commit
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
	}
};

StatusDefNode::StatusDefNode() : AMDA::XMLConfigurator::NodeGrpCfg()
{
	getChildList()["status"]=NodeCfgSPtr(new StatusInfoNode);
}

StatusDefNode::~StatusDefNode()
{
}

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

	AMDA::Parameters::CfgContext lContext(pContext);
	ParamInfo* pParamInfo =  pContext.get<ParamInfo*>();
	lContext.push<ParamInfo *>(pParamInfo);

	NodeGrpCfg::proceed(pNode, lContext);
}

}/* namespace Info */
} /* namespace AMDA */