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-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>
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 
77  void setDefaults(int defaultNumLanes,
78  SUMOReal defaultSpeed, int defaultPriority);
79 
80 
91  void insert(const std::string& id, int numLanes,
92  SUMOReal maxSpeed, int prio,
93  SVCPermissions permissions,
94  SUMOReal width, bool oneWayIsDefault,
95  SUMOReal sidewalkWidth,
96  SUMOReal bikeLaneWidth);
97 
101  unsigned int size() const {
102  return (unsigned int) myTypes.size();
103  }
104 
105 
109  bool knows(const std::string& type) const;
110 
111 
115  bool markAsToDiscard(const std::string& id);
116 
121  bool markAsSet(const std::string& id, const SumoXMLAttr attr);
122 
128  bool addRestriction(const std::string& id, const SUMOVehicleClass svc, const SUMOReal speed);
129 
134  bool copyRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
135 
137  void writeTypes(OutputDevice& into) const;
138 
141 
148  int getNumLanes(const std::string& type) const;
149 
150 
157  SUMOReal getSpeed(const std::string& type) const;
158 
159 
166  int getPriority(const std::string& type) const;
167 
168 
176  bool getIsOneWay(const std::string& type) const;
177 
178 
185  bool getShallBeDiscarded(const std::string& type) const;
186 
187 
193  bool wasSet(const std::string& type, const SumoXMLAttr attr) const;
194 
195 
202  SVCPermissions getPermissions(const std::string& type) const;
203 
204 
211  SUMOReal getWidth(const std::string& type) const;
212 
213 
220  SUMOReal getSidewalkWidth(const std::string& type) const;
221 
222 
229  SUMOReal getBikeLaneWidth(const std::string& type) const;
231 
232 
233 private:
234  struct TypeDefinition {
237  numLanes(1), speed((SUMOReal) 13.9), priority(-1),
238  permissions(SVC_UNSPECIFIED),
239  oneWay(true), discard(false),
240  width(NBEdge::UNSPECIFIED_WIDTH),
241  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
242  bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH)
243  { }
244 
246  TypeDefinition(int _numLanes, SUMOReal _speed, int _priority,
247  SUMOReal _width, SVCPermissions _permissions, bool _oneWay,
248  SUMOReal _sideWalkWidth,
249  SUMOReal _bikeLaneWidth) :
250  numLanes(_numLanes), speed(_speed), priority(_priority),
251  permissions(_permissions),
252  oneWay(_oneWay), discard(false), width(_width),
253  sidewalkWidth(_sideWalkWidth),
254  bikeLaneWidth(_bikeLaneWidth)
255  { }
256 
258  int numLanes;
262  int priority;
266  bool oneWay;
268  bool discard;
271  /* @brief The width of the sidewalk that should be added as an additional lane
272  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
274  /* @brief The width of the bike lane that should be added as an additional lane
275  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
278  std::map<SUMOVehicleClass, SUMOReal> restrictions;
280  std::set<SumoXMLAttr> attrs;
281 
282  };
283 
284 
291  const TypeDefinition& getType(const std::string& name) const;
292 
293 
294 private:
297 
299  typedef std::map<std::string, TypeDefinition> TypesCont;
300 
302  TypesCont myTypes;
303 
304 
305 private:
307  NBTypeCont(const NBTypeCont& s);
308 
310  NBTypeCont& operator=(const NBTypeCont& s);
311 
312 
313 };
314 
315 
316 #endif
317 
318 /****************************************************************************/
319 
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:280
~NBTypeCont()
Destructor.
Definition: NBTypeCont.h:69
int numLanes
The number of lanes of an edge.
Definition: NBTypeCont.h:258
bool wasSet(const std::string &type, const SumoXMLAttr attr) const
Returns whether an attribute of a type was set.
Definition: NBTypeCont.cpp:205
std::map< std::string, TypeDefinition > TypesCont
A container of types, accessed by the string id.
Definition: NBTypeCont.h:299
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:235
SUMOReal width
The width of lanes of edges of this type [m].
Definition: NBTypeCont.h:270
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:193
SUMOReal speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:260
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
Definition: NBTypeCont.cpp:92
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
bool oneWay
Whether one-way traffic is mostly common for this type (mostly unused)
Definition: NBTypeCont.h:266
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:217
SUMOReal getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:223
TypeDefinition()
Constructor.
Definition: NBTypeCont.h:236
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:181
SUMOReal getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:229
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:175
unsigned int size() const
Returns the number of known types.
Definition: NBTypeCont.h:101
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:187
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:75
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:61
void writeTypes(OutputDevice &into) const
writes all types a s XML
Definition: NBTypeCont.cpp:127
bool markAsToDiscard(const std::string &id)
Marks a type as to be discarded.
Definition: NBTypeCont.cpp:81
TypeDefinition myDefaultType
The default type.
Definition: NBTypeCont.h:296
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:199
bool copyRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a type.
Definition: NBTypeCont.cpp:114
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:211
int priority
The priority of an edge.
Definition: NBTypeCont.h:262
SVCPermissions permissions
List of vehicle types that are allowed on this edge.
Definition: NBTypeCont.h:264
std::map< SUMOVehicleClass, SUMOReal > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:278
TypesCont myTypes
The container of types.
Definition: NBTypeCont.h:302
bool addRestriction(const std::string &id, const SUMOVehicleClass svc, const SUMOReal speed)
Adds a restriction to a type.
Definition: NBTypeCont.cpp:103
void setDefaults(int defaultNumLanes, SUMOReal defaultSpeed, int defaultPriority)
Sets the default values.
Definition: NBTypeCont.cpp:51
const SVCPermissions SVC_UNSPECIFIED
bool discard
Whether edges of this type shall be discarded.
Definition: NBTypeCont.h:268
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:246