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-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 StaticCommand_h
19 #define StaticCommand_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include "Command.h"
28 
29 
30 // ===========================================================================
31 // class definition
32 // ===========================================================================
41 template< class T >
42 class StaticCommand : public Command {
43 public:
46 
47 
48 public:
56  : myOperation(operation), myAmDescheduledByParent(false) {}
57 
58 
61 
62 
68  void deschedule() {
70  }
71 
72 
73 
76 
86  SUMOTime execute(SUMOTime currentTime) {
87  // do not execute if the command was descheduled
89  return 0;
90  }
91  // execute if stil valid
92  return (*myOperation)(currentTime);
93  }
95 
96 
97 private:
100 
103 
104 
105 };
106 
107 
108 #endif
109 
110 /****************************************************************************/
111 
long long int SUMOTime
Definition: SUMOTime.h:36
Base (microsim) event class.
Definition: Command.h:54
A wrapper for a Command function.
Definition: StaticCommand.h:42
StaticCommand(Operation operation)
Constructor.
Definition: StaticCommand.h:55
Operation myOperation
The object&#39;s operation to perform.
Definition: StaticCommand.h:99
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: StaticCommand.h:86
bool myAmDescheduledByParent
Whether this command was descheduled (is invalid) and shall not be executed.
~StaticCommand()
Destructor.
Definition: StaticCommand.h:60
SUMOTime(* Operation)(SUMOTime)
Type of the function to execute.
Definition: StaticCommand.h:45
void deschedule()
Marks this Command as being descheduled.
Definition: StaticCommand.h:68