#include <GUIEventControl.h>

Encapsulates MSEventControl-methods using a lock, prohibiting parallel addition / processing of events what may yield in application break due to broken containers.
Definition at line 46 of file GUIEventControl.h.
Public Types | |
| enum | AdaptType { ADAPT_AFTER_EXECUTION = 1, NO_CHANGE = 2 } |
| Defines what to do if the insertion time lies before the current simulation time. More... | |
| typedef std::pair< Command *, SUMOTime > | Event |
| Combination of an event and the time it shall be executed at. | |
Public Member Functions | |
| SUMOTime | addEvent (Command *operation, SUMOTime execTimeStep, AdaptType type) throw () |
| Adds an Event. | |
| void | execute (SUMOTime time) throw (ProcessError) |
| Executes time-dependant commands. | |
| GUIEventControl () throw () | |
| Default constructor. | |
| bool | isEmpty () throw () |
| Returns whether events are in the que. | |
| void | setCurrentTimeStep (SUMOTime time) |
| Set the current Time. | |
| ~GUIEventControl () throw () | |
| Destructor. | |
Private Member Functions | |
| GUIEventControl (const GUIEventControl &) | |
| invalid copy constructor. | |
| GUIEventControl & | operator= (const GUIEventControl &) |
| invalid assignment operator. | |
Private Attributes | |
| MFXMutex | myLock |
| The lock used to prohibit parallel addition and processing of events. | |
typedef std::pair< Command*, SUMOTime > MSEventControl::Event [inherited] |
Combination of an event and the time it shall be executed at.
Definition at line 56 of file MSEventControl.h.
enum MSEventControl::AdaptType [inherited] |
Defines what to do if the insertion time lies before the current simulation time.
| ADAPT_AFTER_EXECUTION | Patch the time in a way that it is at least as high as the simulation begin time. |
| NO_CHANGE | Do nothing. |
Definition at line 63 of file MSEventControl.h.
00063 { 00065 ADAPT_AFTER_EXECUTION = 1, 00067 NO_CHANGE = 2 00068 };
| GUIEventControl::GUIEventControl | ( | ) | throw () |
| GUIEventControl::~GUIEventControl | ( | ) | throw () |
| GUIEventControl::GUIEventControl | ( | const GUIEventControl & | ) | [private] |
invalid copy constructor.
| SUMOTime GUIEventControl::addEvent | ( | Command * | operation, | |
| SUMOTime | execTimeStep, | |||
| AdaptType | type | |||
| ) | throw () [virtual] |
Adds an Event.
Locks itself before calling MSEventControl::addEvent. Unlock itself after the call.
| [in] | operation | The event to add |
| [in] | execTimeStep | The time the event shall be executed at |
| [in] | type | The adaptation type |
Reimplemented from MSEventControl.
Definition at line 52 of file GUIEventControl.cpp.
References MSEventControl::addEvent(), MFXMutex::lock(), myLock, and MFXMutex::unlock().
00054 { 00055 myLock.lock(); 00056 SUMOTime ret = MSEventControl::addEvent(operation, execTimeStep, type); 00057 myLock.unlock(); 00058 return ret; 00059 }
| void GUIEventControl::execute | ( | SUMOTime | time | ) | throw (ProcessError) [virtual] |
Executes time-dependant commands.
Locks itself before calling MSEventControl::execute. Unlock itself after the call.
| [in] | time | The current simulation time |
| ProcessError | From an executed Command |
Reimplemented from MSEventControl.
Definition at line 63 of file GUIEventControl.cpp.
References MSEventControl::execute(), MFXMutex::lock(), myLock, and MFXMutex::unlock().
00063 { 00064 myLock.lock(); 00065 try { 00066 MSEventControl::execute(execTime); 00067 } catch (ProcessError &) { 00068 myLock.unlock(); 00069 throw; 00070 } 00071 myLock.unlock(); 00072 }
| bool MSEventControl::isEmpty | ( | ) | throw () [inherited] |
Returns whether events are in the que.
Definition at line 114 of file MSEventControl.cpp.
References MSEventControl::myEvents.
Referenced by MSNet::simulationState().
00114 { 00115 return myEvents.empty(); 00116 }
| GUIEventControl& GUIEventControl::operator= | ( | const GUIEventControl & | ) | [private] |
invalid assignment operator.
| void MSEventControl::setCurrentTimeStep | ( | SUMOTime | time | ) | [inherited] |
Set the current Time.
This method is only for Unit Testing. Set the current TimeStep used in addEvent. Normally the time is set automatically from an instance of MSNet.
Definition at line 119 of file MSEventControl.cpp.
References MSEventControl::currentTimeStep.
Referenced by TEST().
00119 { 00120 currentTimeStep = time; 00121 }
MFXMutex GUIEventControl::myLock [private] |
The lock used to prohibit parallel addition and processing of events.
Definition at line 84 of file GUIEventControl.h.
Referenced by addEvent(), and execute().
1.5.6