SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NBTypeCont.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // A storage for available types of edges
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef NBTypeCont_h
25 #define NBTypeCont_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <string>
38 #include <map>
39 #include "NBNode.h"
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
56 class NBTypeCont {
57 public:
60 
61 
64 
65 
71  void setDefaults(int defaultNoLanes,
72  SUMOReal defaultSpeed, int defaultPriority);
73 
74 
86  bool insert(const std::string& id, int noLanes, SUMOReal maxSpeed, int prio,
87  SUMOReal width, SUMOVehicleClass vClasses = SVC_IGNORING, bool oneWayIsDefault = false,
88  SUMOReal sidewalkWidth = NBEdge::UNSPECIFIED_WIDTH);
89 
100  bool insert(const std::string& id, int noLanes,
101  SUMOReal maxSpeed, int prio,
102  SVCPermissions permissions,
103  SUMOReal width, bool oneWayIsDefault,
104  SUMOReal sidewalkWidth);
105 
109  unsigned int size() const {
110  return (unsigned int) myTypes.size();
111  }
112 
113 
117  bool knows(const std::string& type) const;
118 
119 
123  bool markAsToDiscard(const std::string& id);
124 
125 
126 
129 
136  int getNumLanes(const std::string& type) const;
137 
138 
145  SUMOReal getSpeed(const std::string& type) const;
146 
147 
154  int getPriority(const std::string& type) const;
155 
156 
164  bool getIsOneWay(const std::string& type) const;
165 
166 
172  bool getShallBeDiscarded(const std::string& type) const;
173 
174 
181  SVCPermissions getPermissions(const std::string& type) const;
182 
183 
190  SUMOReal getWidth(const std::string& type) const;
191 
192 
199  SUMOReal getSidewalkWidth(const std::string& type) const;
201 
202 
203 private:
204  struct TypeDefinition {
207  noLanes(1), speed((SUMOReal) 13.9), priority(-1),
209  oneWay(true), discard(false),
210  width(NBEdge::UNSPECIFIED_WIDTH),
211  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH)
212  { }
213 
215  TypeDefinition(int _noLanes, SUMOReal _speed, int _priority,
216  SUMOReal _width, SVCPermissions _permissions, bool _oneWay,
217  SUMOReal _sideWalkWidth) :
218  noLanes(_noLanes), speed(_speed), priority(_priority),
219  permissions(_permissions),
220  oneWay(_oneWay), discard(false), width(_width),
221  sidewalkWidth(_sideWalkWidth)
222  { }
223 
225  int noLanes;
229  int priority;
233  bool oneWay;
235  bool discard;
238  /* @brief The width of the sidewalk that should be added as an additional lane
239  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
241 
242  };
243 
244 
251  const TypeDefinition& getType(const std::string& name) const;
252 
253 
254 private:
257 
259  typedef std::map<std::string, TypeDefinition> TypesCont;
260 
262  TypesCont myTypes;
263 
264 
265 private:
267  NBTypeCont(const NBTypeCont& s);
268 
270  NBTypeCont& operator=(const NBTypeCont& s);
271 
272 
273 };
274 
275 
276 #endif
277 
278 /****************************************************************************/
279 
int noLanes
The number of lanes of an edge.
Definition: NBTypeCont.h:225
~NBTypeCont()
Destructor.
Definition: NBTypeCont.h:63
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:201
std::map< std::string, TypeDefinition > TypesCont
A container of types, accessed by the string id.
Definition: NBTypeCont.h:259
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
NBTypeCont & operator=(const NBTypeCont &s)
invalid assignment operator
const TypeDefinition & getType(const std::string &name) const
Retrieve the name or the default type.
Definition: NBTypeCont.cpp:146
SUMOReal width
The width of lanes of edges of this type [m].
Definition: NBTypeCont.h:237
int SVCPermissions
NBTypeCont()
Constructor.
Definition: NBTypeCont.h:59
The representation of a single edge during network building.
Definition: NBEdge.h:71
bool getIsOneWay(const std::string &type) const
Returns whether edges are one-way per default for the given type.
Definition: NBTypeCont.cpp:116
SUMOReal speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:227
const SVCPermissions SVCAll
bool oneWay
Whether one-way traffic is mostly common for this type (mostly unused)
Definition: NBTypeCont.h:233
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:134
SUMOReal getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:140
TypeDefinition()
Constructor.
Definition: NBTypeCont.h:206
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:104
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:98
void setDefaults(int defaultNoLanes, SUMOReal defaultSpeed, int defaultPriority)
Sets the default values.
Definition: NBTypeCont.cpp:50
unsigned int size() const
Returns the number of known types.
Definition: NBTypeCont.h:109
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:110
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:80
bool insert(const std::string &id, int noLanes, SUMOReal maxSpeed, int prio, SUMOReal width, SUMOVehicleClass vClasses=SVC_IGNORING, bool oneWayIsDefault=false, SUMOReal sidewalkWidth=NBEdge::UNSPECIFIED_WIDTH)
Adds a type into the list. This is a simplified convenience form of insert, if only one allowed vehic...
Definition: NBTypeCont.cpp:60
bool markAsToDiscard(const std::string &id)
Marks a type as to be discarded.
Definition: NBTypeCont.cpp:86
TypeDefinition myDefaultType
The default type.
Definition: NBTypeCont.h:256
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:122
#define SUMOReal
Definition: config.h:218
TypeDefinition(int _noLanes, SUMOReal _speed, int _priority, SUMOReal _width, SVCPermissions _permissions, bool _oneWay, SUMOReal _sideWalkWidth)
Constructor.
Definition: NBTypeCont.h:215
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:128
int priority
The priority of an edge.
Definition: NBTypeCont.h:229
SVCPermissions permissions
List of vehicle types that are allowed on this edge.
Definition: NBTypeCont.h:231
TypesCont myTypes
The container of types.
Definition: NBTypeCont.h:262
vehicles ignoring classes
bool discard
Whether edges of this type shall be discarded.
Definition: NBTypeCont.h:235
A storage for available types of edges.
Definition: NBTypeCont.h:56