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 /****************************************************************************/
10 /// @file    ROLane.h
11 /// @author  Daniel Krajzewicz
12 /// @author  Jakob Erdmann
13 /// @date    Sept 2002
14 /// @version $Id$
15 ///
16 // A single lane the router may use
17 /****************************************************************************/
18 #ifndef ROLane_h
19 #define ROLane_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <vector>
28 #include <utils/geom/PositionVector.h>
29 #include <utils/common/Named.h>
30 #include <utils/common/SUMOVehicleClass.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class ROEdge;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
42 /**
43  * @class ROLane
44  * @brief A single lane the router may use
45  *
46  * Currently, the lane has no other purpose then storing the allowed vehicle
47  *  classes. They are even only stored herein and used by computing the vehicle
48  *  classes allowed on the according edge.
49  * @see ROEdge
50  */
51 class ROLane : public Named {
52 public:
53     /** @brief Constructor
54      *
55      * @param[in] id The id of the lane
56      * @param[in] length The length of the lane
57      * @param[in] maxSpeed The maximum speed allowed on the lane
58      * @param[in] permissions Vehicle classes that may pass this lane
59      */
ROLane(const std::string & id,ROEdge * edge,double length,double maxSpeed,SVCPermissions permissions,const PositionVector & shape)60     ROLane(const std::string& id, ROEdge* edge, double length, double maxSpeed, SVCPermissions permissions, const PositionVector& shape) :
61         Named(id), myEdge(edge), myLength(length), myMaxSpeed(maxSpeed), myPermissions(permissions), myShape(shape) {
62     }
63 
64 
65     /// @brief Destructor
~ROLane()66     ~ROLane() { }
67 
68 
69     /** @brief Returns the length of the lane
70      * @return The length of this lane
71      */
getLength()72     double getLength() const {
73         return myLength;
74     }
75 
76 
77     /** @brief Returns the maximum speed allowed on this lane
78      * @return The maximum speed allowed on this lane
79      */
getSpeed()80     double getSpeed() const {
81         return myMaxSpeed;
82     }
83 
84 
85     /** @brief Returns the list of allowed vehicle classes
86      * @return The list of vehicle classes allowed on this lane
87      */
getPermissions()88     inline SVCPermissions getPermissions() const {
89         return myPermissions;
90     }
91 
92     /** @brief Returns the lane's edge
93      * @return This lane's edge
94      */
getEdge()95     ROEdge& getEdge() const {
96         return *myEdge;
97     }
98 
99     /// @brief get the map of outgoing lanes to via edges
getOutgoingViaLanes()100     const std::vector<std::pair<const ROLane*, const ROEdge*> >& getOutgoingViaLanes() const {
101         return myOutgoingLanes;
102     }
103 
104     void addOutgoingLane(ROLane* lane, ROEdge* via = nullptr) {
105         myOutgoingLanes.push_back(std::make_pair(lane, via));
106     }
107 
108     /// @brief get the state of the link from the logical predecessor to this lane (ignored for routing)
getIncomingLinkState()109     inline LinkState getIncomingLinkState() const {
110         return LINKSTATE_MAJOR;
111     }
112 
allowsVehicleClass(SUMOVehicleClass vclass)113     inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
114         return (myPermissions & vclass) == vclass;
115     }
116 
getShape()117     const PositionVector& getShape() const {
118         return myShape;
119     }
120 
121 private:
122     /// @brief The parent edge of this lane
123     ROEdge* myEdge;
124 
125     /// @brief The length of the lane
126     double myLength;
127 
128     /// @brief The maximum speed allowed on the lane
129     double myMaxSpeed;
130 
131     /// @brief The encoding of allowed vehicle classes
132     SVCPermissions myPermissions;
133 
134     std::vector<std::pair<const ROLane*, const ROEdge*> > myOutgoingLanes;
135 
136     /// @brief shape for this lane
137     const PositionVector myShape;
138 
139 
140 private:
141     /// @brief Invalidated copy constructor
142     ROLane(const ROLane& src);
143 
144     /// @brief Invalidated assignment operator
145     ROLane& operator=(const ROLane& src);
146 
147 };
148 
149 
150 #endif
151 
152 /****************************************************************************/
153 
154