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-2018 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 // The base class for an intersection
19 /****************************************************************************/
20 #ifndef MSJunction_h
21 #define MSJunction_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <vector>
31 #include <map>
32 #include <utils/geom/Position.h>
34 #include <utils/common/Named.h>
36 #include <utils/common/SUMOTime.h>
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class MSVehicle;
45 class MSLink;
46 class MSLane;
47 class MSEdge;
48 
49 typedef std::vector<MSEdge*> MSEdgeVector;
50 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
60 class MSJunction : public Named, public Parameterised {
61 public:
67  MSJunction(const std::string& id,
68  SumoXMLNodeType type,
69  const Position& position,
70  const PositionVector& shape);
71 
72 
74  virtual ~MSJunction();
75 
76 
79  virtual void postloadInit();
80 
81 
83  const Position& getPosition() const;
84 
85 
89  const PositionVector& getShape() const {
90  return myShape;
91  }
92 
93  virtual const std::vector<MSLink*>& getFoeLinks(const MSLink* const /*srcLink*/) const {
94  return myEmptyLinks;
95  }
96 
97  virtual const std::vector<MSLane*>& getFoeInternalLanes(const MSLink* const /*srcLink*/) const {
98  return myEmptyLanes;
99  }
100 
101  inline const ConstMSEdgeVector& getIncoming() const {
102  return myIncoming;
103  }
104 
105  int getNrOfIncomingLanes() const;
106 
107  inline const ConstMSEdgeVector& getOutgoing() const {
108  return myOutgoing;
109  }
110 
113  virtual const std::vector<MSLane*> getInternalLanes() const {
114  return myEmptyLanes;
115  }
116 
117  void addIncoming(MSEdge* edge) {
118  myIncoming.push_back(edge);
119  }
120 
121  void addOutgoing(MSEdge* edge) {
122  myOutgoing.push_back(edge);
123  }
124 
127  return myType;
128  }
129 
131  void passedJunction(const MSVehicle* vehicle);
132 
133  /* @brief @return whether the foe vehicle is a leader for ego
134  * @note vehicles are added to myLinkLeaders when first seen as a foe */
135  bool isLeader(const MSVehicle* ego, const MSVehicle* foe, bool updateLeader);
136 
137 protected:
140 
143 
146 
147  std::vector<MSLink*> myEmptyLinks;
148  std::vector<MSLane*> myEmptyLanes;
149 
150 
155 
157  typedef std::map<std::string, MSJunction* > DictType;
158 
160  typedef std::map<const MSVehicle*, std::set<const MSVehicle*> > LeaderMap;
161  LeaderMap myLinkLeaders;
162 
163 
164 private:
166  MSJunction(const MSJunction&);
167 
170 
171 };
172 
173 
174 #endif
175 
176 /****************************************************************************/
177 
MSJunction & operator=(const MSJunction &)
Invalidated assignment operator.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:117
LeaderMap myLinkLeaders
Definition: MSJunction.h:161
SumoXMLNodeType myType
Tye type of this junction.
Definition: MSJunction.h:139
The base class for an intersection.
Definition: MSJunction.h:60
ConstMSEdgeVector myOutgoing
outgoing edges
Definition: MSJunction.h:154
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSJunction.h:50
std::vector< MSLink * > myEmptyLinks
Definition: MSJunction.h:147
virtual const std::vector< MSLane * > & getFoeInternalLanes(const MSLink *const) const
Definition: MSJunction.h:97
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
virtual ~MSJunction()
Destructor.
Definition: MSJunction.cpp:65
A road/street connecting two junctions.
Definition: MSEdge.h:75
ConstMSEdgeVector myIncoming
incoming edges
Definition: MSJunction.h:152
Position myPosition
The position of the junction.
Definition: MSJunction.h:142
std::vector< MSEdge * > MSEdgeVector
Definition: MSJunction.h:47
MSJunction(const std::string &id, SumoXMLNodeType type, const Position &position, const PositionVector &shape)
Constructor.
Definition: MSJunction.cpp:56
std::map< const MSVehicle *, std::set< const MSVehicle * > > LeaderMap
map from leader vehicle to follower vehicles
Definition: MSJunction.h:160
void passedJunction(const MSVehicle *vehicle)
erase vehicle from myLinkLeaders
Definition: MSJunction.cpp:89
std::map< std::string, MSJunction *> DictType
definition of the static dictionary type
Definition: MSJunction.h:157
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
const ConstMSEdgeVector & getIncoming() const
Definition: MSJunction.h:101
const Position & getPosition() const
Definition: MSJunction.cpp:69
virtual const std::vector< MSLink * > & getFoeLinks(const MSLink *const) const
Definition: MSJunction.h:93
An upper class for objects with additional parameters.
Definition: Parameterised.h:44
virtual const std::vector< MSLane * > getInternalLanes() const
Returns all internal lanes on the junction.
Definition: MSJunction.h:113
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:121
Base class for objects which have an id.
Definition: Named.h:49
const ConstMSEdgeVector & getOutgoing() const
Definition: MSJunction.h:107
bool isLeader(const MSVehicle *ego, const MSVehicle *foe, bool updateLeader)
Definition: MSJunction.cpp:100
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
int getNrOfIncomingLanes() const
Definition: MSJunction.cpp:79
virtual void postloadInit()
Definition: MSJunction.cpp:75
PositionVector myShape
The shape of the junction.
Definition: MSJunction.h:145
std::vector< MSLane * > myEmptyLanes
Definition: MSJunction.h:148
Representation of a lane in the micro simulation.
Definition: MSLane.h:71
const PositionVector & getShape() const
Returns this junction&#39;s shape.
Definition: MSJunction.h:89
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:126