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. | |
WrappingCommand (T *receiver, Operation operation) | |
Constructor. | |
~WrappingCommand () | |
Destructor. | |
Derived from Command | |
SUMOTime | execute (SUMOTime currentTime) |
Executes the command. | |
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 60 of file WrappingCommand.h.
typedef SUMOTime(T::* WrappingCommand< T >::Operation)(SUMOTime) |
Type of the function to execute.
Definition at line 63 of file WrappingCommand.h.
WrappingCommand< T >::WrappingCommand | ( | T * | receiver, |
Operation | operation | ||
) | [inline] |
Constructor.
[in] | receiver | Pointer to object of type T that will receive a call to one of it's methods. |
[in] | operation | The objects' method that will be called on execute() |
Definition at line 73 of file WrappingCommand.h.
WrappingCommand< T >::~WrappingCommand | ( | ) | [inline] |
Destructor.
Definition at line 79 of file WrappingCommand.h.
void WrappingCommand< 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 87 of file WrappingCommand.h.
Referenced by MSDevice_Routing::notifyEnter(), and MSDevice_Routing::~MSDevice_Routing().
SUMOTime WrappingCommand< T >::execute | ( | SUMOTime | currentTime | ) | [inline, virtual] |
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 105 of file WrappingCommand.h.
bool WrappingCommand< T >::myAmDescheduledByParent [private] |
Whether this command was descheduled (is invalid) and shall not be executed.
Definition at line 124 of file WrappingCommand.h.
Referenced by WrappingCommand< MSDevice_Routing >::deschedule(), and WrappingCommand< MSDevice_Routing >::execute().
Operation WrappingCommand< T >::myOperation [private] |
The object's operation to perform.
Definition at line 121 of file WrappingCommand.h.
Referenced by WrappingCommand< MSDevice_Routing >::execute().
T* WrappingCommand< T >::myReceiver [private] |
The object the action is directed to.
Definition at line 118 of file WrappingCommand.h.
Referenced by WrappingCommand< MSDevice_Routing >::execute().