Eclipse SUMO - Simulation of Urban MObility
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) More...
 

Public Member Functions

void deschedule ()
 Marks this Command as being descheduled. More...
 
bool isDescheduled ()
 whether this command has been descheduled More...
 
 ParametrisedWrappingCommand (T *receiver, const S &param, Operation operation)
 Constructor. More...
 
virtual SUMOTime shiftTime (SUMOTime, SUMOTime, SUMOTime)
 Reschedule or deschedule the command when quick-loading state. More...
 
 ~ParametrisedWrappingCommand ()
 Destructor. More...
 
Derived from Command
SUMOTime execute (SUMOTime currentTime)
 Executes the command. More...
 

Private Attributes

bool myAmDescheduledByParent
 Whether this command was descheduled (is invalid) and shall not be executed. More...
 
Operation myOperation
 The object's operation to perform. More...
 
myParameter
 The parameter. More...
 
T * myReceiver
 The object the action is directed to. More...
 

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 35 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 39 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 it's methods.
[in]parameterThe methods parameter (must be copy-constructable)
[in]operationThe objects' method that will be called on execute()

Definition at line 50 of file ParametrisedWrappingCommand.h.

◆ ~ParametrisedWrappingCommand()

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

Destructor.

Definition at line 56 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 64 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 86 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 69 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.

Definition at line 82 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 108 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 105 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 102 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 99 of file ParametrisedWrappingCommand.h.

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


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