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-2017 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 
63 public:
66 
67 
69  virtual ~MSEventControl();
70 
71 
78  virtual void addEvent(Command* operation, SUMOTime execTimeStep = -1);
79 
80 
98  virtual void execute(SUMOTime time);
99 
100 
105  bool isEmpty();
106 
107 
114  void setCurrentTimeStep(SUMOTime time);
115 
116 
117 protected:
123  public:
125  bool operator()(const Event& e1, const Event& e2) const {
126  return e1.second > e2.second;
127  }
128  };
129 
130 
131 private:
133  typedef std::priority_queue< Event, std::vector< Event >, EventSortCrit > EventCont;
134 
137 
139  EventCont myEvents;
140 
143 
144 
145 private:
148 
151 
152 
153 };
154 
155 
156 #endif
157 
158 /****************************************************************************/
159 
Sort-criterion for events.
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.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
EventCont myEvents
Event-container, holds executable events.
SUMOTime getCurrentTimeStep()
get the Current TimeStep used in addEvent.
MSEventControl & operator=(const MSEventControl &)
invalid assignment operator.
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.
long long int SUMOTime
Definition: TraCIDefs.h:52
Stores time-dependant events and executes them at the proper time.