-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrafficLightGeneratorXml.h
80 lines (63 loc) · 1.97 KB
/
TrafficLightGeneratorXml.h
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
/*
* File: TrafficLightGeneratorXml.h
* Author: bdupont
*
* Created on September 25, 2011, 7:10 PM
*/
#ifndef _TRAFFICLIGHTGENERATORXML_H
#define _TRAFFICLIGHTGENERATORXML_H
#include "tinyxml.h"
#include "TrafficPointXml.h"
#include <list>
class TrafficLightGeneratorXml {
private:
list<TrafficPointXml> m_trafficPoints;
double m_timeLeft;
double m_timeStraight;
double m_timeBuffer;
public:
double GetTimeBuffer() const {
return m_timeBuffer;
}
void SetTimeBuffer(double timeBuffer) {
this->m_timeBuffer = timeBuffer;
}
double GetTimeLeft() const {
return m_timeLeft;
}
void SetTimeLeft(double timeLeft) {
this->m_timeLeft = timeLeft;
}
double GetTimeStraight() const {
return m_timeStraight;
}
void SetTimeStraight(double timeStraight) {
this->m_timeStraight = timeStraight;
}
list<TrafficPointXml> GetTrafficPoints() {
return m_trafficPoints;
}
void SetTrafficPoints(list<TrafficPointXml> trafficPoints) {
m_trafficPoints = trafficPoints;
}
void LoadFromXml(TiXmlHandle root) {
m_timeLeft = 20.0;
m_timeStraight = 40.0;
m_timeBuffer = 5.0;
m_trafficPoints = list<TrafficPointXml>();
TiXmlElement* rootPtr = root.Element();
if(rootPtr) {
rootPtr->QueryDoubleAttribute("timeStraight", &m_timeStraight);
rootPtr->QueryDoubleAttribute("timeLeft", &m_timeLeft);
rootPtr->QueryDoubleAttribute("timeBuffer", &m_timeBuffer);
TiXmlHandle trafficPointHandle = root.FirstChildElement("trafficPoint");
for(TiXmlElement* tpEle = trafficPointHandle.Element(); tpEle; tpEle = tpEle->NextSiblingElement()) {
TrafficPointXml tp;
TiXmlHandle tpHandle(tpEle);
tp.LoadFromXml(tpHandle);
m_trafficPoints.push_back(tp);
}
}
}
};
#endif /* _TRAFFICLIGHTGENERATORXML_H */