Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSEventControl.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// Stores time-dependant events and executes them at the proper time
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <utility>
27#include <queue>
28#include <vector>
29#include <map>
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class Command;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
48public:
50 typedef std::pair< Command*, SUMOTime > Event;
51
52
53public:
56
57
59 virtual ~MSEventControl();
60
61
68 virtual void addEvent(Command* operation, SUMOTime execTimeStep = -1);
69
70
88 virtual void execute(SUMOTime time);
89
90
95 bool isEmpty();
96
98 void clearState(SUMOTime currentTime, SUMOTime newTime);
99
102
103protected:
105 static bool eventCompare(const Event& e1, const Event& e2);
106
107
108private:
110 std::vector<Event> myEvents;
111
112
113private:
116
119
120
121};
long long int SUMOTime
Definition GUI.h:36
Base (microsim) event class.
Definition Command.h:50
Stores time-dependant events and executes them at the proper time.
virtual void execute(SUMOTime time)
Executes time-dependant commands.
static bool eventCompare(const Event &e1, const Event &e2)
compares two events
bool isEmpty()
Returns whether events are in the que.
SUMOTime getEventTime(Command *cmd) const
get the next scheduled event time for the given command, -2 if it is not scheduled
MSEventControl(const MSEventControl &)
invalid copy constructor.
std::pair< Command *, SUMOTime > Event
Combination of an event and the time it shall be executed at.
MSEventControl()
Default constructor.
void clearState(SUMOTime currentTime, SUMOTime newTime)
Remove all events before quick-loading state.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
MSEventControl & operator=(const MSEventControl &)
invalid assignment operator.
virtual ~MSEventControl()
Destructor.
std::vector< Event > myEvents
Event-container, holds executable events.