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 /****************************************************************************/
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  double widthResolution,
94  double maxWidth,
95  double minWidth);
96 
100  int size() const {
101  return (int) myTypes.size();
102  }
103 
104 
108  bool knows(const std::string& type) const;
109 
110 
114  bool markAsToDiscard(const std::string& id);
115 
120  bool markAsSet(const std::string& id, const SumoXMLAttr attr);
121 
127  bool addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
128 
133  bool copyRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
134 
136  void writeTypes(OutputDevice& into) const;
137 
140 
147  int getNumLanes(const std::string& type) const;
148 
149 
156  double getSpeed(const std::string& type) const;
157 
158 
165  int getPriority(const std::string& type) const;
166 
167 
175  bool getIsOneWay(const std::string& type) const;
176 
177 
184  bool getShallBeDiscarded(const std::string& type) const;
185 
193  double getWidthResolution(const std::string& type) const;
194 
202  double getMaxWidth(const std::string& type) const;
203 
211  double getMinWidth(const std::string& type) const;
212 
213 
219  bool wasSet(const std::string& type, const SumoXMLAttr attr) const;
220 
221 
228  SVCPermissions getPermissions(const std::string& type) const;
229 
230 
237  double getWidth(const std::string& type) const;
238 
239 
246  double getSidewalkWidth(const std::string& type) const;
247 
248 
255  double getBikeLaneWidth(const std::string& type) const;
257 
258 
259 private:
260  struct TypeDefinition {
263  numLanes(1), speed((double) 13.89), priority(-1),
265  oneWay(true), discard(false),
266  width(NBEdge::UNSPECIFIED_WIDTH),
267  widthResolution(0),
268  maxWidth(0),
269  minWidth(0),
270  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
271  bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
272  }
273 
275  TypeDefinition(int _numLanes, double _speed, int _priority,
276  double _width, SVCPermissions _permissions, bool _oneWay,
277  double _sideWalkWidth,
278  double _bikeLaneWidth,
279  double _widthResolution,
280  double _maxWidth,
281  double _minWidth) :
282  numLanes(_numLanes), speed(_speed), priority(_priority),
283  permissions(_permissions),
284  oneWay(_oneWay), discard(false),
285  width(_width),
286  widthResolution(_widthResolution),
287  maxWidth(_maxWidth),
288  minWidth(_minWidth),
289  sidewalkWidth(_sideWalkWidth),
290  bikeLaneWidth(_bikeLaneWidth) {
291  }
292 
294  int numLanes;
296  double speed;
298  int priority;
302  bool oneWay;
304  bool discard;
306  double width;
310  double maxWidth;
312  double minWidth;
313  /* @brief The width of the sidewalk that should be added as an additional lane
314  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
316  /* @brief The width of the bike lane that should be added as an additional lane
317  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
320  std::map<SUMOVehicleClass, double> restrictions;
322  std::set<SumoXMLAttr> attrs;
323 
324  };
325 
326 
333  const TypeDefinition& getType(const std::string& name) const;
334 
335 
336 private:
339 
341  typedef std::map<std::string, TypeDefinition> TypesCont;
342 
345 
346 
347 private:
349  NBTypeCont(const NBTypeCont& s);
350 
352  NBTypeCont& operator=(const NBTypeCont& s);
353 
354 
355 };
356 
357 
358 #endif
359 
360 /****************************************************************************/
361 
NBTypeCont::TypeDefinition
Definition: NBTypeCont.h:260
NBTypeCont::copyRestrictionsAndAttrs
bool copyRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a type.
Definition: NBTypeCont.cpp:111
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
SVC_UNSPECIFIED
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
Definition: SUMOVehicleClass.cpp:149
NBTypeCont::TypeDefinition::attrs
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:322
NBTypeCont::TypeDefinition::numLanes
int numLanes
The number of lanes of an edge.
Definition: NBTypeCont.h:294
NBTypeCont::setDefaults
void setDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
Definition: NBTypeCont.cpp:40
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
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:54
NBTypeCont::getMaxWidth
double getMaxWidth(const std::string &type) const
Returns the maximum edge/lane widths of the given type.
Definition: NBTypeCont.cpp:206
NBTypeCont::TypeDefinition::widthResolution
double widthResolution
The resolution for interpreting custom (noisy) lane widths of this type [m].
Definition: NBTypeCont.h:308
NBTypeCont::~NBTypeCont
~NBTypeCont()
Destructor.
Definition: NBTypeCont.h:62
NBTypeCont::knows
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:72
NBTypeCont::markAsToDiscard
bool markAsToDiscard(const std::string &id)
Marks a type as to be discarded.
Definition: NBTypeCont.cpp:78
NBTypeCont::getWidthResolution
double getWidthResolution(const std::string &type) const
Returns the resolution for interpreting edge/lane widths of the given type.
Definition: NBTypeCont.cpp:201
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:86
NBTypeCont::TypeDefinition::oneWay
bool oneWay
Whether one-way traffic is mostly common for this type (mostly unused)
Definition: NBTypeCont.h:302
NBTypeCont::getIsOneWay
bool getIsOneWay(const std::string &type) const
Returns whether edges are one-way per default for the given type.
Definition: NBTypeCont.cpp:190
NBTypeCont::TypeDefinition::TypeDefinition
TypeDefinition()
Constructor.
Definition: NBTypeCont.h:262
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:219
NBTypeCont::myTypes
TypesCont myTypes
The container of types.
Definition: NBTypeCont.h:344
NBTypeCont::getSpeed
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:178
SUMOVehicleClass.h
NBTypeCont::operator=
NBTypeCont & operator=(const NBTypeCont &s)
invalid assignment operator
NBTypeCont::TypeDefinition::sidewalkWidth
double sidewalkWidth
Definition: NBTypeCont.h:315
NBTypeCont::TypeDefinition::width
double width
The width of lanes of edges of this type [m].
Definition: NBTypeCont.h:306
NBTypeCont::getShallBeDiscarded
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:196
NBTypeCont::getPriority
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:184
NBTypeCont::TypesCont
std::map< std::string, TypeDefinition > TypesCont
A container of types, accessed by the string id.
Definition: NBTypeCont.h:341
NBTypeCont::NBTypeCont
NBTypeCont()
Constructor.
Definition: NBTypeCont.h:58
NBTypeCont::TypeDefinition::minWidth
double minWidth
The minimum width for lanes of this type [m].
Definition: NBTypeCont.h:312
NBTypeCont::size
int size() const
Returns the number of known types.
Definition: NBTypeCont.h:100
NBTypeCont::getPermissions
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:222
NBTypeCont::writeTypes
void writeTypes(OutputDevice &into) const
writes all types a s XML
Definition: NBTypeCont.cpp:124
NBTypeCont
A storage for available types of edges.
Definition: NBTypeCont.h:55
NBTypeCont::TypeDefinition::speed
double speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:296
NBTypeCont::wasSet
bool wasSet(const std::string &type, const SumoXMLAttr attr) const
Returns whether an attribute of a type was set.
Definition: NBTypeCont.cpp:216
NBTypeCont::markAsSet
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
Definition: NBTypeCont.cpp:89
NBTypeCont::getWidth
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:228
NBTypeCont::getNumLanes
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:172
NBTypeCont::TypeDefinition::restrictions
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:320
NBTypeCont::addRestriction
bool addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to a type.
Definition: NBTypeCont.cpp:100
config.h
NBTypeCont::TypeDefinition::bikeLaneWidth
double bikeLaneWidth
Definition: NBTypeCont.h:318
NBTypeCont::getType
const TypeDefinition & getType(const std::string &name) const
Retrieve the name or the default type.
Definition: NBTypeCont.cpp:246
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:275
NBTypeCont::TypeDefinition::priority
int priority
The priority of an edge.
Definition: NBTypeCont.h:298
NBTypeCont::getSidewalkWidth
double getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:234
NBTypeCont::myDefaultType
TypeDefinition myDefaultType
The default type.
Definition: NBTypeCont.h:338
NBTypeCont::TypeDefinition::maxWidth
double maxWidth
The maximum width for lanes of this type [m].
Definition: NBTypeCont.h:310
NBTypeCont::getMinWidth
double getMinWidth(const std::string &type) const
Returns the minimum edge/lane widths of the given type.
Definition: NBTypeCont.cpp:211
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
NBTypeCont::TypeDefinition::permissions
SVCPermissions permissions
List of vehicle types that are allowed on this edge.
Definition: NBTypeCont.h:300
NBTypeCont::getBikeLaneWidth
double getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:240
NBEdge.h
NBTypeCont::TypeDefinition::discard
bool discard
Whether edges of this type shall be discarded.
Definition: NBTypeCont.h:304