SUMO - Simulation of Urban MObility
NBTypeCont.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
21 // A storage for available types of edges
22 /****************************************************************************/
23 #ifndef NBTypeCont_h
24 #define NBTypeCont_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <map>
39 #include <netbuild/NBEdge.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class OutputDevice;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
61 class NBTypeCont {
62 public:
65 
66 
69 
70 
78  void setDefaults(int defaultNumLanes, double defaultLaneWidth,
79  double defaultSpeed, int defaultPriority,
80  SVCPermissions defaultPermissions);
81 
82 
93  void insert(const std::string& id, int numLanes,
94  double maxSpeed, int prio,
95  SVCPermissions permissions,
96  double width, bool oneWayIsDefault,
97  double sidewalkWidth,
98  double bikeLaneWidth);
99 
103  int size() const {
104  return (int) myTypes.size();
105  }
106 
107 
111  bool knows(const std::string& type) const;
112 
113 
117  bool markAsToDiscard(const std::string& id);
118 
123  bool markAsSet(const std::string& id, const SumoXMLAttr attr);
124 
130  bool addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
131 
136  bool copyRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
137 
139  void writeTypes(OutputDevice& into) const;
140 
143 
150  int getNumLanes(const std::string& type) const;
151 
152 
159  double getSpeed(const std::string& type) const;
160 
161 
168  int getPriority(const std::string& type) const;
169 
170 
178  bool getIsOneWay(const std::string& type) const;
179 
180 
187  bool getShallBeDiscarded(const std::string& type) const;
188 
189 
195  bool wasSet(const std::string& type, const SumoXMLAttr attr) const;
196 
197 
204  SVCPermissions getPermissions(const std::string& type) const;
205 
206 
213  double getWidth(const std::string& type) const;
214 
215 
222  double getSidewalkWidth(const std::string& type) const;
223 
224 
231  double getBikeLaneWidth(const std::string& type) const;
233 
234 
235 private:
236  struct TypeDefinition {
239  numLanes(1), speed((double) 13.9), priority(-1),
240  permissions(SVC_UNSPECIFIED),
241  oneWay(true), discard(false),
242  width(NBEdge::UNSPECIFIED_WIDTH),
243  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
244  bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
245  }
246 
248  TypeDefinition(int _numLanes, double _speed, int _priority,
249  double _width, SVCPermissions _permissions, bool _oneWay,
250  double _sideWalkWidth,
251  double _bikeLaneWidth) :
252  numLanes(_numLanes), speed(_speed), priority(_priority),
253  permissions(_permissions),
254  oneWay(_oneWay), discard(false), width(_width),
255  sidewalkWidth(_sideWalkWidth),
256  bikeLaneWidth(_bikeLaneWidth) {
257  }
258 
260  int numLanes;
262  double speed;
264  int priority;
268  bool oneWay;
270  bool discard;
272  double width;
273  /* @brief The width of the sidewalk that should be added as an additional lane
274  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
276  /* @brief The width of the bike lane that should be added as an additional lane
277  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
280  std::map<SUMOVehicleClass, double> restrictions;
282  std::set<SumoXMLAttr> attrs;
283 
284  };
285 
286 
293  const TypeDefinition& getType(const std::string& name) const;
294 
295 
296 private:
299 
301  typedef std::map<std::string, TypeDefinition> TypesCont;
302 
304  TypesCont myTypes;
305 
306 
307 private:
309  NBTypeCont(const NBTypeCont& s);
310 
312  NBTypeCont& operator=(const NBTypeCont& s);
313 
314 
315 };
316 
317 
318 #endif
319 
320 /****************************************************************************/
321 
void insert(const std::string &id, int numLanes, double maxSpeed, int prio, SVCPermissions permissions, double width, bool oneWayIsDefault, double sidewalkWidth, double bikeLaneWidth)
Adds a type into the list.
Definition: NBTypeCont.cpp:60
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:282
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:180
~NBTypeCont()
Destructor.
Definition: NBTypeCont.h:68
int numLanes
The number of lanes of an edge.
Definition: NBTypeCont.h:260
std::map< std::string, TypeDefinition > TypesCont
A container of types, accessed by the string id.
Definition: NBTypeCont.h:301
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
NBTypeCont & operator=(const NBTypeCont &s)
invalid assignment operator
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
NBTypeCont()
Constructor.
Definition: NBTypeCont.h:64
The representation of a single edge during network building.
Definition: NBEdge.h:70
TypeDefinition(int _numLanes, double _speed, int _priority, double _width, SVCPermissions _permissions, bool _oneWay, double _sideWalkWidth, double _bikeLaneWidth)
Constructor.
Definition: NBTypeCont.h:248
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:186
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
Definition: NBTypeCont.cpp:91
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:174
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:198
bool oneWay
Whether one-way traffic is mostly common for this type (mostly unused)
Definition: NBTypeCont.h:268
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:216
const TypeDefinition & getType(const std::string &name) const
Retrieve the name or the default type.
Definition: NBTypeCont.cpp:234
bool addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to a type.
Definition: NBTypeCont.cpp:102
TypeDefinition()
Constructor.
Definition: NBTypeCont.h:238
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:74
double getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:228
double getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:222
void setDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
Definition: NBTypeCont.cpp:46
double width
The width of lanes of edges of this type [m].
Definition: NBTypeCont.h:272
bool markAsToDiscard(const std::string &id)
Marks a type as to be discarded.
Definition: NBTypeCont.cpp:80
TypeDefinition myDefaultType
The default type.
Definition: NBTypeCont.h:298
double speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:262
bool copyRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a type.
Definition: NBTypeCont.cpp:113
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:280
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
int priority
The priority of an edge.
Definition: NBTypeCont.h:264
SVCPermissions permissions
List of vehicle types that are allowed on this edge.
Definition: NBTypeCont.h:266
bool getIsOneWay(const std::string &type) const
Returns whether edges are one-way per default for the given type.
Definition: NBTypeCont.cpp:192
TypesCont myTypes
The container of types.
Definition: NBTypeCont.h:304
int size() const
Returns the number of known types.
Definition: NBTypeCont.h:103
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
bool wasSet(const std::string &type, const SumoXMLAttr attr) const
Returns whether an attribute of a type was set.
Definition: NBTypeCont.cpp:204
bool discard
Whether edges of this type shall be discarded.
Definition: NBTypeCont.h:270
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:210
A storage for available types of edges.
Definition: NBTypeCont.h:61
void writeTypes(OutputDevice &into) const
writes all types a s XML
Definition: NBTypeCont.cpp:126