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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // A wrapper for a Command function
19 /****************************************************************************/
20 #ifndef WrappingCommand_h
21 #define WrappingCommand_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "Command.h"
34 
35 
36 // ===========================================================================
37 // class definition
38 // ===========================================================================
58 template< class T >
59 class WrappingCommand : public Command {
60 public:
62  typedef SUMOTime(T::* Operation)(SUMOTime);
63 
64 
65 public:
72  WrappingCommand(T* receiver, Operation operation)
73  : myReceiver(receiver), myOperation(operation),
74  myAmDescheduledByParent(false) {}
75 
76 
79 
80 
86  void deschedule() {
88  }
89 
90 
91 
94 
104  SUMOTime execute(SUMOTime currentTime) {
105  // do not execute if the command was descheduled
107  return 0;
108  }
109  // execute if stil valid
110  return (myReceiver->*myOperation)(currentTime);
111  }
113 
114 
115 private:
118 
121 
124 
125 
126 };
127 
128 
129 #endif
130 
131 /****************************************************************************/
132 
Operation myOperation
The object&#39;s operation to perform.
Base (microsim) event class.
Definition: Command.h:60
SUMOTime(T::* Operation)(SUMOTime)
Type of the function to execute.
SUMOTime execute(SUMOTime currentTime)
Executes the command.
WrappingCommand(T *receiver, Operation operation)
Constructor.
~WrappingCommand()
Destructor.
A wrapper for a Command function.
void deschedule()
Marks this Command as being descheduled.
long long int SUMOTime
Definition: TraCIDefs.h:51
bool myAmDescheduledByParent
Whether this command was descheduled (is invalid) and shall not be executed.
T * myReceiver
The object the action is directed to.