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-2016 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 // ===========================================================================
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 {
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 
113  void addIncoming(MSEdge* edge) {
114  myIncoming.push_back(edge);
115  }
116 
117  void addOutgoing(MSEdge* edge) {
118  myOutgoing.push_back(edge);
119  }
120 
123  return myType;
124  }
125 
127  void passedJunction(const MSVehicle* vehicle);
128 
129  /* @brief @return whether the foe vehicle is a leader for ego
130  * @note vehicles are added to myLinkLeaders when first seen as a foe */
131  bool isLeader(const MSVehicle* ego, const MSVehicle* foe);
132 
133 protected:
136 
139 
142 
143  std::vector<MSLink*> myEmptyLinks;
144  std::vector<MSLane*> myEmptyLanes;
145 
146 
151 
153  typedef std::map<std::string, MSJunction* > DictType;
154 
156  typedef std::map<const MSVehicle*, std::set<const MSVehicle*> > LeaderMap;
157  LeaderMap myLinkLeaders;
158 
159 
160 private:
162  MSJunction(const MSJunction&);
163 
166 
167 };
168 
169 
170 #endif
171 
172 /****************************************************************************/
173 
MSJunction & operator=(const MSJunction &)
Invalidated assignment operator.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:82
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:113
LeaderMap myLinkLeaders
Definition: MSJunction.h:157
SumoXMLNodeType myType
Tye type of this junction.
Definition: MSJunction.h:135
The base class for an intersection.
Definition: MSJunction.h:64
ConstMSEdgeVector myOutgoing
outgoing edges
Definition: MSJunction.h:150
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSJunction.h:53
std::vector< MSLink * > myEmptyLinks
Definition: MSJunction.h:143
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:63
A road/street connecting two junctions.
Definition: MSEdge.h:80
ConstMSEdgeVector myIncoming
incoming edges
Definition: MSJunction.h:148
Position myPosition
The position of the junction.
Definition: MSJunction.h:138
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:156
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:153
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
const ConstMSEdgeVector & getIncoming() const
Definition: MSJunction.h:105
const Position & getPosition() const
Definition: MSJunction.cpp:67
virtual const std::vector< MSLink * > & getFoeLinks(const MSLink *const) const
Definition: MSJunction.h:97
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:117
Base class for objects which have an id.
Definition: Named.h:46
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:73
PositionVector myShape
The shape of the junction.
Definition: MSJunction.h:141
std::vector< MSLane * > myEmptyLanes
Definition: MSJunction.h:144
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
bool isLeader(const MSVehicle *ego, const MSVehicle *foe)
Definition: MSJunction.cpp:83
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:122