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-2018 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 /****************************************************************************/
16 // A wrapper for a Command function
17 /****************************************************************************/
18 #ifndef WrappingCommand_h
19 #define WrappingCommand_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include "Command.h"
28 
29 
30 // ===========================================================================
31 // class definition
32 // ===========================================================================
52 template< class T >
53 class WrappingCommand : public Command {
54 public:
56  typedef SUMOTime(T::* Operation)(SUMOTime);
57 
58 
59 public:
66  WrappingCommand(T* receiver, Operation operation)
67  : myReceiver(receiver), myOperation(operation),
68  myAmDescheduledByParent(false) {}
69 
70 
73 
74 
80  void deschedule() {
82  }
83 
85  bool isDescheduled() {
87  }
88 
89 
92 
102  SUMOTime execute(SUMOTime currentTime) {
103  // do not execute if the command was descheduled
105  return 0;
106  }
107  // execute if stil valid
108  return (myReceiver->*myOperation)(currentTime);
109  }
111 
112 
113 private:
116 
119 
122 
123 
124 };
125 
126 
127 #endif
128 
129 /****************************************************************************/
130 
long long int SUMOTime
Definition: SUMOTime.h:36
Operation myOperation
The object&#39;s operation to perform.
Base (microsim) event class.
Definition: Command.h:54
SUMOTime(T::* Operation)(SUMOTime)
Type of the function to execute.
SUMOTime execute(SUMOTime currentTime)
Executes the command.
WrappingCommand(T *receiver, Operation operation)
Constructor.
bool isDescheduled()
whether this command has been descheduled
~WrappingCommand()
Destructor.
A wrapper for a Command function.
void deschedule()
Marks this Command as being descheduled.
bool myAmDescheduledByParent
Whether this command was descheduled (is invalid) and shall not be executed.
T * myReceiver
The object the action is directed to.