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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
19 // A storage for available types of edges
20 /****************************************************************************/
21 #ifndef NBTypeCont_h
22 #define NBTypeCont_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <string>
31 #include <map>
33 #include <netbuild/NBEdge.h>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class OutputDevice;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
55 class NBTypeCont {
56 public:
59 
60 
63 
64 
72  void setDefaults(int defaultNumLanes, double defaultLaneWidth,
73  double defaultSpeed, int defaultPriority,
74  SVCPermissions defaultPermissions);
75 
76 
87  void insert(const std::string& id, int numLanes,
88  double maxSpeed, int prio,
89  SVCPermissions permissions,
90  double width, bool oneWayIsDefault,
91  double sidewalkWidth,
92  double bikeLaneWidth);
93 
97  int size() const {
98  return (int) myTypes.size();
99  }
100 
101 
105  bool knows(const std::string& type) const;
106 
107 
111  bool markAsToDiscard(const std::string& id);
112 
117  bool markAsSet(const std::string& id, const SumoXMLAttr attr);
118 
124  bool addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
125 
130  bool copyRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
131 
133  void writeTypes(OutputDevice& into) const;
134 
137 
144  int getNumLanes(const std::string& type) const;
145 
146 
153  double getSpeed(const std::string& type) const;
154 
155 
162  int getPriority(const std::string& type) const;
163 
164 
172  bool getIsOneWay(const std::string& type) const;
173 
174 
181  bool getShallBeDiscarded(const std::string& type) const;
182 
183 
189  bool wasSet(const std::string& type, const SumoXMLAttr attr) const;
190 
191 
198  SVCPermissions getPermissions(const std::string& type) const;
199 
200 
207  double getWidth(const std::string& type) const;
208 
209 
216  double getSidewalkWidth(const std::string& type) const;
217 
218 
225  double getBikeLaneWidth(const std::string& type) const;
227 
228 
229 private:
230  struct TypeDefinition {
233  numLanes(1), speed((double) 13.89), priority(-1),
234  permissions(SVC_UNSPECIFIED),
235  oneWay(true), discard(false),
236  width(NBEdge::UNSPECIFIED_WIDTH),
237  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
238  bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
239  }
240 
242  TypeDefinition(int _numLanes, double _speed, int _priority,
243  double _width, SVCPermissions _permissions, bool _oneWay,
244  double _sideWalkWidth,
245  double _bikeLaneWidth) :
246  numLanes(_numLanes), speed(_speed), priority(_priority),
247  permissions(_permissions),
248  oneWay(_oneWay), discard(false), width(_width),
249  sidewalkWidth(_sideWalkWidth),
250  bikeLaneWidth(_bikeLaneWidth) {
251  }
252 
254  int numLanes;
256  double speed;
258  int priority;
262  bool oneWay;
264  bool discard;
266  double width;
267  /* @brief The width of the sidewalk that should be added as an additional lane
268  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
270  /* @brief The width of the bike lane that should be added as an additional lane
271  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
274  std::map<SUMOVehicleClass, double> restrictions;
276  std::set<SumoXMLAttr> attrs;
277 
278  };
279 
280 
287  const TypeDefinition& getType(const std::string& name) const;
288 
289 
290 private:
293 
295  typedef std::map<std::string, TypeDefinition> TypesCont;
296 
298  TypesCont myTypes;
299 
300 
301 private:
303  NBTypeCont(const NBTypeCont& s);
304 
306  NBTypeCont& operator=(const NBTypeCont& s);
307 
308 
309 };
310 
311 
312 #endif
313 
314 /****************************************************************************/
315 
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:54
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:276
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:174
~NBTypeCont()
Destructor.
Definition: NBTypeCont.h:62
int numLanes
The number of lanes of an edge.
Definition: NBTypeCont.h:254
std::map< std::string, TypeDefinition > TypesCont
A container of types, accessed by the string id.
Definition: NBTypeCont.h:295
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:58
The representation of a single edge during network building.
Definition: NBEdge.h:65
TypeDefinition(int _numLanes, double _speed, int _priority, double _width, SVCPermissions _permissions, bool _oneWay, double _sideWalkWidth, double _bikeLaneWidth)
Constructor.
Definition: NBTypeCont.h:242
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:180
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
Definition: NBTypeCont.cpp:85
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:168
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:192
bool oneWay
Whether one-way traffic is mostly common for this type (mostly unused)
Definition: NBTypeCont.h:262
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:210
const TypeDefinition & getType(const std::string &name) const
Retrieve the name or the default type.
Definition: NBTypeCont.cpp:228
bool addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to a type.
Definition: NBTypeCont.cpp:96
TypeDefinition()
Constructor.
Definition: NBTypeCont.h:232
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:68
double getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:222
double getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:216
void setDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
Definition: NBTypeCont.cpp:40
double width
The width of lanes of edges of this type [m].
Definition: NBTypeCont.h:266
bool markAsToDiscard(const std::string &id)
Marks a type as to be discarded.
Definition: NBTypeCont.cpp:74
TypeDefinition myDefaultType
The default type.
Definition: NBTypeCont.h:292
double speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:256
bool copyRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a type.
Definition: NBTypeCont.cpp:107
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:274
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
int priority
The priority of an edge.
Definition: NBTypeCont.h:258
SVCPermissions permissions
List of vehicle types that are allowed on this edge.
Definition: NBTypeCont.h:260
bool getIsOneWay(const std::string &type) const
Returns whether edges are one-way per default for the given type.
Definition: NBTypeCont.cpp:186
TypesCont myTypes
The container of types.
Definition: NBTypeCont.h:298
int size() const
Returns the number of known types.
Definition: NBTypeCont.h:97
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:198
bool discard
Whether edges of this type shall be discarded.
Definition: NBTypeCont.h:264
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:204
A storage for available types of edges.
Definition: NBTypeCont.h:55
void writeTypes(OutputDevice &into) const
writes all types a s XML
Definition: NBTypeCont.cpp:120