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