-
Notifications
You must be signed in to change notification settings - Fork 0
/
VehicleGeneratorXml.h
130 lines (102 loc) · 3.11 KB
/
VehicleGeneratorXml.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
/*
* File: VehicleGeneratorXml.h
* Author: bdupont
*
* Created on September 19, 2011, 8:39 PM
*/
#ifndef _VEHICLEGENERATORXML_H
#define _VEHICLEGENERATORXML_H
#include "tinyxml.h"
#include <map>
#include <utility>
#include <list>
using namespace std;
class VehicleGeneratorXml {
private:
int m_highwayId;
int m_wifiConfigId;
double m_flow;
double m_lowVelocity;
double m_highVelocity;
double m_minGap;
double m_penetrationRate;
list<pair<double, int> > m_destinationMap;
public:
double GetFlow() {
return m_flow;
}
void SetFlow(double flow) {
m_flow = flow;
}
int GetHighwayId() {
return m_highwayId;
}
void SetHighwayId(int highwayId) {
m_highwayId = highwayId;
}
double GetMinGap() {
return m_minGap;
}
void SetMinGap(double minGap) {
m_minGap = minGap;
}
double GetPenetrationRate() {
return m_penetrationRate;
}
void SetPenetrationRate(double penetrationRate) {
m_penetrationRate = penetrationRate;
}
double GetLowVelocity() {
return m_lowVelocity;
}
void SetLowVelocity(double lowVelocity) {
m_lowVelocity = lowVelocity;
}
double GetHighVelocity() {
return m_highVelocity;
}
void SetHighVelocity(double highVelocity) {
m_highVelocity = highVelocity;
}
int GetWifiConfigId() {
return m_wifiConfigId;
}
void SetWifiConfigId(int wifiConfigId) {
m_wifiConfigId = wifiConfigId;
}
list<pair<double, int> > GetDestinationMap() {
return m_destinationMap;
}
void SetDestinationMap(list<pair<double, int> > destinationMap) {
m_destinationMap = destinationMap;
}
void LoadFromXml(TiXmlHandle root) {
m_highwayId = -100000;
m_wifiConfigId = -10000;
m_flow = 1.0;
m_lowVelocity = 11.176;
m_highVelocity = 11.176;
m_minGap = 33.0;
m_penetrationRate = 100.0;
m_destinationMap = list<pair<double, int> >();
TiXmlElement* rootPtr = root.Element();
if (rootPtr) {
rootPtr->QueryIntAttribute("highwayId", &m_highwayId);
rootPtr->QueryIntAttribute("wifiConfigId", &m_wifiConfigId);
rootPtr->QueryDoubleAttribute("flow", &m_flow);
rootPtr->QueryDoubleAttribute("lowVelocity", &m_lowVelocity);
rootPtr->QueryDoubleAttribute("highVelocity", &m_highVelocity);
rootPtr->QueryDoubleAttribute("minGap", &m_minGap);
rootPtr->QueryDoubleAttribute("penetrationRate", &m_penetrationRate);
TiXmlHandle destHandle = root.FirstChildElement("destination");
double weight = 0.0;
int dest = -1;
for(TiXmlElement* destPtr = destHandle.Element(); destPtr; destPtr = destPtr->NextSiblingElement()) {
destPtr->QueryDoubleAttribute("weight", &weight);
destPtr->QueryIntAttribute("destinationId", &dest);
m_destinationMap.push_back(pair<double,int>(weight,dest));
}
}
}
};
#endif /* _VEHICLEGENERATORXML_H */