SUMO - Simulation of Urban MObility
MELoop.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // The main mesocopic simulation loop
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MELoop_h
21 #define MELoop_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <map>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MESegment;
41 class MEVehicle;
42 class MSEdge;
43 class MSLink;
44 class MSVehicleControl;
45 class BinaryInputDevice;
46 class OptionsCont;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
56 class MELoop {
57 public:
59  MELoop(const SUMOTime recheckInterval);
60 
61  ~MELoop();
62 
69  void simulate(SUMOTime tMax);
70 
76  void addLeaderCar(MEVehicle* veh, MSLink* link);
77 
82  void removeLeaderCar(MEVehicle* v);
83 
88  void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
89 
96  MESegment* getSegmentForEdge(const MSEdge& e, SUMOReal pos = 0);
97 
102  bool changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment, const bool ignoreLink = false);
103 
109  static void setApproaching(MEVehicle* veh, MSLink* link);
110 
111 
112 private:
120  void checkCar(MEVehicle* veh);
121 
134 
135 
140  void teleportVehicle(MEVehicle* veh, MESegment* const toSegment);
141 
142 private:
144  std::map<SUMOTime, std::vector<MEVehicle*> > myLeaderCars;
145 
147  std::vector<MESegment*> myEdges2FirstSegments;
148 
151 
154 
155 private:
157  MELoop(const MELoop&);
158 
160  MELoop& operator=(const MELoop&);
161 };
162 
163 
164 #endif
165 
166 /****************************************************************************/
167 
bool changeSegment(MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, const bool ignoreLink=false)
change to the next segment this handles combinations of the following cases: (ending / continuing rou...
Definition: MELoop.cpp:91
MELoop(const SUMOTime recheckInterval)
SUMO constructor.
Definition: MELoop.cpp:58
long long int SUMOTime
Definition: SUMOTime.h:43
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
Definition: MELoop.cpp:235
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:52
~MELoop()
Definition: MELoop.cpp:61
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
Definition: MELoop.h:150
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition: MELoop.h:147
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition: MELoop.cpp:254
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment)
teleports a vehicle or continues a teleport
Definition: MELoop.cpp:156
void removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition: MELoop.cpp:228
A road/street connecting two junctions.
Definition: MSEdge.h:80
The main mesocopic simulation loop.
Definition: MELoop.h:56
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition: MELoop.h:144
static void setApproaching(MEVehicle *veh, MSLink *link)
registers vehicle with the given link
Definition: MELoop.cpp:215
A single mesoscopic segment (cell)
Definition: MESegment.h:57
A storage for options typed value containers)
Definition: OptionsCont.h:108
MELoop & operator=(const MELoop &)
Invalidated assignment operator.
MESegment * getSegmentForEdge(const MSEdge &e, SUMOReal pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:288
const SUMOTime myLinkRecheckInterval
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition: MELoop.h:153
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition: MELoop.cpp:122
#define SUMOReal
Definition: config.h:213
The class responsible for building and deletion of vehicles.
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition: MELoop.cpp:73
Encapsulates binary reading operations on a file.
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:208