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

A wrapper for a Command function with parameter. More...

#include <ParametrisedWrappingCommand.h>

Inheritance diagram for ParametrisedWrappingCommand< T, S >:
[legend]
Collaboration diagram for ParametrisedWrappingCommand< T, S >:
[legend]

Public Types

typedef SUMOTime(T::* Operation) (SUMOTime, S)
 Type of the function to execute. (with parameter)
 

Public Member Functions

void deschedule ()
 Marks this Command as being descheduled.
 
bool isDescheduled ()
 whether this command has been descheduled
 
 ParametrisedWrappingCommand (T *receiver, const S &param, Operation operation)
 Constructor.
 
virtual SUMOTime shiftTime (SUMOTime, SUMOTime, SUMOTime)
 Reschedule or deschedule the command when quick-loading state.
 
 ~ParametrisedWrappingCommand ()
 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.
 
myParameter
 The parameter.
 
T * myReceiver
 The object the action is directed to.
 

Detailed Description

template<class T, class S>
class ParametrisedWrappingCommand< T, S >

A wrapper for a Command function with parameter.

See also
WrappingCommand.h

Definition at line 36 of file ParametrisedWrappingCommand.h.

Member Typedef Documentation

◆ Operation

template<class T , class S >
typedef SUMOTime(T::* ParametrisedWrappingCommand< T, S >::Operation) (SUMOTime, S)

Type of the function to execute. (with parameter)

Definition at line 40 of file ParametrisedWrappingCommand.h.

Constructor & Destructor Documentation

◆ ParametrisedWrappingCommand()

template<class T , class S >
ParametrisedWrappingCommand< T, S >::ParametrisedWrappingCommand ( T *  receiver,
const S &  param,
Operation  operation 
)
inline

Constructor.

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

Definition at line 51 of file ParametrisedWrappingCommand.h.

◆ ~ParametrisedWrappingCommand()

template<class T , class S >
ParametrisedWrappingCommand< T, S >::~ParametrisedWrappingCommand ( )
inline

Destructor.

Definition at line 57 of file ParametrisedWrappingCommand.h.

Member Function Documentation

◆ deschedule()

template<class T , class S >
void ParametrisedWrappingCommand< T, S >::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 65 of file ParametrisedWrappingCommand.h.

References ParametrisedWrappingCommand< T, S >::myAmDescheduledByParent.

◆ execute()

template<class T , class S >
SUMOTime ParametrisedWrappingCommand< T, S >::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 87 of file ParametrisedWrappingCommand.h.

References ParametrisedWrappingCommand< T, S >::myAmDescheduledByParent, ParametrisedWrappingCommand< T, S >::myOperation, ParametrisedWrappingCommand< T, S >::myParameter, and ParametrisedWrappingCommand< T, S >::myReceiver.

◆ isDescheduled()

template<class T , class S >
bool ParametrisedWrappingCommand< T, S >::isDescheduled ( )
inline

whether this command has been descheduled

Definition at line 70 of file ParametrisedWrappingCommand.h.

References ParametrisedWrappingCommand< T, S >::myAmDescheduledByParent.

◆ 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 , class S >
bool ParametrisedWrappingCommand< T, S >::myAmDescheduledByParent
private

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

Definition at line 109 of file ParametrisedWrappingCommand.h.

Referenced by ParametrisedWrappingCommand< T, S >::deschedule(), ParametrisedWrappingCommand< T, S >::execute(), and ParametrisedWrappingCommand< T, S >::isDescheduled().

◆ myOperation

template<class T , class S >
Operation ParametrisedWrappingCommand< T, S >::myOperation
private

The object's operation to perform.

Definition at line 106 of file ParametrisedWrappingCommand.h.

Referenced by ParametrisedWrappingCommand< T, S >::execute().

◆ myParameter

template<class T , class S >
S ParametrisedWrappingCommand< T, S >::myParameter
private

The parameter.

Definition at line 103 of file ParametrisedWrappingCommand.h.

Referenced by ParametrisedWrappingCommand< T, S >::execute().

◆ myReceiver

template<class T , class S >
T* ParametrisedWrappingCommand< T, S >::myReceiver
private

The object the action is directed to.

Definition at line 100 of file ParametrisedWrappingCommand.h.

Referenced by ParametrisedWrappingCommand< T, S >::execute().

◆ priority

int Command::priority = 0
inherited

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