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 /****************************************************************************/
15 // A wrapper for a Command function
16 /****************************************************************************/
17 #ifndef StaticCommand_h
18 #define StaticCommand_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
25 #include "Command.h"
26 
27 
28 // ===========================================================================
29 // class definition
30 // ===========================================================================
39 template< class T >
40 class StaticCommand : public Command {
41 public:
44 
45 
46 public:
54  : myOperation(operation), myAmDescheduledByParent(false) {}
55 
56 
59 
60 
66  void deschedule() {
68  }
69 
70 
71 
74 
84  SUMOTime execute(SUMOTime currentTime) {
85  // do not execute if the command was descheduled
87  return 0;
88  }
89  // execute if stil valid
90  return (*myOperation)(currentTime);
91  }
93 
94 
95 private:
98 
101 
102 
103 };
104 
105 
106 #endif
107 
108 /****************************************************************************/
109 
StaticCommand::execute
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: StaticCommand.h:84
StaticCommand::Operation
SUMOTime(* Operation)(SUMOTime)
Type of the function to execute.
Definition: StaticCommand.h:43
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
StaticCommand
A wrapper for a Command function.
Definition: StaticCommand.h:40
StaticCommand::deschedule
void deschedule()
Marks this Command as being descheduled.
Definition: StaticCommand.h:66
StaticCommand::myAmDescheduledByParent
bool myAmDescheduledByParent
Whether this command was descheduled (is invalid) and shall not be executed.
Definition: StaticCommand.h:100
Command
Base (microsim) event class.
Definition: Command.h:52
StaticCommand::myOperation
Operation myOperation
The object's operation to perform.
Definition: StaticCommand.h:97
StaticCommand::~StaticCommand
~StaticCommand()
Destructor.
Definition: StaticCommand.h:58
Command.h
StaticCommand::StaticCommand
StaticCommand(Operation operation)
Constructor.
Definition: StaticCommand.h:53