LRAUV  revA
Method.h
Go to the documentation of this file.
1 
9 #ifndef METHOD_H_
10 #define METHOD_H_
11 
12 #include "data/ElementURI.h"
13 #include "logger/Logger.h"
14 #include "utils/FlexArray.h"
15 
16 class DataReader;
17 class DataValue;
18 class DataWriter;
19 class DefinedBehavior;
20 class OutputURI;
21 class ScriptAPI;
22 class ScriptNode;
23 class SettingReader;
24 class Unit;
25 
31 class InputInfo
32 {
33 public:
34  InputInfo( const Str& name, const Str& uriPart, DataValue* defaultValue )
35  : name_( name ),
36  uriPart_( uriPart ),
37  defaultValue_( defaultValue )
38  {}
39 
40  virtual ~InputInfo();
41 
42  const Str& getName()
43  {
44  return name_;
45  }
46  const Str& getUriPart()
47  {
48  return uriPart_;
49  }
51  {
52  return defaultValue_;
53  }
54 
55 protected:
56  const Str name_;
57  const Str uriPart_;
59 
60 private:
61  // Note that the copy constructor below is private and not given a body.
62  // Any attempt to call it will return a compiler error.
63  InputInfo( const InputInfo& old ); // disallow copy constructor
64 };
65 
66 
73 {
74 public:
75  OutputInfo( const ElementURI* uri, const Unit* unit, bool arg )
76  : uri_( uri ),
77  unit_( unit ),
78  arg_( arg )
79  {}
80 
81  virtual ~OutputInfo()
82  {}
83 
84  const ElementURI* getUri()
85  {
86  return uri_;
87  }
88  const Unit* getUnit()
89  {
90  return unit_;
91  }
92  bool isArg()
93  {
94  return arg_;
95  }
96 
97 protected:
98  const ElementURI* uri_;
99  const Unit* unit_;
100  const bool arg_;
101 
102 private:
103  // Note that the copy constructor below is private and not given a body.
104  // Any attempt to call it will return a compiler error.
105  OutputInfo( const OutputInfo& old ); // disallow copy constructor
106 };
107 
108 
109 
111 {
112 public:
115  : inputs_( true ),
116  outputs_( true )
117  {}
118 
119  void addInput( InputInfo* input )
120  {
121  inputs_.push( input );
122  }
123 
124  void addOutput( OutputInfo* output )
125  {
126  outputs_.push( output );
127  }
128 
129  void setScript( const char* methodName, const char* code )
130  {
131  methodName_ = methodName;
132  code_ = code;
133  }
134 
135 protected:
136 
137  friend class Method;
138 
141 
144 
145  // Name of method
147 
150 
151 private:
152  // Note that the copy constructor below is private and not given a body.
153  // Any attempt to call it will return a compiler error.
154  MethodInfo( const MethodInfo& old ); // disallow copy constructor
155 
156 };
157 
164 class Method
165 {
166 public:
168  Method( DefinedBehavior* definedBehavior, MethodInfo* methodInfo, ScriptAPI* scriptAPI );
169 
170  virtual ~Method();
171 
172  void addInput( DataReader* input, const Unit* unit );
173 
174  void addOutput( DataWriter* output, const Unit* unit );
175 
176  virtual void execute( Logger& logger );
177 
178  virtual bool executeBool( Logger& logger );
179 
180  virtual void executeVoid( Logger& logger );
181 
183  {
184  return outputs_;
185  }
186 
188  {
189  return outUnits_;
190  }
191 
193  {
194  return outputArgs_;
195  }
196 
197 protected:
200 
203 
206 
209 
212 
215 
216 private:
217  // Note that the copy constructor below is private and not given a body.
218  // Any attempt to call it will return a compiler error.
219  Method( const Method& old ); // disallow copy constructor
220 
221 };
222 
223 #endif /* METHOD_H_ */
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
FlexArray< InputInfo * > inputs_
Method arguments;.
Definition: Method.h:140
const Unit * getUnit()
Definition: Method.h:88
virtual FlexArray< OutputURI * > & getOutputArgs()
Definition: Method.h:192
const Str & getUriPart()
Definition: Method.h:46
const Str name_
Definition: Method.h:56
virtual ~Method()
Definition: Method.cpp:57
Method(DefinedBehavior *definedBehavior, MethodInfo *methodInfo, ScriptAPI *scriptAPI)
Constructor.
Definition: Method.cpp:19
const ElementURI * getUri()
Definition: Method.h:84
void push(T item)
Definition: FlexArray.h:160
FlexArray< const Unit * > outUnits_
Units of return values for method;.
Definition: Method.h:208
Abstract base class for scripted programming language interfaces.
Definition: ScriptAPI.h:29
void addInput(DataReader *input, const Unit *unit)
Definition: Method.cpp:60
const Str uriPart_
Definition: Method.h:57
FlexArray< OutputURI * > outputArgs_
Non-null entries indicate outputArgs;.
Definition: Method.h:211
A DataAccessor that reads values from the Slate Contains a default dataValue that must not be NULL...
Definition: DataReader.h:30
virtual FlexArray< const Unit * > & getOutUnits()
Definition: Method.h:187
void addInput(InputInfo *input)
Definition: Method.h:119
FlexArray< DataWriter * > outputs_
Return values for method;.
Definition: Method.h:205
Behavior that is embedded in scripted code within a mission file.
Definition: DefineBehavior.h:127
Abstract base class for nodes in tree-like scripts.
Definition: ScriptNode.h:20
ScriptNode * scriptNode_
Code for method;.
Definition: Method.h:214
virtual ~OutputInfo()
Definition: Method.h:81
virtual bool executeBool(Logger &logger)
Definition: Method.cpp:83
A DataValue is an abstract base class for a data value and associated engineering units of the value...
Definition: DataValue.h:35
virtual void execute(Logger &logger)
Definition: Method.cpp:71
Information to create a Output in a Method.
Definition: Method.h:72
A DataAccessor that writes values to the Slate via its associated DataElement.
Definition: DataWriter.h:27
Contains the FlexArrayBase and FlexArray class declarations.
const Unit * unit_
Definition: Method.h:99
FlexArray< OutputInfo * > outputs_
Return values for method;.
Definition: Method.h:143
const Str & getName()
Definition: Method.h:42
FlexArray< SettingReader * > & settings_
Method arguments;.
Definition: Method.h:202
Replacement for standard template class string.
Definition: Str.h:12
Wraps the inputs, outputs, and code for a method (i.e., initialize, run, etc) within a scripted compo...
Definition: Method.h:164
Definition: Method.h:110
void addOutput(OutputInfo *output)
Definition: Method.h:124
InputInfo(const Str &name, const Str &uriPart, DataValue *defaultValue)
Definition: Method.h:34
OutputInfo(const ElementURI *uri, const Unit *unit, bool arg)
Definition: Method.h:75
Contains the ElementURI class definition.
virtual FlexArray< DataWriter * > & getOutputs()
Definition: Method.h:182
MethodInfo()
Constructor.
Definition: Method.h:114
DataValue * defaultValue_
Definition: Method.h:58
Contains the Logger class definition.
Reads values from mission settings.
Definition: SettingReader.h:26
virtual void executeVoid(Logger &logger)
Definition: Method.cpp:98
const ElementURI * uri_
Definition: Method.h:98
Str code_
Code for method;.
Definition: Method.h:149
Information to create a Input in a Method.
Definition: Method.h:31
Definition: ElementURI.h:255
const bool arg_
Definition: Method.h:100
Code unit that represents a unique name for a DataElement.
Definition: ElementURI.h:27
FlexArray< DataReader * > inputs_
Arguments for method;.
Definition: Method.h:199
DataValue * getDataValue()
Definition: Method.h:50
bool isArg()
Definition: Method.h:92
void setScript(const char *methodName, const char *code)
Definition: Method.h:129
Code that represents an engineering unit.
Definition: Unit.h:24
void addOutput(DataWriter *output, const Unit *unit)
Definition: Method.cpp:65
Str methodName_
Definition: Method.h:146
virtual ~InputInfo()
Definition: Method.cpp:110