Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/guisim/GUIEventControl.h
169665 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GUIEventControl.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @date Mon, 04 Feb 2008
18
///
19
// Stores time-dependant events and executes them at the proper time (guisim)
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <utils/foxtools/fxheader.h>
25
#include <microsim/MSEventControl.h>
26
27
28
// ===========================================================================
29
// class definitions
30
// ===========================================================================
31
/**
32
* @class GUIEventControl
33
* @brief Stores time-dependant events and executes them at the proper time (guisim)
34
*
35
* Encapsulates MSEventControl-methods using a lock, prohibiting parallel addition /
36
* processing of events what may yield in application break due to broken containers.
37
*/
38
class GUIEventControl : public MSEventControl {
39
public:
40
/// @brief Default constructor.
41
GUIEventControl();
42
43
44
/// @brief Destructor.
45
~GUIEventControl();
46
47
48
/** @brief Adds an Event.
49
*
50
* Locks itself before calling MSEventControl::addEvent. Unlock itself
51
* after the call.
52
*
53
* @param[in] operation The event to add
54
* @param[in] execTimeStep The time the event shall be executed at (-1 means at sim start)
55
* @see MSEventControl::addEvent
56
*/
57
void addEvent(Command* operation, SUMOTime execTimeStep = -1);
58
59
60
/** @brief Executes time-dependant commands
61
*
62
* Locks itself before calling MSEventControl::execute. Unlock itself
63
* after the call.
64
*
65
* @param[in] time The current simulation time
66
* @exception ProcessError From an executed Command
67
* @see MSEventControl::execute
68
*/
69
void execute(SUMOTime time);
70
71
72
private:
73
/// @brief The lock used to prohibit parallel addition and processing of events
74
FXMutex myLock;
75
76
77
private:
78
/// @brief invalid copy constructor.
79
GUIEventControl(const GUIEventControl&);
80
81
/// @brief invalid assignment operator.
82
GUIEventControl& operator=(const GUIEventControl&);
83
84
85
};
86
87