-
Notifications
You must be signed in to change notification settings - Fork 0
/
HighwayXml.h
224 lines (182 loc) · 6.86 KB
/
HighwayXml.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*
* File: HighwayXml.h
* Author: bdupont
*
* Created on September 19, 2011, 8:33 PM
*/
#ifndef _HIGHWAYXML_H
#define _HIGHWAYXML_H
#include <iostream>
#include <list>
#include "tinyxml.h"
#include "HighwayConnectionXml.h"
using namespace std;
class HighwayXml {
private:
int m_highwayId;
int m_numberOfLanes;
double m_direction;
double m_length;
double m_startX;
double m_startY;
double m_leftTurnSpeed;
double m_rightTurnSpeed;
double m_laneWidth;
list<HighwayConnectionXml> m_frontHighways;
list<HighwayConnectionXml> m_backHighways;
list<HighwayConnectionXml> m_rightHighways;
list<HighwayConnectionXml> m_leftHighways;
public:
list<HighwayConnectionXml> GetBackHighways() {
return m_backHighways;
}
void SetBackHighways(list<HighwayConnectionXml> backHighways) {
m_backHighways = backHighways;
}
double GetDirection() {
return m_direction;
}
void SetDirection(double direction) {
m_direction = direction;
}
list<HighwayConnectionXml> GetFrontHighways() {
return m_frontHighways;
}
void SetFrontHighways(list<HighwayConnectionXml> frontHighways) {
m_frontHighways = frontHighways;
}
int GetHighwayId() {
return m_highwayId;
}
void SetHighwayId(int highwayId) {
m_highwayId = highwayId;
}
double GetLaneWidth() {
return m_laneWidth;
}
void SetLaneWidth(double laneWidth) {
m_laneWidth = laneWidth;
}
list<HighwayConnectionXml> GetLeftHighways() {
return m_leftHighways;
}
void SetLeftHighways(list<HighwayConnectionXml> leftHighways) {
m_leftHighways = leftHighways;
}
double GetLeftTurnSpeed() {
return m_leftTurnSpeed;
}
void SetLeftTurnSpeed(double leftTurnSpeed) {
m_leftTurnSpeed = leftTurnSpeed;
}
double GetLength() {
return m_length;
}
void SetLength(double length) {
m_length = length;
}
int GetNumberOfLanes() {
return m_numberOfLanes;
}
void SetNumberOfLanes(int numberOfLanes) {
m_numberOfLanes = numberOfLanes;
}
list<HighwayConnectionXml> GetRightHighways() {
return m_rightHighways;
}
void SetRightHighways(list<HighwayConnectionXml> rightHighways) {
m_rightHighways = rightHighways;
}
double GetRightTurnSpeed() {
return m_rightTurnSpeed;
}
void SetRightTurnSpeed(double rightTurnSpeed) {
m_rightTurnSpeed = rightTurnSpeed;
}
double GetStartX() {
return m_startX;
}
void SetStartX(double startX) {
m_startX = startX;
}
double GetStartY() {
return m_startY;
}
void SetStartY(double startY) {
m_startY = startY;
}
void LoadFromXml(TiXmlHandle root) {
m_highwayId = -100000;
m_numberOfLanes = 1;
m_direction = 0.0;
m_length = 1000;
m_startX = 0.0;
m_startY = 0.0;
m_leftTurnSpeed = 2.2352;
m_rightTurnSpeed = 2.2352;
m_laneWidth = 5.0;
m_frontHighways = list<HighwayConnectionXml>();
m_backHighways = list<HighwayConnectionXml>();
m_rightHighways = list<HighwayConnectionXml>();
m_leftHighways = list<HighwayConnectionXml>();
TiXmlElement* highwayRootPtr = root.Element();
highwayRootPtr->QueryIntAttribute("highwayId", &m_highwayId);
highwayRootPtr->QueryIntAttribute("numberOfLanes", &m_numberOfLanes);
highwayRootPtr->QueryDoubleAttribute("direction", &m_direction);
highwayRootPtr->QueryDoubleAttribute("length", &m_length);
highwayRootPtr->QueryDoubleAttribute("startX", &m_startX);
highwayRootPtr->QueryDoubleAttribute("startY", &m_startY);
highwayRootPtr->QueryDoubleAttribute("leftTurnSpeed", &m_leftTurnSpeed);
highwayRootPtr->QueryDoubleAttribute("rightTurnSpeed", &m_rightTurnSpeed);
highwayRootPtr->QueryDoubleAttribute("laneWidth", &m_laneWidth);
TiXmlHandle frontHighwaysRoot = root.FirstChildElement("frontHighways");
TiXmlElement* frontHighwaysRootPtr = frontHighwaysRoot.Element();
if(frontHighwaysRootPtr) {
TiXmlHandle connectionChild = TiXmlHandle(frontHighwaysRootPtr->FirstChildElement());
TiXmlElement* connectionChildPtr = connectionChild.Element();
for(;connectionChildPtr;connectionChildPtr = connectionChildPtr->NextSiblingElement()) {
TiXmlHandle connectionHandle = TiXmlHandle(connectionChildPtr);
HighwayConnectionXml connection;
connection.LoadFromXml(connectionHandle);
m_frontHighways.push_back(connection);
}
}
TiXmlHandle backHighwaysRoot = root.FirstChildElement("backHighways");
TiXmlElement* backHighwaysRootPtr = backHighwaysRoot.Element();
if(backHighwaysRootPtr) {
TiXmlHandle connectionChild = TiXmlHandle(backHighwaysRootPtr->FirstChildElement());
TiXmlElement* connectionChildPtr = connectionChild.Element();
for(;connectionChildPtr;connectionChildPtr = connectionChildPtr->NextSiblingElement()) {
TiXmlHandle connectionHandle = TiXmlHandle(connectionChildPtr);
HighwayConnectionXml connection;
connection.LoadFromXml(connectionHandle);
m_backHighways.push_back(connection);
}
}
TiXmlHandle rightHighwaysRoot = root.FirstChildElement("rightHighways");
TiXmlElement* rightHighwaysRootPtr = rightHighwaysRoot.Element();
if(rightHighwaysRootPtr) {
TiXmlHandle connectionChild = TiXmlHandle(rightHighwaysRootPtr->FirstChildElement());
TiXmlElement* connectionChildPtr = connectionChild.Element();
for(;connectionChildPtr;connectionChildPtr = connectionChildPtr->NextSiblingElement()) {
TiXmlHandle connectionHandle = TiXmlHandle(connectionChildPtr);
HighwayConnectionXml connection;
connection.LoadFromXml(connectionHandle);
m_rightHighways.push_back(connection);
}
}
TiXmlHandle leftHighwaysRoot = root.FirstChildElement("leftHighways");
TiXmlElement* leftHighwaysRootPtr = leftHighwaysRoot.Element();
if(leftHighwaysRootPtr) {
TiXmlHandle connectionChild = TiXmlHandle(leftHighwaysRootPtr->FirstChildElement());
TiXmlElement* connectionChildPtr = connectionChild.Element();
for(;connectionChildPtr;connectionChildPtr = connectionChildPtr->NextSiblingElement()) {
TiXmlHandle connectionHandle = TiXmlHandle(connectionChildPtr);
HighwayConnectionXml connection;
connection.LoadFromXml(connectionHandle);
m_leftHighways.push_back(connection);
}
}
}
};
#endif /* _HIGHWAYXML_H */