SUMO - Simulation of Urban MObility
MSEventControl.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Stores time-dependant events and executes them at the proper time
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 MSEventControl_h
24 #define MSEventControl_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 <utility>
37 #include <queue>
38 #include <vector>
39 #include <map>
40 #include <utils/common/SUMOTime.h>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class Command;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
58 public:
60  typedef std::pair< Command*, SUMOTime > Event;
61 
62 
67  enum AdaptType {
72  };
73 
74 
75 public:
78 
79 
81  virtual ~MSEventControl();
82 
83 
98  virtual SUMOTime addEvent(Command* operation, SUMOTime execTimeStep,
99  AdaptType type);
100 
101 
119  virtual void execute(SUMOTime time);
120 
121 
126  bool isEmpty();
127 
128 
135  void setCurrentTimeStep(SUMOTime time);
136 
137 
138 protected:
144  public:
146  bool operator()(const Event& e1, const Event& e2) const {
147  return e1.second > e2.second;
148  }
149  };
150 
151 
152 private:
154  typedef std::priority_queue< Event, std::vector< Event >, EventSortCrit > EventCont;
155 
158 
160  EventCont myEvents;
161 
164 
165 
166 private:
169 
172 
173 
174 };
175 
176 
177 #endif
178 
179 /****************************************************************************/
180 
Sort-criterion for events.
long long int SUMOTime
Definition: SUMOTime.h:43
MSEventControl()
Default constructor.
virtual void execute(SUMOTime time)
Executes time-dependant commands.
Base (microsim) event class.
Definition: Command.h:61
bool operator()(const Event &e1, const Event &e2) const
compares two events
SUMOTime currentTimeStep
The Current TimeStep.
void setCurrentTimeStep(SUMOTime time)
Set the current Time.
std::pair< Command *, SUMOTime > Event
Combination of an event and the time it shall be executed at.
AdaptType
Defines what to do if the insertion time lies before the current simulation time. ...
EventCont myEvents
Event-container, holds executable events.
SUMOTime getCurrentTimeStep()
get the Current TimeStep used in addEvent.
MSEventControl & operator=(const MSEventControl &)
invalid assignment operator.
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
virtual ~MSEventControl()
Destructor.
bool isEmpty()
Returns whether events are in the que.
std::priority_queue< Event, std::vector< Event >, EventSortCrit > EventCont
Container for time-dependant events, e.g. traffic-light-change.
Patch the time in a way that it is at least as high as the simulation begin time. ...
Stores time-dependant events and executes them at the proper time.