Eclipse SUMO - Simulation of Urban MObility
GUIEventControl Class Reference

Stores time-dependant events and executes them at the proper time (guisim) More...

#include <GUIEventControl.h>

Inheritance diagram for GUIEventControl:
[legend]
Collaboration diagram for GUIEventControl:
[legend]

Public Types

typedef std::pair< Command *, SUMOTimeEvent
 Combination of an event and the time it shall be executed at. More...
 

Public Member Functions

void addEvent (Command *operation, SUMOTime execTimeStep=-1)
 Adds an Event. More...
 
void clearState (SUMOTime currentTime, SUMOTime newTime)
 Remove all events before quick-loading state. More...
 
void execute (SUMOTime time)
 Executes time-dependant commands. More...
 
SUMOTime getEventTime (Command *cmd) const
 get the next scheduled event time for the given command, -2 if it is not scheduled More...
 
 GUIEventControl ()
 Default constructor. More...
 
bool isEmpty ()
 Returns whether events are in the que. More...
 
 ~GUIEventControl ()
 Destructor. More...
 

Static Protected Member Functions

static bool eventCompare (const Event &e1, const Event &e2)
 compares two events More...
 

Private Member Functions

 GUIEventControl (const GUIEventControl &)
 invalid copy constructor. More...
 
GUIEventControloperator= (const GUIEventControl &)
 invalid assignment operator. More...
 

Private Attributes

std::vector< EventmyEvents
 Event-container, holds executable events. More...
 
FXMutex myLock
 The lock used to prohibit parallel addition and processing of events. More...
 

Detailed Description

Stores time-dependant events and executes them at the proper time (guisim)

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 38 of file GUIEventControl.h.

Member Typedef Documentation

◆ Event

typedef std::pair< Command*, SUMOTime > MSEventControl::Event
inherited

Combination of an event and the time it shall be executed at.

Definition at line 50 of file MSEventControl.h.

Constructor & Destructor Documentation

◆ GUIEventControl() [1/2]

GUIEventControl::GUIEventControl ( )

Default constructor.

Definition at line 31 of file GUIEventControl.cpp.

◆ ~GUIEventControl()

GUIEventControl::~GUIEventControl ( )

Destructor.

Definition at line 36 of file GUIEventControl.cpp.

◆ GUIEventControl() [2/2]

GUIEventControl::GUIEventControl ( const GUIEventControl )
private

invalid copy constructor.

Member Function Documentation

◆ addEvent()

void GUIEventControl::addEvent ( Command operation,
SUMOTime  execTimeStep = -1 
)
virtual

Adds an Event.

Locks itself before calling MSEventControl::addEvent. Unlock itself after the call.

Parameters
[in]operationThe event to add
[in]execTimeStepThe time the event shall be executed at (-1 means at sim start)
See also
MSEventControl::addEvent

Reimplemented from MSEventControl.

Definition at line 41 of file GUIEventControl.cpp.

References MSEventControl::addEvent(), and myLock.

◆ clearState()

void MSEventControl::clearState ( SUMOTime  currentTime,
SUMOTime  newTime 
)
inherited

Remove all events before quick-loading state.

Definition at line 103 of file MSEventControl.cpp.

References MSEventControl::eventCompare(), and MSEventControl::myEvents.

Referenced by MSNet::clearState().

Here is the caller graph for this function:

◆ eventCompare()

bool MSEventControl::eventCompare ( const Event e1,
const Event e2 
)
staticprotectedinherited

compares two events

Definition at line 98 of file MSEventControl.cpp.

Referenced by MSEventControl::addEvent(), MSEventControl::clearState(), and MSEventControl::execute().

Here is the caller graph for this function:

◆ execute()

void GUIEventControl::execute ( SUMOTime  time)
virtual

Executes time-dependant commands.

Locks itself before calling MSEventControl::execute. Unlock itself after the call.

Parameters
[in]timeThe current simulation time
Exceptions
ProcessErrorFrom an executed Command
See also
MSEventControl::execute

Reimplemented from MSEventControl.

Definition at line 48 of file GUIEventControl.cpp.

References MSEventControl::execute(), and myLock.

◆ getEventTime()

SUMOTime MSEventControl::getEventTime ( Command cmd) const
inherited

get the next scheduled event time for the given command, -2 if it is not scheduled

◆ isEmpty()

bool MSEventControl::isEmpty ( )
inherited

Returns whether events are in the que.

Returns
whether events are in the que

Definition at line 93 of file MSEventControl.cpp.

References MSEventControl::myEvents.

◆ operator=()

GUIEventControl& GUIEventControl::operator= ( const GUIEventControl )
private

invalid assignment operator.

Field Documentation

◆ myEvents

std::vector<Event> MSEventControl::myEvents
privateinherited

◆ myLock

FXMutex GUIEventControl::myLock
private

The lock used to prohibit parallel addition and processing of events.

Definition at line 74 of file GUIEventControl.h.

Referenced by addEvent(), and execute().


The documentation for this class was generated from the following files: