>xabsl | The Extensible Agent Behavior Specification Language |
start | team | language reference | tools | xabsl engine | download | licence | |
XabslEngine Class Library Reference | |
  | |
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
XabslAction.hGo to the documentation of this file.00001 /** 00002 * @file XabslAction.h 00003 * 00004 * Definition of class Action and Helper classes 00005 * 00006 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00007 */ 00008 00009 #ifndef __XabslAction_h_ 00010 #define __XabslAction_h_ 00011 00012 #include "XabslBasicBehavior.h" 00013 #include "XabslDecimalExpression.h" 00014 #include "XabslBooleanExpression.h" 00015 #include "XabslEnumeratedExpression.h" 00016 00017 namespace xabsl 00018 { 00019 00020 // class prototype needed for declaration of Action 00021 class Option; 00022 00023 /** 00024 * @class Action 00025 * 00026 * Represents an action execution. This is either a subsequent option or basic behavior to be executed, or an 00027 * output symbol assignment. 00028 * 00029 * @author Max Risler 00030 */ 00031 class Action 00032 { 00033 public: 00034 /** 00035 * Constructor. 00036 * @param time The system time in ms. 00037 */ 00038 Action(const unsigned &time) : 00039 time(time) 00040 {} 00041 00042 /** 00043 * Virtual destructor. 00044 */ 00045 virtual ~Action() {} 00046 00047 /** 00048 * Creates an action definition. 00049 * @param input An input source for the intermediate code. It must be opened and read until 00050 * A position where a state starts. 00051 * @param options All available options 00052 * @param basicBehaviors All available basicBehaviors 00053 * @param symbols All available symbols 00054 * @param option The current option 00055 * @param state The current state 00056 * @param errorHandler A reference to a ErrorHandler instance 00057 * @param time The system time in ms. 00058 */ 00059 static Action* create( 00060 InputSource& input, 00061 NamedArray<Option*>& options, 00062 NamedArray<BasicBehavior*>& basicBehaviors, 00063 Symbols& symbols, 00064 Option& option, 00065 State& state, 00066 ErrorHandler& errorHandler, 00067 const unsigned& time); 00068 00069 /** 00070 * Creates an action definition which just calls a single option or basic behavior 00071 * without setting any parameters. 00072 * @param behavior The referenced option or basic behavior. 00073 * @param errorHandler A reference to a ErrorHandler instance 00074 * @param time The system time in ms. 00075 */ 00076 static Action* create( 00077 Behavior* behavior, 00078 ErrorHandler& errorHandler, 00079 const unsigned &time); 00080 00081 /** Execute the behavior or assign the output symbol */ 00082 virtual void execute() = 0; 00083 00084 /** Returns a pointer to the option or basic behavior to be executed, or 0 if an output symbol is set */ 00085 Behavior* getBehavior(); 00086 const Behavior* getBehavior() const; 00087 00088 /** Returns a pointer to the option, if an option is to be executed, 0 otherwise */ 00089 Option* getOption(); 00090 const Option* getOption() const; 00091 00092 /** Returns a pointer to the basic behavior, if a basic behavior is to be executed, 0 otherwise */ 00093 BasicBehavior* getBasicBehavior(); 00094 const BasicBehavior* getBasicBehavior() const; 00095 00096 /** Returns a pointer to the parameter assignments for an option or basic behavior, or 0 if an output symbol is set */ 00097 ParameterAssignment* getParameters(); 00098 const ParameterAssignment* getParameters() const; 00099 00100 /** Returns a pointer to the output symbol, if a decimal output symbol is to be assigned, 0 otherwise */ 00101 const DecimalOutputSymbol* getDecimalOutputSymbol() const; 00102 00103 /** Returns a pointer to the output symbol, if a boolean output symbol is to be assigned, 0 otherwise */ 00104 const BooleanOutputSymbol* getBooleanOutputSymbol() const; 00105 00106 /** Returns a pointer to the output symbol, if an enumerated output symbol is to be assigned, 0 otherwise */ 00107 const EnumeratedOutputSymbol* getEnumeratedOutputSymbol() const; 00108 00109 /** Returns the last symbol value, if a decimal output symbol is to be assigned, 0 otherwise */ 00110 double getDecimalOutputSymbolValue() const; 00111 00112 /** Returns the last symbol value, if a boolean output symbol is to be assigned, 0 otherwise */ 00113 bool getBooleanOutputSymbolValue() const; 00114 00115 /** Returns the last symbol value, if an enumerated output symbol is to be assigned, 0 otherwise */ 00116 int getEnumeratedOutputSymbolValue() const; 00117 00118 protected: 00119 /** The system time in ms. */ 00120 const unsigned& time; 00121 }; 00122 00123 /** 00124 * @class ActionBehavior 00125 * 00126 * Represents an action execution. This is either a subsequent option or basic behavior to be executed. 00127 * 00128 * @author Max Risler 00129 */ 00130 class ActionBehavior : public Action 00131 { 00132 public: 00133 /** 00134 * Constructor. 00135 * @param time The system time in ms. 00136 */ 00137 ActionBehavior(const unsigned& time) : 00138 Action(time), 00139 parameters(0) 00140 {} 00141 00142 /** Destructor */ 00143 ~ActionBehavior(); 00144 00145 /** 00146 * Parameters of the option or basic behavior that is executed 00147 */ 00148 ParameterAssignment* parameters; 00149 00150 /** 00151 * The option or basic behavior that is executed 00152 */ 00153 virtual const Behavior* getBehavior() const = 0; 00154 virtual Behavior* getBehavior() = 0; 00155 00156 /** Execute the behavior */ 00157 virtual void execute(); 00158 }; 00159 00160 /** 00161 * @class ActionBasicBehavior 00162 * 00163 * Represents an action execution. In this case a basic behavior is to be executed. 00164 * 00165 * @author Max Risler 00166 */ 00167 class ActionBasicBehavior : public ActionBehavior 00168 { 00169 public: 00170 /** 00171 * Constructor. 00172 * @param time The system time in ms. 00173 */ 00174 ActionBasicBehavior(const unsigned& time) : 00175 ActionBehavior(time), 00176 basicBehavior(0) 00177 {} 00178 00179 BasicBehavior* basicBehavior; 00180 00181 virtual const Behavior* getBehavior() const; 00182 virtual Behavior* getBehavior(); 00183 }; 00184 00185 /** 00186 * @class ActionOption 00187 * 00188 * Represents an action execution. In this case an option is to be executed. 00189 * 00190 * @author Max Risler 00191 */ 00192 class ActionOption : public ActionBehavior 00193 { 00194 public: 00195 /** 00196 * Constructor. 00197 * @param time The system time in ms. 00198 */ 00199 ActionOption(const unsigned& time) : 00200 ActionBehavior(time), 00201 option(0) 00202 {} 00203 00204 Option* option; 00205 00206 virtual const Behavior* getBehavior() const; 00207 virtual Behavior* getBehavior(); 00208 }; 00209 00210 /** 00211 * @class ActionDecimalOutputSymbol 00212 * 00213 * Represents an action execution, in this case a decimal output symbol assignment 00214 * 00215 * @author Max Risler 00216 */ 00217 class ActionDecimalOutputSymbol : public Action 00218 { 00219 public: 00220 /** 00221 * Constructor. 00222 * @param time The system time in ms. 00223 */ 00224 ActionDecimalOutputSymbol(const unsigned& time) : 00225 Action(time), 00226 decimalOutputSymbol(0), 00227 decimalOutputSymbolExpression(0), 00228 decimalOutputSymbolValue(0) 00229 {} 00230 00231 /** Destructor */ 00232 ~ActionDecimalOutputSymbol(); 00233 00234 /** A decimal output symbol that is set if the state is active, null when a behavior is executed or another output symbol is set */ 00235 DecimalOutputSymbol* decimalOutputSymbol; 00236 /** The expression for the decimal output symbol that is set if the state is active */ 00237 const DecimalExpression* decimalOutputSymbolExpression; 00238 /** Current decimal output symbol value, this is stored just for debugging purposes */ 00239 double decimalOutputSymbolValue; 00240 00241 /** Execute the behavior */ 00242 virtual void execute(); 00243 }; 00244 00245 /** 00246 * @class ActionBooleanOutputSymbol 00247 * 00248 * Represents an action execution, in this case a boolean output symbol assignment 00249 * 00250 * @author Max Risler 00251 */ 00252 class ActionBooleanOutputSymbol : public Action 00253 { 00254 public: 00255 /** 00256 * Constructor. 00257 * @param time The system time in ms. 00258 */ 00259 ActionBooleanOutputSymbol(const unsigned& time) : 00260 Action(time), 00261 booleanOutputSymbol(0), 00262 booleanOutputSymbolExpression(0), 00263 booleanOutputSymbolValue(false) 00264 {} 00265 00266 /** Destructor */ 00267 ~ActionBooleanOutputSymbol(); 00268 00269 /** A boolean output symbol that is set if the state is active, null when a behavior is executed or another output symbol is set */ 00270 BooleanOutputSymbol* booleanOutputSymbol; 00271 /** The expression for the boolean output symbol that is set if the state is active */ 00272 const BooleanExpression* booleanOutputSymbolExpression; 00273 /** Current boolean output symbol value, this is stored just for debugging purposes */ 00274 bool booleanOutputSymbolValue; 00275 00276 /** Execute the behavior */ 00277 virtual void execute(); 00278 }; 00279 00280 /** 00281 * @class ActionEnumeratedOutputSymbol 00282 * 00283 * Represents an action execution, in this case an enumerated output symbol assignment 00284 * 00285 * @author Max Risler 00286 */ 00287 class ActionEnumeratedOutputSymbol : public Action 00288 { 00289 public: 00290 /** 00291 * Constructor. 00292 * @param time The system time in ms. 00293 */ 00294 ActionEnumeratedOutputSymbol(const unsigned& time) : 00295 Action(time), 00296 enumeratedOutputSymbol(0), 00297 enumeratedOutputSymbolExpression(0), 00298 enumeratedOutputSymbolValue(0) 00299 {} 00300 00301 /** Destructor */ 00302 ~ActionEnumeratedOutputSymbol(); 00303 00304 /** An enumerated output symbol that is set if the state is active, null when a behavior is executed or another output symbol is set */ 00305 EnumeratedOutputSymbol* enumeratedOutputSymbol; 00306 /** The expression for the enumerated output symbol that is set if the state is active */ 00307 const EnumeratedExpression* enumeratedOutputSymbolExpression; 00308 /** Current enumerated output symbol value, this is stored just for debugging purposes */ 00309 int enumeratedOutputSymbolValue; 00310 00311 /** Execute the behavior */ 00312 virtual void execute(); 00313 }; 00314 00315 } // namespace 00316 00317 #endif //__XabslAction_h_ Up | Main Page | Generated at Wed Aug 19 17:32:28 2009.
|
|
Copyright 2002 - 2009 by the XABSL developer team. See the licence for details. | |