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 /****************************************************************************/
16 // A wrapper for a Command function
17 /****************************************************************************/
18 #ifndef WrappingCommand_h
19 #define WrappingCommand_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 
26 #include "Command.h"
27 
28 
29 // ===========================================================================
30 // class definition
31 // ===========================================================================
51 template< class T >
52 class WrappingCommand : public Command {
53 public:
55  typedef SUMOTime(T::* Operation)(SUMOTime);
56 
57 
58 public:
65  WrappingCommand(T* receiver, Operation operation)
66  : myReceiver(receiver), myOperation(operation),
67  myAmDescheduledByParent(false) {}
68 
69 
72 
73 
79  void deschedule() {
81  }
82 
84  bool isDescheduled() {
86  }
87 
88 
91 
101  SUMOTime execute(SUMOTime currentTime) {
102  // do not execute if the command was descheduled
104  return 0;
105  }
106  // execute if stil valid
107  return (myReceiver->*myOperation)(currentTime);
108  }
110 
111 
112 private:
115 
118 
121 
122 
123 };
124 
125 
126 #endif
127 
128 /****************************************************************************/
129 
long long int SUMOTime
Definition: SUMOTime.h:35
Operation myOperation
The object&#39;s operation to perform.
Base (microsim) event class.
Definition: Command.h:53
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.