SUMO - Simulation of Urban MObility
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 
78  void setDefaults(int defaultNumLanes, SUMOReal defaultLaneWidth,
79  SUMOReal defaultSpeed, int defaultPriority);
80 
81 
92  void insert(const std::string& id, int numLanes,
93  SUMOReal maxSpeed, int prio,
94  SVCPermissions permissions,
95  SUMOReal width, bool oneWayIsDefault,
96  SUMOReal sidewalkWidth,
97  SUMOReal bikeLaneWidth);
98 
102  int size() const {
103  return (int) myTypes.size();
104  }
105 
106 
110  bool knows(const std::string& type) const;
111 
112 
116  bool markAsToDiscard(const std::string& id);
117 
122  bool markAsSet(const std::string& id, const SumoXMLAttr attr);
123 
129  bool addRestriction(const std::string& id, const SUMOVehicleClass svc, const SUMOReal speed);
130 
135  bool copyRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
136 
138  void writeTypes(OutputDevice& into) const;
139 
142 
149  int getNumLanes(const std::string& type) const;
150 
151 
158  SUMOReal getSpeed(const std::string& type) const;
159 
160 
167  int getPriority(const std::string& type) const;
168 
169 
177  bool getIsOneWay(const std::string& type) const;
178 
179 
186  bool getShallBeDiscarded(const std::string& type) const;
187 
188 
194  bool wasSet(const std::string& type, const SumoXMLAttr attr) const;
195 
196 
203  SVCPermissions getPermissions(const std::string& type) const;
204 
205 
212  SUMOReal getWidth(const std::string& type) const;
213 
214 
221  SUMOReal getSidewalkWidth(const std::string& type) const;
222 
223 
230  SUMOReal getBikeLaneWidth(const std::string& type) const;
232 
233 
234 private:
235  struct TypeDefinition {
238  numLanes(1), speed((SUMOReal) 13.9), priority(-1),
239  permissions(SVC_UNSPECIFIED),
240  oneWay(true), discard(false),
241  width(NBEdge::UNSPECIFIED_WIDTH),
242  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
243  bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
244  }
245 
247  TypeDefinition(int _numLanes, SUMOReal _speed, int _priority,
248  SUMOReal _width, SVCPermissions _permissions, bool _oneWay,
249  SUMOReal _sideWalkWidth,
250  SUMOReal _bikeLaneWidth) :
251  numLanes(_numLanes), speed(_speed), priority(_priority),
252  permissions(_permissions),
253  oneWay(_oneWay), discard(false), width(_width),
254  sidewalkWidth(_sideWalkWidth),
255  bikeLaneWidth(_bikeLaneWidth) {
256  }
257 
259  int numLanes;
263  int priority;
267  bool oneWay;
269  bool discard;
272  /* @brief The width of the sidewalk that should be added as an additional lane
273  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
275  /* @brief The width of the bike lane that should be added as an additional lane
276  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
279  std::map<SUMOVehicleClass, SUMOReal> restrictions;
281  std::set<SumoXMLAttr> attrs;
282 
283  };
284 
285 
292  const TypeDefinition& getType(const std::string& name) const;
293 
294 
295 private:
298 
300  typedef std::map<std::string, TypeDefinition> TypesCont;
301 
303  TypesCont myTypes;
304 
305 
306 private:
308  NBTypeCont(const NBTypeCont& s);
309 
311  NBTypeCont& operator=(const NBTypeCont& s);
312 
313 
314 };
315 
316 
317 #endif
318 
319 /****************************************************************************/
320 
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:281
~NBTypeCont()
Destructor.
Definition: NBTypeCont.h:69
int numLanes
The number of lanes of an edge.
Definition: NBTypeCont.h:259
bool wasSet(const std::string &type, const SumoXMLAttr attr) const
Returns whether an attribute of a type was set.
Definition: NBTypeCont.cpp:207
std::map< std::string, TypeDefinition > TypesCont
A container of types, accessed by the string id.
Definition: NBTypeCont.h:300
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:237
SUMOReal width
The width of lanes of edges of this type [m].
Definition: NBTypeCont.h:271
int SVCPermissions
NBTypeCont()
Constructor.
Definition: NBTypeCont.h:65
The representation of a single edge during network building.
Definition: NBEdge.h:70
bool getIsOneWay(const std::string &type) const
Returns whether edges are one-way per default for the given type.
Definition: NBTypeCont.cpp:195
SUMOReal speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:261
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
Definition: NBTypeCont.cpp:94
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
bool oneWay
Whether one-way traffic is mostly common for this type (mostly unused)
Definition: NBTypeCont.h:267
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:219
SUMOReal getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:225
TypeDefinition()
Constructor.
Definition: NBTypeCont.h:237
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:183
SUMOReal getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:231
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:177
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:189
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:77
void setDefaults(int defaultNumLanes, SUMOReal defaultLaneWidth, SUMOReal defaultSpeed, int defaultPriority)
Sets the default values.
Definition: NBTypeCont.cpp:51
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:63
void writeTypes(OutputDevice &into) const
writes all types a s XML
Definition: NBTypeCont.cpp:129
bool markAsToDiscard(const std::string &id)
Marks a type as to be discarded.
Definition: NBTypeCont.cpp:83
int size() const
Returns the number of known types.
Definition: NBTypeCont.h:102
TypeDefinition myDefaultType
The default type.
Definition: NBTypeCont.h:297
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:201
bool copyRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a type.
Definition: NBTypeCont.cpp:116
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:213
int priority
The priority of an edge.
Definition: NBTypeCont.h:263
SVCPermissions permissions
List of vehicle types that are allowed on this edge.
Definition: NBTypeCont.h:265
std::map< SUMOVehicleClass, SUMOReal > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:279
TypesCont myTypes
The container of types.
Definition: NBTypeCont.h:303
bool addRestriction(const std::string &id, const SUMOVehicleClass svc, const SUMOReal speed)
Adds a restriction to a type.
Definition: NBTypeCont.cpp:105
const SVCPermissions SVC_UNSPECIFIED
bool discard
Whether edges of this type shall be discarded.
Definition: NBTypeCont.h:269
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:247