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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
22 // A storage for available edgeTypes of edges
23 /****************************************************************************/
24 #pragma once
25 #include <config.h>
26 
27 #include <string>
28 #include <map>
30 #include <netbuild/NBEdge.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class OutputDevice;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
52 class NBTypeCont {
53 
54 public:
59 
62 
64  double speed;
65 
68 
70  double width;
71 
73  std::map<SUMOVehicleClass, double> restrictions;
74 
76  std::set<SumoXMLAttr> attrs;
77  };
78 
81 
84 
86  EdgeTypeDefinition(const EdgeTypeDefinition* edgeType);
87 
89  EdgeTypeDefinition(int numLanes, double speed, int priority,
90  double width, SVCPermissions permissions, bool oneWay,
91  double sideWalkWidth, double bikeLaneWidth,
92  double widthResolution, double maxWidth, double minWidth);
93 
95  bool needsLaneType() const;
96 
98  double speed;
99 
101  int priority;
102 
105 
107  bool oneWay;
108 
110  bool discard;
111 
113  double width;
114 
117 
119  double maxWidth;
120 
122  double minWidth;
123 
124  /* @brief The width of the sidewalk that should be added as an additional lane
125  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
127 
128  /* @brief The width of the bike lane that should be added as an additional lane
129  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
131 
133  std::map<SUMOVehicleClass, double> restrictions;
134 
136  std::set<SumoXMLAttr> attrs;
137 
139  std::vector<LaneTypeDefinition> laneTypeDefinitions;
140  };
141 
143  typedef std::map<std::string, EdgeTypeDefinition*> TypesCont;
144 
146  NBTypeCont();
147 
149  ~NBTypeCont();
150 
152  void clearTypes();
153 
161  void setEdgeTypeDefaults(int defaultNumLanes, double defaultLaneWidth,
162  double defaultSpeed, int defaultPriority,
163  SVCPermissions defaultPermissions);
164 
175  void insertEdgeType(const std::string& id, int numLanes,
176  double maxSpeed, int prio,
177  SVCPermissions permissions,
178  double width, bool oneWayIsDefault,
179  double sidewalkWidth,
180  double bikeLaneWidth,
181  double widthResolution,
182  double maxWidth,
183  double minWidth);
184 
189  void insertEdgeType(const std::string& id, const EdgeTypeDefinition* edgeType);
190 
198  void insertLaneType(const std::string& edgeTypeID,
199  int index,
200  double maxSpeed,
201  SVCPermissions permissions,
202  double width,
203  const std::set<SumoXMLAttr> &attrs);
204 
208  int size() const;
209 
214  void removeEdgeType(const std::string& id);
215 
220  void updateEdgeTypeID(const std::string& oldId, const std::string& newId);
221 
223  TypesCont::const_iterator begin() const;
224 
226  TypesCont::const_iterator end() const;
227 
231  bool knows(const std::string& edgeType) const;
232 
236  bool markEdgeTypeAsToDiscard(const std::string& id);
237 
242  bool markEdgeTypeAsSet(const std::string& id, const SumoXMLAttr attr);
243 
249  bool addEdgeTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
250 
255  bool copyEdgeTypeRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
256 
261  bool markLaneTypeAsSet(const std::string& id, int index, const SumoXMLAttr attr);
262 
268  bool addLaneTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
269 
271  void writeEdgeTypes(OutputDevice& into) const;
272 
275 
282  int getEdgeTypeNumLanes(const std::string& edgeType) const;
283 
290  double getEdgeTypeSpeed(const std::string& edgeType) const;
291 
298  int getEdgeTypePriority(const std::string& edgeType) const;
299 
307  bool getEdgeTypeIsOneWay(const std::string& edgeType) const;
308 
315  bool getEdgeTypeShallBeDiscarded(const std::string& edgeType) const;
316 
324  double getEdgeTypeWidthResolution(const std::string& edgeType) const;
325 
333  double getEdgeTypeMaxWidth(const std::string& edgeType) const;
334 
342  double getEdgeTypeMinWidth(const std::string& edgeType) const;
343 
349  bool wasSetEdgeTypeAttribute(const std::string& edgeType, const SumoXMLAttr attr) const;
350 
357  SVCPermissions getEdgeTypePermissions(const std::string& edgeType) const;
358 
365  double getEdgeTypeWidth(const std::string& edgeType) const;
366 
373  double getEdgeTypeSidewalkWidth(const std::string& edgeType) const;
374 
381  double getEdgeTypeBikeLaneWidth(const std::string& edgeType) const;
382 
384 
385 protected:
392  const EdgeTypeDefinition* getEdgeType(const std::string& name) const;
393 
396 
399 
400 private:
402  NBTypeCont(const NBTypeCont& s) = delete;
403 
405  NBTypeCont& operator=(const NBTypeCont& s) = delete;
406 };
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A storage for available edgeTypes of edges.
Definition: NBTypeCont.h:52
void setEdgeTypeDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
Definition: NBTypeCont.cpp:158
double getEdgeTypeMaxWidth(const std::string &edgeType) const
Returns the maximum edge/lane widths of the given edgeType.
Definition: NBTypeCont.cpp:479
bool markEdgeTypeAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a edgeType as set.
Definition: NBTypeCont.cpp:287
void removeEdgeType(const std::string &id)
Remove a edgeType from the list.
Definition: NBTypeCont.cpp:229
std::map< std::string, EdgeTypeDefinition * > TypesCont
A container of edgeTypes, accessed by the string id.
Definition: NBTypeCont.h:143
NBTypeCont()
Constructor.
Definition: NBTypeCont.cpp:132
bool addLaneTypeRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to last laneType.
Definition: NBTypeCont.cpp:333
~NBTypeCont()
Destructor.
Definition: NBTypeCont.cpp:136
void writeEdgeTypes(OutputDevice &into) const
writes all EdgeTypes (and their lanes) as XML
Definition: NBTypeCont.cpp:344
bool wasSetEdgeTypeAttribute(const std::string &edgeType, const SumoXMLAttr attr) const
Returns whether an attribute of a edgeType was set.
Definition: NBTypeCont.cpp:489
int size() const
Returns the number of known edgeTypes.
Definition: NBTypeCont.cpp:223
bool markEdgeTypeAsToDiscard(const std::string &id)
Marks a edgeType as to be discarded.
Definition: NBTypeCont.cpp:276
NBTypeCont & operator=(const NBTypeCont &s)=delete
invalid assignment operator
double getEdgeTypeMinWidth(const std::string &edgeType) const
Returns the minimum edge/lane widths of the given edgeType.
Definition: NBTypeCont.cpp:484
bool getEdgeTypeShallBeDiscarded(const std::string &edgeType) const
Returns the information whether edges of this edgeType shall be discarded.
Definition: NBTypeCont.cpp:469
bool copyEdgeTypeRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a edgeType.
Definition: NBTypeCont.cpp:309
double getEdgeTypeSpeed(const std::string &edgeType) const
Returns the maximal velocity for the given edgeType [m/s].
Definition: NBTypeCont.cpp:451
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
Definition: NBTypeCont.cpp:457
TypesCont::const_iterator begin() const
return begin iterator
Definition: NBTypeCont.cpp:258
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
Definition: NBTypeCont.cpp:445
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
Definition: NBTypeCont.cpp:501
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
Definition: NBTypeCont.cpp:495
double getEdgeTypeWidthResolution(const std::string &edgeType) const
Returns the resolution for interpreting edge/lane widths of the given edgeType.
Definition: NBTypeCont.cpp:474
void insertEdgeType(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 edgeType into the list.
Definition: NBTypeCont.cpp:173
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
Definition: NBTypeCont.cpp:270
bool addEdgeTypeRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to a edgeType.
Definition: NBTypeCont.cpp:298
TypesCont::const_iterator end() const
return end iterator
Definition: NBTypeCont.cpp:264
double getEdgeTypeSidewalkWidth(const std::string &edgeType) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:507
double getEdgeTypeBikeLaneWidth(const std::string &edgeType) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:513
void clearTypes()
clear types
Definition: NBTypeCont.cpp:147
const EdgeTypeDefinition * getEdgeType(const std::string &name) const
Retrieve the name or the default edgeType.
Definition: NBTypeCont.cpp:519
bool getEdgeTypeIsOneWay(const std::string &edgeType) const
Returns whether edges are one-way per default for the given edgeType.
Definition: NBTypeCont.cpp:463
void updateEdgeTypeID(const std::string &oldId, const std::string &newId)
change edge type ID
Definition: NBTypeCont.cpp:241
TypesCont myEdgeTypes
The container of edgeTypes.
Definition: NBTypeCont.h:398
bool markLaneTypeAsSet(const std::string &id, int index, const SumoXMLAttr attr)
Marks an attribute of last laneType as set.
Definition: NBTypeCont.cpp:322
EdgeTypeDefinition * myDefaultType
The default edgeType.
Definition: NBTypeCont.h:395
NBTypeCont(const NBTypeCont &s)=delete
invalid copy constructor
void insertLaneType(const std::string &edgeTypeID, int index, double maxSpeed, SVCPermissions permissions, double width, const std::set< SumoXMLAttr > &attrs)
Adds a laneType into the list.
Definition: NBTypeCont.cpp:210
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
edgeType definition
Definition: NBTypeCont.h:80
int priority
The priority of an edge.
Definition: NBTypeCont.h:101
double width
The width of lanes of edges of this edgeType [m].
Definition: NBTypeCont.h:113
double minWidth
The minimum width for lanes of this edgeType [m].
Definition: NBTypeCont.h:122
double speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:98
SVCPermissions permissions
List of vehicle edgeTypes that are allowed on this edge.
Definition: NBTypeCont.h:104
double maxWidth
The maximum width for lanes of this edgeType [m].
Definition: NBTypeCont.h:119
double widthResolution
The resolution for interpreting custom (noisy) lane widths of this edgeType [m].
Definition: NBTypeCont.h:116
bool oneWay
Whether one-way traffic is mostly common for this edgeType (mostly unused)
Definition: NBTypeCont.h:107
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:136
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:133
bool needsLaneType() const
whether any lane attributes deviate from the edge attributes
Definition: NBTypeCont.cpp:109
std::vector< LaneTypeDefinition > laneTypeDefinitions
vector with LaneTypeDefinitions
Definition: NBTypeCont.h:139
bool discard
Whether edges of this edgeType shall be discarded.
Definition: NBTypeCont.h:110
laneType definition
Definition: NBTypeCont.h:56
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:73
double speed
The maximal velocity on a lane in m/s.
Definition: NBTypeCont.h:64
SVCPermissions permissions
List of vehicle edgeTypes that are allowed on this lane.
Definition: NBTypeCont.h:67
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:76
double width
lane width [m]
Definition: NBTypeCont.h:70