SUMO - Simulation of Urban MObility
MSJunction.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The base class for an intersection
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSJunction_h
24 #define MSJunction_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <vector>
38 #include <map>
39 #include <utils/geom/Position.h>
41 #include <utils/common/Named.h>
42 #include <utils/common/SUMOTime.h>
45 
46 
47 class MSVehicle;
48 class MSLink;
49 class MSLane;
50 class MSEdge;
51 
52 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
61 class MSJunction : public Named {
62 public:
68  MSJunction(const std::string& id,
69  SumoXMLNodeType type,
70  const Position& position,
71  const PositionVector& shape);
72 
73 
75  virtual ~MSJunction();
76 
77 
80  virtual void postloadInit();
81 
82 
84  const Position& getPosition() const;
85 
86 
90  const PositionVector& getShape() const {
91  return myShape;
92  }
93 
94  virtual const std::vector<MSLink*>& getFoeLinks(const MSLink* const /*srcLink*/) const {
95  return myEmptyLinks;
96  }
97 
98  virtual const std::vector<MSLane*>& getFoeInternalLanes(const MSLink* const /*srcLink*/) const {
99  return myEmptyLanes;
100  }
101 
102  inline const ConstMSEdgeVector& getIncoming() const {
103  return myIncoming;
104  }
105 
106  inline const ConstMSEdgeVector& getOutgoing() const {
107  return myOutgoing;
108  }
109 
110  void addIncoming(MSEdge* edge) {
111  myIncoming.push_back(edge);
112  }
113 
114  void addOutgoing(MSEdge* edge) {
115  myOutgoing.push_back(edge);
116  }
117 
120  return myType;
121  }
122 
124  void passedJunction(const MSVehicle* vehicle);
125 
126  /* @brief @return whether the foe vehicle is a leader for ego
127  * @note vehicles are added to myLinkLeaders when first seen as a foe */
128  bool isLeader(const MSVehicle* ego, const MSVehicle* foe);
129 
130 protected:
133 
136 
139 
140  std::vector<MSLink*> myEmptyLinks;
141  std::vector<MSLane*> myEmptyLanes;
142 
143 
148 
150  typedef std::map<std::string, MSJunction* > DictType;
151 
153  typedef std::map<const MSVehicle*, std::set<const MSVehicle*> > LeaderMap;
154  LeaderMap myLinkLeaders;
155 
156 
157 private:
159  MSJunction(const MSJunction&);
160 
163 
164 };
165 
166 
167 #endif
168 
169 /****************************************************************************/
170 
MSJunction & operator=(const MSJunction &)
Invalidated assignment operator.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
virtual const std::vector< MSLink * > & getFoeLinks(const MSLink *const ) const
Definition: MSJunction.h:94
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:110
LeaderMap myLinkLeaders
Definition: MSJunction.h:154
SumoXMLNodeType myType
Tye type of this junction.
Definition: MSJunction.h:132
The base class for an intersection.
Definition: MSJunction.h:61
ConstMSEdgeVector myOutgoing
outgoing edges
Definition: MSJunction.h:147
const PositionVector & getShape() const
Returns this junction&#39;s shape.
Definition: MSJunction.h:90
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSJunction.h:50
std::vector< MSLink * > myEmptyLinks
Definition: MSJunction.h:140
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
virtual ~MSJunction()
Destructor.
Definition: MSJunction.cpp:63
A road/street connecting two junctions.
Definition: MSEdge.h:81
ConstMSEdgeVector myIncoming
incoming edges
Definition: MSJunction.h:145
Position myPosition
The position of the junction.
Definition: MSJunction.h:135
MSJunction(const std::string &id, SumoXMLNodeType type, const Position &position, const PositionVector &shape)
Constructor.
Definition: MSJunction.cpp:54
std::map< const MSVehicle *, std::set< const MSVehicle * > > LeaderMap
map from leader vehicle to follower vehicles
Definition: MSJunction.h:153
void passedJunction(const MSVehicle *vehicle)
erase vehicle from myLinkLeaders
Definition: MSJunction.cpp:77
std::map< std::string, MSJunction * > DictType
definition of the static dictionary type
Definition: MSJunction.h:150
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:119
const ConstMSEdgeVector & getOutgoing() const
Definition: MSJunction.h:106
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:114
Base class for objects which have an id.
Definition: Named.h:45
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
virtual void postloadInit()
Definition: MSJunction.cpp:73
virtual const std::vector< MSLane * > & getFoeInternalLanes(const MSLink *const ) const
Definition: MSJunction.h:98
PositionVector myShape
The shape of the junction.
Definition: MSJunction.h:138
const ConstMSEdgeVector & getIncoming() const
Definition: MSJunction.h:102
std::vector< MSLane * > myEmptyLanes
Definition: MSJunction.h:141
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
bool isLeader(const MSVehicle *ego, const MSVehicle *foe)
Definition: MSJunction.cpp:83
const Position & getPosition() const
Definition: MSJunction.cpp:67