Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
StaticCommand< T > Class Template Reference

A wrapper for a Command function. More...

#include <StaticCommand.h>

Inheritance diagram for StaticCommand< T >:
[legend]
Collaboration diagram for StaticCommand< T >:
[legend]

Public Types

typedef SUMOTime(* Operation) (SUMOTime)
 Type of the function to execute.
 

Public Member Functions

void deschedule ()
 Marks this Command as being descheduled.
 
virtual SUMOTime shiftTime (SUMOTime, SUMOTime, SUMOTime)
 Reschedule or deschedule the command when quick-loading state.
 
 StaticCommand (Operation operation)
 Constructor.
 
 ~StaticCommand ()
 Destructor.
 
Derived from Command
SUMOTime execute (SUMOTime currentTime)
 Executes the command.
 

Data Fields

int priority = 0
 

Private Attributes

bool myAmDescheduledByParent
 Whether this command was descheduled (is invalid) and shall not be executed.
 
Operation myOperation
 The object's operation to perform.
 

Detailed Description

template<class T>
class StaticCommand< T >

A wrapper for a Command function.

See also
Design Patterns, Gamma et al.
Command
MSEventControl

Definition at line 38 of file StaticCommand.h.

Member Typedef Documentation

◆ Operation

template<class T >
typedef SUMOTime(* StaticCommand< T >::Operation) (SUMOTime)

Type of the function to execute.

Definition at line 41 of file StaticCommand.h.

Constructor & Destructor Documentation

◆ StaticCommand()

template<class T >
StaticCommand< T >::StaticCommand ( Operation  operation)
inline

Constructor.

Parameters
[in]receiverPointer to object of type T that will receive a call to one of its methods.
[in]operationThe objects' method that will be called on execute()

Definition at line 51 of file StaticCommand.h.

◆ ~StaticCommand()

template<class T >
StaticCommand< T >::~StaticCommand ( )
inline

Destructor.

Definition at line 56 of file StaticCommand.h.

Member Function Documentation

◆ deschedule()

template<class T >
void StaticCommand< T >::deschedule ( )
inline

Marks this Command as being descheduled.

A simple boolean marker ("myAmDescheduledByParent") is set which prevents this command from being executed.

Definition at line 64 of file StaticCommand.h.

References StaticCommand< T >::myAmDescheduledByParent.

◆ execute()

template<class T >
SUMOTime StaticCommand< T >::execute ( SUMOTime  currentTime)
inlinevirtual

Executes the command.

If the command is not descheduled, the stored method of the stored instance is called.

Parameters
[in]currentTimeThe current simulation time
Returns
The time after which the command shall be executed again, 0 if this command shall be descheduled.
Exceptions
ProcessErrorDerived actions may throw this exception

Implements Command.

Definition at line 82 of file StaticCommand.h.

References StaticCommand< T >::myAmDescheduledByParent, and StaticCommand< T >::myOperation.

◆ shiftTime()

virtual SUMOTime Command::shiftTime ( SUMOTime  ,
SUMOTime  ,
SUMOTime   
)
inlinevirtualinherited

Reschedule or deschedule the command when quick-loading state.

The implementations should return -1 if the command shall not be re-scheduled, or a value >= 0 that describe the new time at which the command shall be executed again.

Parameters
[in]currentTimeThe current simulation time
[in]execTimeThe time at which the command would have been executed
[in]newTimeThe simulation time at which the simulation is restarted
Returns
The time at which the command shall be executed again

Reimplemented in MSTrafficLightLogic::SwitchCommand, and MSCalibrator::CalibratorCommand.

Definition at line 83 of file Command.h.

Field Documentation

◆ myAmDescheduledByParent

template<class T >
bool StaticCommand< T >::myAmDescheduledByParent
private

Whether this command was descheduled (is invalid) and shall not be executed.

Definition at line 98 of file StaticCommand.h.

Referenced by StaticCommand< T >::deschedule(), and StaticCommand< T >::execute().

◆ myOperation

template<class T >
Operation StaticCommand< T >::myOperation
private

The object's operation to perform.

Definition at line 95 of file StaticCommand.h.

Referenced by StaticCommand< T >::execute().

◆ priority

int Command::priority = 0
inherited

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