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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // The base class for an intersection
21 /****************************************************************************/
22 #ifndef MSJunction_h
23 #define MSJunction_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <vector>
37 #include <map>
38 #include <utils/geom/Position.h>
40 #include <utils/common/Named.h>
42 #include <utils/common/SUMOTime.h>
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
50 class MSVehicle;
51 class MSLink;
52 class MSLane;
53 class MSEdge;
54 
55 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
64 class MSJunction : public Named, public Parameterised {
65 public:
71  MSJunction(const std::string& id,
72  SumoXMLNodeType type,
73  const Position& position,
74  const PositionVector& shape);
75 
76 
78  virtual ~MSJunction();
79 
80 
83  virtual void postloadInit();
84 
85 
87  const Position& getPosition() const;
88 
89 
93  const PositionVector& getShape() const {
94  return myShape;
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  inline const ConstMSEdgeVector& getOutgoing() const {
110  return myOutgoing;
111  }
112 
115  virtual const std::vector<MSLane*> getInternalLanes() const {
116  return myEmptyLanes;
117  }
118 
119  void addIncoming(MSEdge* edge) {
120  myIncoming.push_back(edge);
121  }
122 
123  void addOutgoing(MSEdge* edge) {
124  myOutgoing.push_back(edge);
125  }
126 
129  return myType;
130  }
131 
133  void passedJunction(const MSVehicle* vehicle);
134 
135  /* @brief @return whether the foe vehicle is a leader for ego
136  * @note vehicles are added to myLinkLeaders when first seen as a foe */
137  bool isLeader(const MSVehicle* ego, const MSVehicle* foe);
138 
139 protected:
142 
145 
148 
149  std::vector<MSLink*> myEmptyLinks;
150  std::vector<MSLane*> myEmptyLanes;
151 
152 
157 
159  typedef std::map<std::string, MSJunction* > DictType;
160 
162  typedef std::map<const MSVehicle*, std::set<const MSVehicle*> > LeaderMap;
163  LeaderMap myLinkLeaders;
164 
165 
166 private:
168  MSJunction(const MSJunction&);
169 
172 
173 };
174 
175 
176 #endif
177 
178 /****************************************************************************/
179 
MSJunction & operator=(const MSJunction &)
Invalidated assignment operator.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:119
LeaderMap myLinkLeaders
Definition: MSJunction.h:163
SumoXMLNodeType myType
Tye type of this junction.
Definition: MSJunction.h:141
The base class for an intersection.
Definition: MSJunction.h:64
ConstMSEdgeVector myOutgoing
outgoing edges
Definition: MSJunction.h:156
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSJunction.h:53
std::vector< MSLink * > myEmptyLinks
Definition: MSJunction.h:149
virtual const std::vector< MSLane * > & getFoeInternalLanes(const MSLink *const) const
Definition: MSJunction.h:101
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
virtual ~MSJunction()
Destructor.
Definition: MSJunction.cpp:58
A road/street connecting two junctions.
Definition: MSEdge.h:80
ConstMSEdgeVector myIncoming
incoming edges
Definition: MSJunction.h:154
Position myPosition
The position of the junction.
Definition: MSJunction.h:144
MSJunction(const std::string &id, SumoXMLNodeType type, const Position &position, const PositionVector &shape)
Constructor.
Definition: MSJunction.cpp:49
std::map< const MSVehicle *, std::set< const MSVehicle * > > LeaderMap
map from leader vehicle to follower vehicles
Definition: MSJunction.h:162
void passedJunction(const MSVehicle *vehicle)
erase vehicle from myLinkLeaders
Definition: MSJunction.cpp:72
std::map< std::string, MSJunction *> DictType
definition of the static dictionary type
Definition: MSJunction.h:159
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
const ConstMSEdgeVector & getIncoming() const
Definition: MSJunction.h:105
const Position & getPosition() const
Definition: MSJunction.cpp:62
virtual const std::vector< MSLink * > & getFoeLinks(const MSLink *const) const
Definition: MSJunction.h:97
An upper class for objects with additional parameters.
Definition: Parameterised.h:50
virtual const std::vector< MSLane * > getInternalLanes() const
Returns all internal lanes on the junction.
Definition: MSJunction.h:115
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:123
Base class for objects which have an id.
Definition: Named.h:54
const ConstMSEdgeVector & getOutgoing() const
Definition: MSJunction.h:109
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
virtual void postloadInit()
Definition: MSJunction.cpp:68
PositionVector myShape
The shape of the junction.
Definition: MSJunction.h:147
std::vector< MSLane * > myEmptyLanes
Definition: MSJunction.h:150
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
bool isLeader(const MSVehicle *ego, const MSVehicle *foe)
Definition: MSJunction.cpp:78
const PositionVector & getShape() const
Returns this junction&#39;s shape.
Definition: MSJunction.h:93
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:128