Eclipse SUMO - Simulation of Urban MObility
WrappingCommand.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A wrapper for a Command function
16 /****************************************************************************/
17 #ifndef WrappingCommand_h
18 #define WrappingCommand_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
25 #include "Command.h"
26 
27 
28 // ===========================================================================
29 // class definition
30 // ===========================================================================
50 template< class T >
51 class WrappingCommand : public Command {
52 public:
54  typedef SUMOTime(T::* Operation)(SUMOTime);
55 
56 
57 public:
64  WrappingCommand(T* receiver, Operation operation)
65  : myReceiver(receiver), myOperation(operation),
66  myAmDescheduledByParent(false) {}
67 
68 
71 
72 
78  void deschedule() {
80  }
81 
83  bool isDescheduled() {
85  }
86 
87 
90 
100  SUMOTime execute(SUMOTime currentTime) {
101  // do not execute if the command was descheduled
103  return 0;
104  }
105  // execute if stil valid
106  return (myReceiver->*myOperation)(currentTime);
107  }
109 
110 
111 private:
114 
117 
120 
121 
122 };
123 
124 
125 #endif
126 
127 /****************************************************************************/
128 
WrappingCommand::Operation
SUMOTime(T::* Operation)(SUMOTime)
Type of the function to execute.
Definition: WrappingCommand.h:54
WrappingCommand::isDescheduled
bool isDescheduled()
whether this command has been descheduled
Definition: WrappingCommand.h:83
WrappingCommand::deschedule
void deschedule()
Marks this Command as being descheduled.
Definition: WrappingCommand.h:78
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
WrappingCommand
A wrapper for a Command function.
Definition: WrappingCommand.h:51
WrappingCommand::WrappingCommand
WrappingCommand(T *receiver, Operation operation)
Constructor.
Definition: WrappingCommand.h:64
WrappingCommand::execute
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: WrappingCommand.h:100
WrappingCommand::~WrappingCommand
~WrappingCommand()
Destructor.
Definition: WrappingCommand.h:70
WrappingCommand::myReceiver
T * myReceiver
The object the action is directed to.
Definition: WrappingCommand.h:113
Command
Base (microsim) event class.
Definition: Command.h:52
Command.h
WrappingCommand::myOperation
Operation myOperation
The object's operation to perform.
Definition: WrappingCommand.h:116
WrappingCommand::myAmDescheduledByParent
bool myAmDescheduledByParent
Whether this command was descheduled (is invalid) and shall not be executed.
Definition: WrappingCommand.h:119