Eclipse 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-2019 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 /****************************************************************************/
18 // A storage for available types of edges
19 /****************************************************************************/
20 #ifndef NBTypeCont_h
21 #define NBTypeCont_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <map>
32 #include <netbuild/NBEdge.h>
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class OutputDevice;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
54 class NBTypeCont {
55 public:
58 
59 
62 
63 
71  void setDefaults(int defaultNumLanes, double defaultLaneWidth,
72  double defaultSpeed, int defaultPriority,
73  SVCPermissions defaultPermissions);
74 
75 
86  void insert(const std::string& id, int numLanes,
87  double maxSpeed, int prio,
88  SVCPermissions permissions,
89  double width, bool oneWayIsDefault,
90  double sidewalkWidth,
91  double bikeLaneWidth,
92  double widthResolution,
93  double maxWidth,
94  double minWidth);
95 
99  int size() const {
100  return (int) myTypes.size();
101  }
102 
103 
107  bool knows(const std::string& type) const;
108 
109 
113  bool markAsToDiscard(const std::string& id);
114 
119  bool markAsSet(const std::string& id, const SumoXMLAttr attr);
120 
126  bool addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
127 
132  bool copyRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
133 
135  void writeTypes(OutputDevice& into) const;
136 
139 
146  int getNumLanes(const std::string& type) const;
147 
148 
155  double getSpeed(const std::string& type) const;
156 
157 
164  int getPriority(const std::string& type) const;
165 
166 
174  bool getIsOneWay(const std::string& type) const;
175 
176 
183  bool getShallBeDiscarded(const std::string& type) const;
184 
192  double getWidthResolution(const std::string& type) const;
193 
201  double getMaxWidth(const std::string& type) const;
202 
210  double getMinWidth(const std::string& type) const;
211 
212 
218  bool wasSet(const std::string& type, const SumoXMLAttr attr) const;
219 
220 
227  SVCPermissions getPermissions(const std::string& type) const;
228 
229 
236  double getWidth(const std::string& type) const;
237 
238 
245  double getSidewalkWidth(const std::string& type) const;
246 
247 
254  double getBikeLaneWidth(const std::string& type) const;
256 
257 
258 private:
259  struct TypeDefinition {
262  numLanes(1), speed((double) 13.89), priority(-1),
264  oneWay(true), discard(false),
265  width(NBEdge::UNSPECIFIED_WIDTH),
266  widthResolution(0),
267  maxWidth(0),
268  minWidth(0),
269  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
270  bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
271  }
272 
274  TypeDefinition(int _numLanes, double _speed, int _priority,
275  double _width, SVCPermissions _permissions, bool _oneWay,
276  double _sideWalkWidth,
277  double _bikeLaneWidth,
278  double _widthResolution,
279  double _maxWidth,
280  double _minWidth) :
281  numLanes(_numLanes), speed(_speed), priority(_priority),
282  permissions(_permissions),
283  oneWay(_oneWay), discard(false),
284  width(_width),
285  widthResolution(_widthResolution),
286  maxWidth(_maxWidth),
287  minWidth(_minWidth),
288  sidewalkWidth(_sideWalkWidth),
289  bikeLaneWidth(_bikeLaneWidth) {
290  }
291 
293  int numLanes;
295  double speed;
297  int priority;
301  bool oneWay;
303  bool discard;
305  double width;
309  double maxWidth;
311  double minWidth;
312  /* @brief The width of the sidewalk that should be added as an additional lane
313  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
315  /* @brief The width of the bike lane that should be added as an additional lane
316  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
319  std::map<SUMOVehicleClass, double> restrictions;
321  std::set<SumoXMLAttr> attrs;
322 
323  };
324 
325 
332  const TypeDefinition& getType(const std::string& name) const;
333 
334 
335 private:
338 
340  typedef std::map<std::string, TypeDefinition> TypesCont;
341 
344 
345 
346 private:
349 
352 
353 
354 };
355 
356 
357 #endif
358 
359 /****************************************************************************/
360 
NBTypeCont::TypeDefinition
Definition: NBTypeCont.h:259
NBTypeCont::copyRestrictionsAndAttrs
bool copyRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a type.
Definition: NBTypeCont.cpp:110
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
SVC_UNSPECIFIED
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
Definition: SUMOVehicleClass.cpp:148
NBTypeCont::TypeDefinition::attrs
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:321
NBTypeCont::TypeDefinition::numLanes
int numLanes
The number of lanes of an edge.
Definition: NBTypeCont.h:293
NBTypeCont::setDefaults
void setDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
Definition: NBTypeCont.cpp:39
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
NBTypeCont::insert
void insert(const std::string &id, int numLanes, double maxSpeed, int prio, SVCPermissions permissions, double width, bool oneWayIsDefault, double sidewalkWidth, double bikeLaneWidth, double widthResolution, double maxWidth, double minWidth)
Adds a type into the list.
Definition: NBTypeCont.cpp:53
NBTypeCont::getMaxWidth
double getMaxWidth(const std::string &type) const
Returns the maximum edge/lane widths of the given type.
Definition: NBTypeCont.cpp:205
NBTypeCont::TypeDefinition::widthResolution
double widthResolution
The resolution for interpreting custom (noisy) lane widths of this type [m].
Definition: NBTypeCont.h:307
NBTypeCont::~NBTypeCont
~NBTypeCont()
Destructor.
Definition: NBTypeCont.h:61
NBTypeCont::knows
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:71
NBTypeCont::markAsToDiscard
bool markAsToDiscard(const std::string &id)
Marks a type as to be discarded.
Definition: NBTypeCont.cpp:77
NBTypeCont::getWidthResolution
double getWidthResolution(const std::string &type) const
Returns the resolution for interpreting edge/lane widths of the given type.
Definition: NBTypeCont.cpp:200
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
NBTypeCont::TypeDefinition::oneWay
bool oneWay
Whether one-way traffic is mostly common for this type (mostly unused)
Definition: NBTypeCont.h:301
NBTypeCont::getIsOneWay
bool getIsOneWay(const std::string &type) const
Returns whether edges are one-way per default for the given type.
Definition: NBTypeCont.cpp:189
NBTypeCont::TypeDefinition::TypeDefinition
TypeDefinition()
Constructor.
Definition: NBTypeCont.h:261
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
NBTypeCont::myTypes
TypesCont myTypes
The container of types.
Definition: NBTypeCont.h:343
NBTypeCont::getSpeed
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:177
SUMOVehicleClass.h
NBTypeCont::operator=
NBTypeCont & operator=(const NBTypeCont &s)
invalid assignment operator
NBTypeCont::TypeDefinition::sidewalkWidth
double sidewalkWidth
Definition: NBTypeCont.h:314
NBTypeCont::TypeDefinition::width
double width
The width of lanes of edges of this type [m].
Definition: NBTypeCont.h:305
NBTypeCont::getShallBeDiscarded
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:195
NBTypeCont::getPriority
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:183
NBTypeCont::TypesCont
std::map< std::string, TypeDefinition > TypesCont
A container of types, accessed by the string id.
Definition: NBTypeCont.h:340
NBTypeCont::NBTypeCont
NBTypeCont()
Constructor.
Definition: NBTypeCont.h:57
NBTypeCont::TypeDefinition::minWidth
double minWidth
The minimum width for lanes of this type [m].
Definition: NBTypeCont.h:311
NBTypeCont::size
int size() const
Returns the number of known types.
Definition: NBTypeCont.h:99
NBTypeCont::getPermissions
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:221
NBTypeCont::writeTypes
void writeTypes(OutputDevice &into) const
writes all types a s XML
Definition: NBTypeCont.cpp:123
NBTypeCont
A storage for available types of edges.
Definition: NBTypeCont.h:54
NBTypeCont::TypeDefinition::speed
double speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:295
NBTypeCont::wasSet
bool wasSet(const std::string &type, const SumoXMLAttr attr) const
Returns whether an attribute of a type was set.
Definition: NBTypeCont.cpp:215
NBTypeCont::markAsSet
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
Definition: NBTypeCont.cpp:88
NBTypeCont::getWidth
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:227
NBTypeCont::getNumLanes
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:171
NBTypeCont::TypeDefinition::restrictions
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:319
NBTypeCont::NBTypeCont
NBTypeCont(const NBTypeCont &s)
invalid copy constructor
NBTypeCont::addRestriction
bool addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to a type.
Definition: NBTypeCont.cpp:99
config.h
NBTypeCont::TypeDefinition::bikeLaneWidth
double bikeLaneWidth
Definition: NBTypeCont.h:317
NBTypeCont::getType
const TypeDefinition & getType(const std::string &name) const
Retrieve the name or the default type.
Definition: NBTypeCont.cpp:245
NBTypeCont::TypeDefinition::TypeDefinition
TypeDefinition(int _numLanes, double _speed, int _priority, double _width, SVCPermissions _permissions, bool _oneWay, double _sideWalkWidth, double _bikeLaneWidth, double _widthResolution, double _maxWidth, double _minWidth)
Constructor.
Definition: NBTypeCont.h:274
NBTypeCont::TypeDefinition::priority
int priority
The priority of an edge.
Definition: NBTypeCont.h:297
NBTypeCont::getSidewalkWidth
double getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:233
NBTypeCont::myDefaultType
TypeDefinition myDefaultType
The default type.
Definition: NBTypeCont.h:337
NBTypeCont::TypeDefinition::maxWidth
double maxWidth
The maximum width for lanes of this type [m].
Definition: NBTypeCont.h:309
NBTypeCont::getMinWidth
double getMinWidth(const std::string &type) const
Returns the minimum edge/lane widths of the given type.
Definition: NBTypeCont.cpp:210
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
NBTypeCont::TypeDefinition::permissions
SVCPermissions permissions
List of vehicle types that are allowed on this edge.
Definition: NBTypeCont.h:299
NBTypeCont::getBikeLaneWidth
double getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:239
NBEdge.h
NBTypeCont::TypeDefinition::discard
bool discard
Whether edges of this type shall be discarded.
Definition: NBTypeCont.h:303