SUMO - Simulation of Urban MObility
StaticCommand.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-sim.org/
11 // Copyright (C) 2001-2014 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 StaticCommand_h
22 #define StaticCommand_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 // ===========================================================================
48 template< class T >
49 class StaticCommand : public Command {
50 public:
53 
54 
55 public:
63  : myOperation(operation), myAmDescheduledByParent(false) {}
64 
65 
68 
69 
75  void deschedule() {
77  }
78 
79 
80 
83 
93  SUMOTime execute(SUMOTime currentTime) {
94  // do not execute if the command was descheduled
96  return 0;
97  }
98  // execute if stil valid
99  return (*myOperation)(currentTime);
100  }
102 
103 
104 private:
107 
110 
111 
112 };
113 
114 
115 #endif
116 
117 /****************************************************************************/
118 
Base (microsim) event class.
Definition: Command.h:61
A wrapper for a Command function.
Definition: StaticCommand.h:49
StaticCommand(Operation operation)
Constructor.
Definition: StaticCommand.h:62
Operation myOperation
The object's operation to perform.
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: StaticCommand.h:93
bool myAmDescheduledByParent
Whether this command was descheduled (is invalid) and shall not be executed.
~StaticCommand()
Destructor.
Definition: StaticCommand.h:67
int SUMOTime
Definition: SUMOTime.h:43
SUMOTime(* Operation)(SUMOTime)
Type of the function to execute.
Definition: StaticCommand.h:52
void deschedule()
Marks this Command as being descheduled.
Definition: StaticCommand.h:75