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
NBTypeCont.cpp
Go to the documentation of this file.
1
/****************************************************************************/
10
// A storage for the available types of an edge
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
14
/****************************************************************************/
15
//
16
// This file is part of SUMO.
17
// SUMO is free software: you can redistribute it and/or modify
18
// it under the terms of the GNU General Public License as published by
19
// the Free Software Foundation, either version 3 of the License, or
20
// (at your option) any later version.
21
//
22
/****************************************************************************/
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <string>
35
#include <map>
36
#include <iostream>
37
#include <
utils/common/MsgHandler.h
>
38
#include <
utils/common/ToString.h
>
39
#include "
NBTypeCont.h
"
40
41
#ifdef CHECK_MEMORY_LEAKS
42
#include <
foreign/nvwa/debug_new.h
>
43
#endif // CHECK_MEMORY_LEAKS
44
45
46
// ===========================================================================
47
// method definitions
48
// ===========================================================================
49
void
50
NBTypeCont::setDefaults
(
int
defaultNoLanes,
51
SUMOReal
defaultSpeed,
52
int
defaultPriority) {
53
myDefaultType
.
noLanes
= defaultNoLanes;
54
myDefaultType
.
speed
= defaultSpeed;
55
myDefaultType
.
priority
= defaultPriority;
56
}
57
58
59
bool
60
NBTypeCont::insert
(
const
std::string&
id
,
int
noLanes,
SUMOReal
maxSpeed,
int
prio,
61
SUMOReal
width,
SUMOVehicleClass
vClass,
bool
oneWayIsDefault) {
62
SVCPermissions
permissions = (vClass ==
SVC_UNKNOWN
?
SVCFreeForAll
: vClass);
63
return
insert
(
id
, noLanes, maxSpeed, prio, permissions, width, oneWayIsDefault);
64
}
65
66
67
bool
68
NBTypeCont::insert
(
const
std::string&
id
,
int
noLanes,
SUMOReal
maxSpeed,
int
prio,
69
SVCPermissions
permissions,
SUMOReal
width,
bool
oneWayIsDefault) {
70
TypesCont::iterator i =
myTypes
.find(
id
);
71
if
(i !=
myTypes
.end()) {
72
return
false
;
73
}
74
myTypes
[id] =
TypeDefinition
(noLanes, maxSpeed, prio, width, permissions, oneWayIsDefault);
75
return
true
;
76
}
77
78
79
bool
80
NBTypeCont::knows
(
const
std::string& type)
const
{
81
return
myTypes
.find(type) !=
myTypes
.end();
82
}
83
84
85
bool
86
NBTypeCont::markAsToDiscard
(
const
std::string&
id
) {
87
TypesCont::iterator i =
myTypes
.find(
id
);
88
if
(i ==
myTypes
.end()) {
89
return
false
;
90
}
91
(*i).second.discard =
true
;
92
return
true
;
93
}
94
95
96
// ------------ Type-dependant Retrieval methods
97
int
98
NBTypeCont::getNumLanes
(
const
std::string& type)
const
{
99
return
getType
(type).
noLanes
;
100
}
101
102
103
SUMOReal
104
NBTypeCont::getSpeed
(
const
std::string& type)
const
{
105
return
getType
(type).
speed
;
106
}
107
108
109
int
110
NBTypeCont::getPriority
(
const
std::string& type)
const
{
111
return
getType
(type).
priority
;
112
}
113
114
115
bool
116
NBTypeCont::getIsOneWay
(
const
std::string& type)
const
{
117
return
getType
(type).
oneWay
;
118
}
119
120
121
bool
122
NBTypeCont::getShallBeDiscarded
(
const
std::string& type)
const
{
123
return
getType
(type).
discard
;
124
}
125
126
127
SVCPermissions
128
NBTypeCont::getPermissions
(
const
std::string& type)
const
{
129
return
getType
(type).
permissions
;
130
}
131
132
133
SUMOReal
134
NBTypeCont::getWidth
(
const
std::string& type)
const
{
135
return
getType
(type).
width
;
136
}
137
138
139
const
NBTypeCont::TypeDefinition
&
140
NBTypeCont::getType
(
const
std::string& name)
const
{
141
TypesCont::const_iterator i =
myTypes
.find(name);
142
if
(i ==
myTypes
.end()) {
143
return
myDefaultType
;
144
}
145
return
(*i).second;
146
}
147
148
/****************************************************************************/
149
home
gladk
tmp
05
sumo-0.17.1~dfsg
src
netbuild
NBTypeCont.cpp
Generated on Sun Jun 16 2013 07:07:54 for SUMO - Simulation of Urban MObility by
1.8.1.2