Eclipse SUMO - Simulation of Urban MObility
|
A wrapper for a Command function. More...
#include <WrappingCommand.h>
Public Types | |
typedef SUMOTime(T::* | Operation) (SUMOTime) |
Type of the function to execute. | |
Public Member Functions | |
void | deschedule () |
Marks this Command as being descheduled. | |
bool | isDescheduled () |
whether this command has been descheduled | |
virtual SUMOTime | shiftTime (SUMOTime, SUMOTime, SUMOTime) |
Reschedule or deschedule the command when quick-loading state. | |
WrappingCommand (T *receiver, Operation operation) | |
Constructor. | |
~WrappingCommand () | |
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. | |
T * | myReceiver |
The object the action is directed to. | |
A wrapper for a Command function.
In order to ease life, this class may encapsulate a method of a class which in order to be used as a Command. This allows to use a member methods of a class to be called as Commands are, avoiding that the instance itself is destroyed by the EventHandler.
Because in some cases, the Command may live longer than the instance class, a boolean value indicates that the Command is "descheduled". It should be set via "deschedule" as soon as the class instance of which a method is encapsulated is destroyed and forces that the command (calling of this instace's method) is not executed.
Definition at line 49 of file WrappingCommand.h.
typedef SUMOTime(T::* WrappingCommand< T >::Operation) (SUMOTime) |
Type of the function to execute.
Definition at line 52 of file WrappingCommand.h.
|
inline |
Constructor.
[in] | receiver | Pointer to object of type T that will receive a call to one of its methods. |
[in] | operation | The objects' method that will be called on execute() |
Definition at line 62 of file WrappingCommand.h.
|
inline |
Destructor.
Definition at line 68 of file WrappingCommand.h.
|
inline |
Marks this Command as being descheduled.
A simple boolean marker ("myAmDescheduledByParent") is set which prevents this command from being executed.
Definition at line 76 of file WrappingCommand.h.
References WrappingCommand< T >::myAmDescheduledByParent.
Referenced by MSDevice_ToC::awarenessRecoveryStep(), MSDevice_ToC::descheduleMRM(), MSDevice_ToC::descheduleRecovery(), MSDevice_ToC::descheduleToC(), MSDevice_ToC::descheduleToCPreparation(), MSDevice_Routing::rebuildRerouteCommand(), MSTransportable::setAbortWaiting(), MSTransportableDevice_Routing::setParameter(), MSDevice_StationFinder::teleportToChargingStation(), MSDevice_StationFinder::updateChargeLimit(), MSDevice_Routing::~MSDevice_Routing(), MSDevice_StationFinder::~MSDevice_StationFinder(), MSDevice_ToC::~MSDevice_ToC(), and MSTransportableDevice_Routing::~MSTransportableDevice_Routing().
|
inlinevirtual |
Executes the command.
If the command is not descheduled, the stored method of the stored instance is called.
[in] | currentTime | The current simulation time |
ProcessError | Derived actions may throw this exception |
Implements Command.
Definition at line 98 of file WrappingCommand.h.
References WrappingCommand< T >::myAmDescheduledByParent, WrappingCommand< T >::myOperation, and WrappingCommand< T >::myReceiver.
|
inline |
whether this command has been descheduled
Definition at line 81 of file WrappingCommand.h.
References WrappingCommand< T >::myAmDescheduledByParent.
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.
[in] | currentTime | The current simulation time |
[in] | execTime | The time at which the command would have been executed |
[in] | newTime | The simulation time at which the simulation is restarted |
Reimplemented in MSTrafficLightLogic::SwitchCommand, and MSCalibrator::CalibratorCommand.
|
private |
Whether this command was descheduled (is invalid) and shall not be executed.
Definition at line 117 of file WrappingCommand.h.
Referenced by WrappingCommand< T >::deschedule(), WrappingCommand< T >::execute(), and WrappingCommand< T >::isDescheduled().
|
private |
The object's operation to perform.
Definition at line 114 of file WrappingCommand.h.
Referenced by WrappingCommand< T >::execute().
|
private |
The object the action is directed to.
Definition at line 111 of file WrappingCommand.h.
Referenced by WrappingCommand< T >::execute().
|
inherited |
Definition at line 87 of file Command.h.
Referenced by MSTransportableDevice_FCDReplay::MovePedestrians::MovePedestrians(), and MSTrafficLightLogic::SwitchCommand::SwitchCommand().