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-2016 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>
40 #include <netbuild/NBEdge.h>
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class OutputDevice;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
62 class NBTypeCont {
63 public:
66 
67 
70 
71 
79  void setDefaults(int defaultNumLanes, SUMOReal defaultLaneWidth,
80  SUMOReal defaultSpeed, int defaultPriority,
81  SVCPermissions defaultPermissions);
82 
83 
94  void insert(const std::string& id, int numLanes,
95  SUMOReal maxSpeed, int prio,
96  SVCPermissions permissions,
97  SUMOReal width, bool oneWayIsDefault,
98  SUMOReal sidewalkWidth,
99  SUMOReal bikeLaneWidth);
100 
104  int size() const {
105  return (int) myTypes.size();
106  }
107 
108 
112  bool knows(const std::string& type) const;
113 
114 
118  bool markAsToDiscard(const std::string& id);
119 
124  bool markAsSet(const std::string& id, const SumoXMLAttr attr);
125 
131  bool addRestriction(const std::string& id, const SUMOVehicleClass svc, const SUMOReal speed);
132 
137  bool copyRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
138 
140  void writeTypes(OutputDevice& into) const;
141 
144 
151  int getNumLanes(const std::string& type) const;
152 
153 
160  SUMOReal getSpeed(const std::string& type) const;
161 
162 
169  int getPriority(const std::string& type) const;
170 
171 
179  bool getIsOneWay(const std::string& type) const;
180 
181 
188  bool getShallBeDiscarded(const std::string& type) const;
189 
190 
196  bool wasSet(const std::string& type, const SumoXMLAttr attr) const;
197 
198 
205  SVCPermissions getPermissions(const std::string& type) const;
206 
207 
214  SUMOReal getWidth(const std::string& type) const;
215 
216 
223  SUMOReal getSidewalkWidth(const std::string& type) const;
224 
225 
232  SUMOReal getBikeLaneWidth(const std::string& type) const;
234 
235 
236 private:
237  struct TypeDefinition {
240  numLanes(1), speed((SUMOReal) 13.9), priority(-1),
242  oneWay(true), discard(false),
243  width(NBEdge::UNSPECIFIED_WIDTH),
244  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
245  bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
246  }
247 
249  TypeDefinition(int _numLanes, SUMOReal _speed, int _priority,
250  SUMOReal _width, SVCPermissions _permissions, bool _oneWay,
251  SUMOReal _sideWalkWidth,
252  SUMOReal _bikeLaneWidth) :
253  numLanes(_numLanes), speed(_speed), priority(_priority),
254  permissions(_permissions),
255  oneWay(_oneWay), discard(false), width(_width),
256  sidewalkWidth(_sideWalkWidth),
257  bikeLaneWidth(_bikeLaneWidth) {
258  }
259 
261  int numLanes;
265  int priority;
269  bool oneWay;
271  bool discard;
274  /* @brief The width of the sidewalk that should be added as an additional lane
275  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
277  /* @brief The width of the bike lane that should be added as an additional lane
278  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
281  std::map<SUMOVehicleClass, SUMOReal> restrictions;
283  std::set<SumoXMLAttr> attrs;
284 
285  };
286 
287 
294  const TypeDefinition& getType(const std::string& name) const;
295 
296 
297 private:
300 
302  typedef std::map<std::string, TypeDefinition> TypesCont;
303 
305  TypesCont myTypes;
306 
307 
308 private:
310  NBTypeCont(const NBTypeCont& s);
311 
313  NBTypeCont& operator=(const NBTypeCont& s);
314 
315 
316 };
317 
318 
319 #endif
320 
321 /****************************************************************************/
322 
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:283
~NBTypeCont()
Destructor.
Definition: NBTypeCont.h:69
int numLanes
The number of lanes of an edge.
Definition: NBTypeCont.h:261
bool wasSet(const std::string &type, const SumoXMLAttr attr) const
Returns whether an attribute of a type was set.
Definition: NBTypeCont.cpp:209
std::map< std::string, TypeDefinition > TypesCont
A container of types, accessed by the string id.
Definition: NBTypeCont.h:302
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:239
SUMOReal width
The width of lanes of edges of this type [m].
Definition: NBTypeCont.h:273
int SVCPermissions
NBTypeCont()
Constructor.
Definition: NBTypeCont.h:65
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:197
SUMOReal speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:263
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
Definition: NBTypeCont.cpp:96
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void setDefaults(int defaultNumLanes, SUMOReal defaultLaneWidth, SUMOReal defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
Definition: NBTypeCont.cpp:51
bool oneWay
Whether one-way traffic is mostly common for this type (mostly unused)
Definition: NBTypeCont.h:269
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:221
SUMOReal getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:227
TypeDefinition()
Constructor.
Definition: NBTypeCont.h:239
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:185
SUMOReal getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:233
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:179
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:191
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:79
void insert(const std::string &id, int numLanes, SUMOReal maxSpeed, int prio, SVCPermissions permissions, SUMOReal width, bool oneWayIsDefault, SUMOReal sidewalkWidth, SUMOReal bikeLaneWidth)
Adds a type into the list.
Definition: NBTypeCont.cpp:65
void writeTypes(OutputDevice &into) const
writes all types a s XML
Definition: NBTypeCont.cpp:131
bool markAsToDiscard(const std::string &id)
Marks a type as to be discarded.
Definition: NBTypeCont.cpp:85
int size() const
Returns the number of known types.
Definition: NBTypeCont.h:104
TypeDefinition myDefaultType
The default type.
Definition: NBTypeCont.h:299
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:203
bool copyRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a type.
Definition: NBTypeCont.cpp:118
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:215
int priority
The priority of an edge.
Definition: NBTypeCont.h:265
SVCPermissions permissions
List of vehicle types that are allowed on this edge.
Definition: NBTypeCont.h:267
std::map< SUMOVehicleClass, SUMOReal > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:281
TypesCont myTypes
The container of types.
Definition: NBTypeCont.h:305
bool addRestriction(const std::string &id, const SUMOVehicleClass svc, const SUMOReal speed)
Adds a restriction to a type.
Definition: NBTypeCont.cpp:107
const SVCPermissions SVC_UNSPECIFIED
bool discard
Whether edges of this type shall be discarded.
Definition: NBTypeCont.h:271
A storage for available types of edges.
Definition: NBTypeCont.h:62
TypeDefinition(int _numLanes, SUMOReal _speed, int _priority, SUMOReal _width, SVCPermissions _permissions, bool _oneWay, SUMOReal _sideWalkWidth, SUMOReal _bikeLaneWidth)
Constructor.
Definition: NBTypeCont.h:249