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:
Collaboration diagram for GUIEventControl:

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 execute (SUMOTime time)
 Executes time-dependant commands. More...
 
 GUIEventControl ()
 Default constructor. More...
 
bool isEmpty ()
 Returns whether events are in the que. More...
 
void setCurrentTimeStep (SUMOTime time)
 Set the current Time. More...
 
 ~GUIEventControl ()
 Destructor. More...
 

Private Types

typedef std::priority_queue< Event, std::vector< Event >, EventSortCritEventCont
 Container for time-dependant events, e.g. traffic-light-change. More...
 

Private Member Functions

SUMOTime getCurrentTimeStep ()
 get the Current TimeStep used in addEvent. More...
 
 GUIEventControl (const GUIEventControl &)
 invalid copy constructor. More...
 
GUIEventControloperator= (const GUIEventControl &)
 invalid assignment operator. More...
 

Private Attributes

SUMOTime currentTimeStep
 The current TimeStep. More...
 
EventCont myEvents
 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 41 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 53 of file MSEventControl.h.

◆ EventCont

typedef std::priority_queue< Event, std::vector< Event >, EventSortCrit > MSEventControl::EventCont
privateinherited

Container for time-dependant events, e.g. traffic-light-change.

Definition at line 126 of file MSEventControl.h.

Constructor & Destructor Documentation

◆ GUIEventControl() [1/2]

GUIEventControl::GUIEventControl ( )

Default constructor.

Definition at line 33 of file GUIEventControl.cpp.

◆ ~GUIEventControl()

GUIEventControl::~GUIEventControl ( )

Destructor.

Definition at line 38 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 43 of file GUIEventControl.cpp.

References MSEventControl::addEvent(), and myLock.

◆ 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 50 of file GUIEventControl.cpp.

References MSEventControl::execute(), and myLock.

◆ getCurrentTimeStep()

SUMOTime MSEventControl::getCurrentTimeStep ( )
privateinherited

get the Current TimeStep used in addEvent.

Definition at line 106 of file MSEventControl.cpp.

References MSEventControl::currentTimeStep, MSNet::getCurrentTimeStep(), and MSNet::getInstance().

◆ isEmpty()

bool MSEventControl::isEmpty ( )
inherited

Returns whether events are in the que.

Returns
whether events are in the que

Definition at line 96 of file MSEventControl.cpp.

References MSEventControl::myEvents.

◆ operator=()

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

invalid assignment operator.

◆ setCurrentTimeStep()

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 101 of file MSEventControl.cpp.

References MSEventControl::currentTimeStep.

Field Documentation

◆ currentTimeStep

SUMOTime MSEventControl::currentTimeStep
privateinherited

The current TimeStep.

Definition at line 129 of file MSEventControl.h.

Referenced by MSEventControl::getCurrentTimeStep(), and MSEventControl::setCurrentTimeStep().

◆ myEvents

EventCont MSEventControl::myEvents
privateinherited

Event-container, holds executable events.

Definition at line 132 of file MSEventControl.h.

Referenced by MSEventControl::addEvent(), MSEventControl::execute(), MSEventControl::isEmpty(), and MSEventControl::~MSEventControl().

◆ myLock

FXMutex GUIEventControl::myLock
private

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

Definition at line 77 of file GUIEventControl.h.

Referenced by addEvent(), and execute().


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