SUMO - Simulation of Urban MObility
StaticCommand.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 StaticCommand_h
21 #define StaticCommand_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 // ===========================================================================
47 template< class T >
48 class StaticCommand : public Command {
49 public:
52 
53 
54 public:
62  : myOperation(operation), myAmDescheduledByParent(false) {}
63 
64 
67 
68 
74  void deschedule() {
76  }
77 
78 
79 
82 
92  SUMOTime execute(SUMOTime currentTime) {
93  // do not execute if the command was descheduled
95  return 0;
96  }
97  // execute if stil valid
98  return (*myOperation)(currentTime);
99  }
101 
102 
103 private:
106 
109 
110 
111 };
112 
113 
114 #endif
115 
116 /****************************************************************************/
117 
Base (microsim) event class.
Definition: Command.h:60
A wrapper for a Command function.
Definition: StaticCommand.h:48
StaticCommand(Operation operation)
Constructor.
Definition: StaticCommand.h:61
Operation myOperation
The object&#39;s operation to perform.
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: StaticCommand.h:92
bool myAmDescheduledByParent
Whether this command was descheduled (is invalid) and shall not be executed.
~StaticCommand()
Destructor.
Definition: StaticCommand.h:66
long long int SUMOTime
Definition: TraCIDefs.h:51
SUMOTime(* Operation)(SUMOTime)
Type of the function to execute.
Definition: StaticCommand.h:51
void deschedule()
Marks this Command as being descheduled.
Definition: StaticCommand.h:74