SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WrappingCommand.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A wrapper for a Command function
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef WrappingCommand_h
22 #define WrappingCommand_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "Command.h"
35 
36 
37 // ===========================================================================
38 // class definition
39 // ===========================================================================
59 template< class T >
60 class WrappingCommand : public Command {
61 public:
63  typedef SUMOTime(T::* Operation)(SUMOTime);
64 
65 
66 public:
73  WrappingCommand(T* receiver, Operation operation)
74  : myReceiver(receiver), myOperation(operation),
75  myAmDescheduledByParent(false) {}
76 
77 
80 
81 
87  void deschedule() {
89  }
90 
91 
92 
95 
105  SUMOTime execute(SUMOTime currentTime) {
106  // do not execute if the command was descheduled
108  return 0;
109  }
110  // execute if stil valid
111  return (myReceiver->*myOperation)(currentTime);
112  }
114 
115 
116 private:
119 
122 
125 
126 
127 };
128 
129 
130 #endif
131 
132 /****************************************************************************/
133 
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOTime(T::* Operation)(SUMOTime)
Type of the function to execute.
Operation myOperation
The object's operation to perform.
Base (microsim) event class.
Definition: Command.h:61
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.
bool myAmDescheduledByParent
Whether this command was descheduled (is invalid) and shall not be executed.
T * myReceiver
The object the action is directed to.