SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
NIVissimTrafficDescription.cpp
Go to the documentation of this file.
1
/****************************************************************************/
7
// -------------------
8
/****************************************************************************/
9
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
11
/****************************************************************************/
12
//
13
// This file is part of SUMO.
14
// SUMO is free software: you can redistribute it and/or modify
15
// it under the terms of the GNU General Public License as published by
16
// the Free Software Foundation, either version 3 of the License, or
17
// (at your option) any later version.
18
//
19
/****************************************************************************/
20
21
22
// ===========================================================================
23
// included modules
24
// ===========================================================================
25
#ifdef _MSC_VER
26
#include <
windows_config.h
>
27
#else
28
#include <
config.h
>
29
#endif
30
31
#include <string>
32
#include <map>
33
#include <cassert>
34
#include "
NIVissimVehicleClassVector.h
"
35
#include "
NIVissimTrafficDescription.h
"
36
37
#ifdef CHECK_MEMORY_LEAKS
38
#include <
foreign/nvwa/debug_new.h
>
39
#endif // CHECK_MEMORY_LEAKS
40
41
42
// ===========================================================================
43
// member function definitions
44
// ===========================================================================
45
NIVissimTrafficDescription::DictType
NIVissimTrafficDescription::myDict
;
46
47
48
// ===========================================================================
49
// member method definitions
50
// ===========================================================================
51
NIVissimTrafficDescription::NIVissimTrafficDescription
(
52
int
id
,
const
std::string& name,
53
const
NIVissimVehicleClassVector
& vehicleTypes)
54
: myID(id), myName(name), myVehicleTypes(vehicleTypes) {}
55
56
57
NIVissimTrafficDescription::~NIVissimTrafficDescription
() {
58
for
(NIVissimVehicleClassVector::iterator i =
myVehicleTypes
.begin(); i !=
myVehicleTypes
.end(); i++) {
59
delete
*i;
60
}
61
myVehicleTypes
.clear();
62
}
63
64
65
bool
66
NIVissimTrafficDescription::dictionary
(
int
id
,
67
const
std::string& name,
68
const
NIVissimVehicleClassVector
& vehicleTypes) {
69
NIVissimTrafficDescription
* o =
new
NIVissimTrafficDescription
(
id
, name, vehicleTypes);
70
if
(!
dictionary
(
id
, o)) {
71
delete
o;
72
return
false
;
73
}
74
return
true
;
75
}
76
77
78
bool
79
NIVissimTrafficDescription::dictionary
(
int
id
,
NIVissimTrafficDescription
* o) {
80
DictType::iterator i =
myDict
.find(
id
);
81
if
(i ==
myDict
.end()) {
82
myDict
[id] = o;
83
return
true
;
84
}
85
return
false
;
86
}
87
88
89
NIVissimTrafficDescription
*
90
NIVissimTrafficDescription::dictionary
(
int
id
) {
91
DictType::iterator i =
myDict
.find(
id
);
92
if
(i ==
myDict
.end()) {
93
return
0;
94
}
95
return
(*i).second;
96
}
97
98
99
void
100
NIVissimTrafficDescription::clearDict
() {
101
for
(DictType::iterator i =
myDict
.begin(); i !=
myDict
.end(); i++) {
102
delete
(*i).second;
103
}
104
myDict
.clear();
105
}
106
107
108
109
110
SUMOReal
111
NIVissimTrafficDescription::meanSpeed
(
int
id
) {
112
NIVissimTrafficDescription
* i =
dictionary
(
id
);
113
assert(i != 0);
114
return
i->
meanSpeed
();
115
}
116
117
118
SUMOReal
119
NIVissimTrafficDescription::meanSpeed
()
const
{
120
SUMOReal
speed = 0;
121
for
(NIVissimVehicleClassVector::const_iterator i =
myVehicleTypes
.begin(); i !=
myVehicleTypes
.end(); i++) {
122
speed += (*i)->getSpeed();
123
}
124
return
speed / (
SUMOReal
)
myVehicleTypes
.size();
125
}
126
127
128
129
/****************************************************************************/
130
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
netimport
vissim
tempstructs
NIVissimTrafficDescription.cpp
Generated on Mon Mar 24 2014 09:53:13 for SUMO - Simulation of Urban MObility by
1.8.1.2