Eclipse SUMO - Simulation of Urban MObility
MSJunction.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 /****************************************************************************/
21 // The base class for an intersection
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <string>
27 #include <vector>
28 #include <map>
29 #include <utils/geom/Position.h>
31 #include <utils/common/Named.h>
33 #include <utils/common/SUMOTime.h>
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class MSVehicle;
42 class MSLink;
43 class MSLane;
44 class MSEdge;
45 class MSJunctionLogic;
46 
47 typedef std::vector<MSEdge*> MSEdgeVector;
48 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
58 class MSJunction : public Named, public Parameterised {
59 public:
65  MSJunction(const std::string& id,
66  SumoXMLNodeType type,
67  const Position& position,
68  const PositionVector& shape,
69  const std::string& name);
70 
71 
73  virtual ~MSJunction();
74 
75 
78  virtual void postloadInit();
79 
80 
82  const Position& getPosition() const;
83 
84 
88  const PositionVector& getShape() const {
89  return myShape;
90  }
91 
93  const std::string& getName() const {
94  return myName;
95  }
96 
97  virtual const std::vector<MSLink*>& getFoeLinks(const MSLink* const /*srcLink*/) const {
98  return myEmptyLinks;
99  }
100 
101  virtual const std::vector<MSLane*>& getFoeInternalLanes(const MSLink* const /*srcLink*/) const {
102  return myEmptyLanes;
103  }
104 
105  inline const ConstMSEdgeVector& getIncoming() const {
106  return myIncoming;
107  }
108 
109  int getNrOfIncomingLanes() const;
110 
111  inline const ConstMSEdgeVector& getOutgoing() const {
112  return myOutgoing;
113  }
114 
117  virtual const std::vector<MSLane*> getInternalLanes() const {
118  return myEmptyLanes;
119  }
120 
121  void addIncoming(MSEdge* edge) {
122  myIncoming.push_back(edge);
123  }
124 
125  void addOutgoing(MSEdge* edge) {
126  myOutgoing.push_back(edge);
127  }
128 
131  return myType;
132  }
133 
135  void passedJunction(const MSVehicle* vehicle);
136 
137  // @brief return the underlying right-of-way and conflict matrix
138  virtual const MSJunctionLogic* getLogic() const {
139  return nullptr;
140  }
141 
142 protected:
145 
148 
151 
153  std::string myName;
154 
155  std::vector<MSLink*> myEmptyLinks;
156  std::vector<MSLane*> myEmptyLanes;
157 
158 
163 
165  typedef std::map<std::string, MSJunction* > DictType;
166 
167 private:
170 
173 
174 };
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSJunction.h:48
std::vector< MSEdge * > MSEdgeVector
Definition: MSJunction.h:45
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
A road/street connecting two junctions.
Definition: MSEdge.h:77
The base class for an intersection.
Definition: MSJunction.h:58
std::map< std::string, MSJunction * > DictType
definition of the static dictionary type
Definition: MSJunction.h:165
const ConstMSEdgeVector & getIncoming() const
Definition: MSJunction.h:105
const PositionVector & getShape() const
Returns this junction's shape.
Definition: MSJunction.h:88
const ConstMSEdgeVector & getOutgoing() const
Definition: MSJunction.h:111
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:130
const Position & getPosition() const
Definition: MSJunction.cpp:68
virtual const std::vector< MSLane * > getInternalLanes() const
Returns all internal lanes on the junction.
Definition: MSJunction.h:117
virtual const MSJunctionLogic * getLogic() const
Definition: MSJunction.h:138
virtual const std::vector< MSLink * > & getFoeLinks(const MSLink *const) const
Definition: MSJunction.h:97
std::vector< MSLane * > myEmptyLanes
Definition: MSJunction.h:156
virtual ~MSJunction()
Destructor.
Definition: MSJunction.cpp:64
PositionVector myShape
The shape of the junction.
Definition: MSJunction.h:150
ConstMSEdgeVector myOutgoing
outgoing edges
Definition: MSJunction.h:162
std::vector< MSLink * > myEmptyLinks
Definition: MSJunction.h:155
Position myPosition
The position of the junction.
Definition: MSJunction.h:147
std::string myName
@briefh The (optional) junction name
Definition: MSJunction.h:153
int getNrOfIncomingLanes() const
Definition: MSJunction.cpp:78
MSJunction(const std::string &id, SumoXMLNodeType type, const Position &position, const PositionVector &shape, const std::string &name)
Constructor.
Definition: MSJunction.cpp:54
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:125
virtual const std::vector< MSLane * > & getFoeInternalLanes(const MSLink *const) const
Definition: MSJunction.h:101
ConstMSEdgeVector myIncoming
incoming edges
Definition: MSJunction.h:160
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:121
void passedJunction(const MSVehicle *vehicle)
erase vehicle from myLinkLeaders
MSJunction(const MSJunction &)
Invalidated copy constructor.
SumoXMLNodeType myType
Tye type of this junction.
Definition: MSJunction.h:144
virtual void postloadInit()
Definition: MSJunction.cpp:74
const std::string & getName() const
return the junction name
Definition: MSJunction.h:93
MSJunction & operator=(const MSJunction &)
Invalidated assignment operator.
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
Base class for objects which have an id.
Definition: Named.h:53
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
A list of positions.