LRAUV  revA
ScriptComponent.h
Go to the documentation of this file.
1 
10 #ifndef SCRIPTCOMPONENT_H_
11 #define SCRIPTCOMPONENT_H_
12 
14 #include "component/Behavior.h"
16 
24 {
25 public:
27  virtual ~ScriptComponent();
28 
31  static Component* Instance( int index, Logger& logger );
32 
34  void setIndex( int index )
35  {
36  index_ = index;
37  }
38 
39  void setModuleName( Str moduleName )
40  {
41  moduleName_ = moduleName;
42  }
43 
45  virtual void scriptInitialize( Logger& logger );
46 
48  virtual void scriptRun( Logger& logger );
49 
51  virtual bool scriptIsSatisfied( Logger& logger );
52 
54  virtual void scriptUninitialize( Logger& logger );
55 
56 protected:
57 
60 
62 
63  int index_;
64 
65 };
66 
73 {
74 private:
75  friend class ScriptComponent;
76 
78  ScriptAsyncComponent( const Module* module, const Str& name,
79  const Timespan& period );
80 
83 
85  inline virtual void initialize()
86  {
88  }
89 
91  inline virtual void run()
92  {
93  scriptRun( logger_ );
94  }
95 
97  inline virtual void uninitialize()
98  {
100  }
101 
102 };
103 
110 {
111 private:
112  friend class ScriptComponent;
113 
115  ScriptMissionComponent( const Module* module, const Str& name,
116  const bool runnable, const bool satisfiable );
117 
120 
122  inline virtual void initialize()
123  {
125  }
126 
128  inline virtual void run()
129  {
130  scriptRun( logger_ );
131  }
132 
134  inline virtual bool isSatisfied()
135  {
136  return scriptIsSatisfied( logger_ );
137  }
138 
140  inline virtual void uninitialize()
141  {
143  }
144 };
145 
152 {
153 private:
154  friend class ScriptComponent;
155 
157  ScriptSyncComponent( const Module* module, const Str& name,
158  CycleOrder cycleOrder );
159 
162 
164  inline virtual void initialize()
165  {
167  }
168 
170  inline virtual void run()
171  {
172  scriptRun( logger_ );
173  }
174 
176  inline virtual void uninitialize()
177  {
179  }
180 };
181 
182 #endif /*SCRIPTCOMPONENT_H_*/
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
Contains the SyncComponent class definition.
ScriptMissionComponent(const Module *module, const Str &name, const bool runnable, const bool satisfiable)
Constructor.
Definition: ScriptComponent.cpp:160
void setModuleName(Str moduleName)
Definition: ScriptComponent.h:39
~ScriptMissionComponent()
Destructor.
Definition: ScriptComponent.h:119
ScriptSyncComponent(const Module *module, const Str &name, CycleOrder cycleOrder)
Constructor.
Definition: ScriptComponent.cpp:166
virtual RunState runnable()
Should eventually follow a START request or RESETTING.
Definition: Component.h:223
virtual void scriptRun(Logger &logger)
The actual "payload" of the component.
Definition: ScriptComponent.cpp:115
Scripted software components that run in the computation cycle.
Definition: ScriptComponent.h:151
virtual void uninitialize()
Uninitialize the payload.
Definition: ScriptComponent.h:140
Logger logger_
Definition: Component.h:476
virtual bool scriptIsSatisfied(Logger &logger)
The satisfied method.
Definition: ScriptComponent.cpp:125
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
ScriptComponent()
Protected constructor called through instance()
Definition: ScriptComponent.cpp:147
Scripted software components that run independently from the computation cycle.
Definition: ScriptComponent.h:72
virtual void uninitialize()
Uninitialize the payload.
Definition: ScriptComponent.h:176
Behavior is the abstract base class for components that implement mission behaviors and commands...
Definition: Behavior.h:32
~ScriptSyncComponent()
Destructor.
Definition: ScriptComponent.h:161
virtual void run()
Execute the payload.
Definition: ScriptComponent.h:128
virtual void initialize()
Initialize the payload.
Definition: ScriptComponent.h:122
virtual void initialize()
Initialize the payload.
Definition: ScriptComponent.h:164
Str moduleName_
Definition: ScriptComponent.h:61
Contains the Behavior class definition.
virtual ~ScriptComponent()
Destructor.
Definition: ScriptComponent.cpp:17
Abstract Base class for software components that run in the computation cycle.
Definition: SyncComponent.h:22
These are enumerated to simplify sorting and ordering.
Definition: SyncComponent.h:42
Not really a component, but a class that can be merged with a Component to wrap code that is scripted...
Definition: ScriptComponent.h:23
Module is the abstract base class for a collection of Component objects that can be contained in a lo...
Definition: Module.h:45
Replacement for standard template class string.
Definition: Str.h:12
void setIndex(int index)
int index
Definition: ScriptComponent.h:34
Abstract Base class for software components.
Definition: Component.h:53
Scripted software components that run as part of a mission script.
Definition: ScriptComponent.h:109
~ScriptAsyncComponent()
Destructor.
Definition: ScriptComponent.h:82
Abstract Base class for software components that run independently from the computation cycle...
Definition: AsyncComponent.h:20
virtual bool isSatisfied()
Check if satisfied.
Definition: ScriptComponent.h:134
int index_
Definition: ScriptComponent.h:63
virtual void run()
Execute the payload.
Definition: ScriptComponent.h:170
virtual void run()
Execute the payload.
Definition: ScriptComponent.h:91
virtual void uninitialize()
Uninitialize the payload.
Definition: ScriptComponent.h:97
static Component * Instance(int index, Logger &logger)
Returns a "Script" version of AsyncComponent, Behavior, or SyncComponent, or NULL if the component ca...
Definition: ScriptComponent.cpp:22
virtual void scriptInitialize(Logger &logger)
Initialize function.
Definition: ScriptComponent.cpp:104
virtual void initialize()
Initialize the payload.
Definition: ScriptComponent.h:85
virtual void scriptUninitialize(Logger &logger)
Uninit function.
Definition: ScriptComponent.cpp:137
ScriptAsyncComponent(const Module *module, const Str &name, const Timespan &period)
Protected constructor for components that run in periodic asynchronous threads.
Definition: ScriptComponent.cpp:154
Contains the AsyncComponent class definition.