>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
XabslDecimalExpression.hGo to the documentation of this file.00001 /** 00002 * @file XabslDecimalExpression.h 00003 * 00004 * Definition of DecimalExpression and derivates 00005 * 00006 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00007 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00008 * @author <a href="http://www.informatik.hu-berlin.de/~juengel">Matthias JŸngel</a> 00009 */ 00010 00011 #ifndef __XabslDecimalExpression_h_ 00012 #define __XabslDecimalExpression_h_ 00013 00014 #include "XabslSymbols.h" 00015 00016 namespace xabsl 00017 { 00018 00019 // class prototypes used by symbol parameters / conditional expressions 00020 class BooleanExpression; 00021 class EnumeratedExpression; 00022 class Option; 00023 class State; 00024 00025 /** 00026 * @class DecimalExpression 00027 * 00028 * Base class for all decimal expressions inside an option graph. 00029 * 00030 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00031 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00032 */ 00033 class DecimalExpression 00034 { 00035 public: 00036 /** Calculates the value of the decimal expression. */ 00037 virtual double getValue() const = 0; 00038 00039 /** 00040 * Creates a decimal expression depending on the input. 00041 * @param input An input source for the intermediate code. It must be opened and read until 00042 * A position where a decimal expression starts. 00043 * @param errorHandler A reference to a ErrorHandler instance 00044 * @param symbols All available symbols 00045 * @param option The current option 00046 * @param state The current state 00047 */ 00048 static DecimalExpression* create(InputSource& input, 00049 ErrorHandler& errorHandler, 00050 Symbols& symbols, 00051 Option& option, 00052 State& state); 00053 00054 /** Destructor */ 00055 virtual ~DecimalExpression() = 0; 00056 00057 /** 00058 * Creates a decimal expression depending on the input. 00059 * Uses the create() function to create decimal operands. 00060 * @param operand The expression to be created 00061 * @param input An input source for the intermediate code. It must be opened and read until 00062 * A position where a decimal operand starts. 00063 * @param errorHandler A reference to a ErrorHandler instance 00064 * @param symbols All available symbols 00065 * @param option The current option 00066 * @param state The current state 00067 * @return If the creation was successful 00068 */ 00069 static bool createOperand( 00070 DecimalExpression*& operand, 00071 InputSource& input, 00072 ErrorHandler& errorHandler, 00073 Symbols& symbols, 00074 Option& option, 00075 State& state); 00076 }; 00077 00078 /** 00079 * @class DecimalValue 00080 * 00081 * Represents a decimal value. 00082 * 00083 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00084 */ 00085 class DecimalValue : public DecimalExpression 00086 { 00087 public: 00088 /** 00089 * Constructor. Creates the value 00090 * @param input An input source for the intermediate code. It must be opened and read until 00091 * A position where a value starts. 00092 * @param errorHandler A reference to a ErrorHandler instance 00093 */ 00094 DecimalValue(InputSource& input, 00095 ErrorHandler& errorHandler); 00096 00097 /** 00098 * Constructor. Creates an expression for a fixed decimal value 00099 * @param value The decimal value 00100 */ 00101 DecimalValue(double value) : value(value) {} 00102 00103 /** Calculates the value of the decimal expression. */ 00104 virtual double getValue() const; 00105 00106 private: 00107 /** The value */ 00108 double value; 00109 }; 00110 00111 /** 00112 * @class DecimalOptionParameterRef 00113 * 00114 * Represents a reference to a decimal option parameter. 00115 * 00116 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00117 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00118 */ 00119 class DecimalOptionParameterRef : public DecimalExpression 00120 { 00121 public: 00122 /** 00123 * Constructor. Creates the reference 00124 * @param input An input source for the intermediate code. It must be opened and read until 00125 * A position where the expression starts. 00126 * @param errorHandler A reference to a ErrorHandler instance 00127 * @param option The current option 00128 */ 00129 DecimalOptionParameterRef(InputSource& input, 00130 ErrorHandler& errorHandler, 00131 Option& option); 00132 00133 /** Calculates the value of the decimal expression. */ 00134 virtual double getValue() const; 00135 00136 private: 00137 /** A pointer to the parameter */ 00138 double* parameter; 00139 }; 00140 00141 /** 00142 * @class ArithmeticOperator 00143 * 00144 * Base class for the +, -, *, / and % operator. 00145 * 00146 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00147 */ 00148 class ArithmeticOperator : public DecimalExpression 00149 { 00150 public: 00151 /** 00152 * Creates the operator 00153 * @param operand1 The first operand 00154 * @param operand2 The second operand 00155 */ 00156 void create(DecimalExpression* operand1, DecimalExpression* operand2); 00157 00158 /** Calculates the value of the decimal expression. */ 00159 virtual double getValue() const = 0; 00160 00161 /** Destructor. Deletes the operands */ 00162 ~ArithmeticOperator(); 00163 00164 protected: 00165 /** The first operand */ 00166 DecimalExpression* operand1; 00167 00168 /** The second operand */ 00169 DecimalExpression* operand2; 00170 }; 00171 00172 /** 00173 * @class PlusOperator 00174 * 00175 * Represents a + operator in the option graph 00176 * 00177 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00178 */ 00179 class PlusOperator : public ArithmeticOperator 00180 { 00181 public: 00182 /** Calculates the value of the decimal expression. */ 00183 virtual double getValue() const; 00184 }; 00185 00186 /** 00187 * @class MinusOperator 00188 * 00189 * Represents a - operator in the option graph 00190 * 00191 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00192 */ 00193 class MinusOperator : public ArithmeticOperator 00194 { 00195 public: 00196 /** Calculates the value of the decimal expression. */ 00197 virtual double getValue() const; 00198 }; 00199 00200 00201 /** 00202 * @class MultiplyOperator 00203 * 00204 * Represents a * operator in the option graph 00205 * 00206 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00207 */ 00208 class MultiplyOperator : public ArithmeticOperator 00209 { 00210 public: 00211 /** Calculates the value of the decimal expression. */ 00212 virtual double getValue() const; 00213 }; 00214 00215 /** 00216 * @class DivideOperator 00217 * 00218 * Represents a / operator in the option graph 00219 * 00220 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00221 */ 00222 class DivideOperator : public ArithmeticOperator 00223 { 00224 public: 00225 /** Calculates the value of the decimal expression. */ 00226 virtual double getValue() const; 00227 }; 00228 00229 /** 00230 * @class ModOperator 00231 * 00232 * Represents a % operator in the option graph 00233 * 00234 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00235 */ 00236 class ModOperator : public ArithmeticOperator 00237 { 00238 public: 00239 /** Calculates the value of the decimal expression. */ 00240 virtual double getValue() const; 00241 }; 00242 00243 /** 00244 * @class TimeRef 00245 * 00246 * Represents a time-of-option-execution or time-of-state-execution element in the option graph 00247 * 00248 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00249 */ 00250 class TimeRef : public DecimalExpression 00251 { 00252 public: 00253 /** 00254 * Constructor 00255 * @param errorHandler A reference to a ErrorHandler instance 00256 * @param time the referenced time 00257 */ 00258 TimeRef(ErrorHandler& errorHandler, 00259 unsigned& time); 00260 00261 /** Calculates the value of the decimal expression. */ 00262 virtual double getValue() const; 00263 00264 private: 00265 /** The referenced time */ 00266 unsigned& time; 00267 }; 00268 00269 /** 00270 * @class DecimalInputSymbolRef 00271 * 00272 * Represents a reference to a decimal input symbol. 00273 * 00274 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00275 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00276 */ 00277 class DecimalInputSymbolRef : public DecimalExpression 00278 { 00279 public: 00280 /** Calculates the value of the decimal expression. */ 00281 virtual double getValue() const; 00282 00283 /** 00284 * Constructor. Creates the function call depending on the input. 00285 * @param input An input source for the intermediate code. It must be opened and read until 00286 * A position where the function reference starts. 00287 * @param errorHandler A reference to a ErrorHandler instance 00288 * @param symbols All available symbols 00289 * @param option The current option 00290 * @param state The current state 00291 */ 00292 DecimalInputSymbolRef(InputSource& input, 00293 ErrorHandler& errorHandler, 00294 Symbols& symbols, 00295 Option& option, 00296 State& state); 00297 00298 /** Destructor */ 00299 ~DecimalInputSymbolRef(); 00300 00301 private: 00302 /** The referenced symbol */ 00303 DecimalInputSymbol* symbol; 00304 00305 /** The parameter assignments of the referenced symbol */ 00306 ParameterAssignment* parameters; 00307 }; 00308 00309 /** 00310 * @class DecimalOutputSymbolRef 00311 * 00312 * Represents a reference to a decimal input symbol. 00313 * 00314 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00315 */ 00316 class DecimalOutputSymbolRef : public DecimalExpression 00317 { 00318 public: 00319 /** Calculates the value of the decimal expression. */ 00320 virtual double getValue() const; 00321 00322 /** 00323 * Constructor. Creates the function call depending on the input. 00324 * @param input An input source for the intermediate code. It must be opened and read until 00325 * A position where the function reference starts. 00326 * @param errorHandler A reference to a ErrorHandler instance 00327 * @param symbols All available symbols 00328 */ 00329 DecimalOutputSymbolRef(InputSource& input, 00330 ErrorHandler& errorHandler, 00331 Symbols& symbols); 00332 00333 private: 00334 /** The referenced symbol */ 00335 DecimalOutputSymbol* symbol; 00336 }; 00337 00338 /** 00339 * @class ConditionalDecimalExpression 00340 * 00341 * Represents an ANSI C (condition?expression:expression) question mark operator 00342 * 00343 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00344 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00345 */ 00346 class ConditionalDecimalExpression : public DecimalExpression 00347 { 00348 public: 00349 /** 00350 * Constructor. Creates the expression 00351 * @param input An input source for the intermediate code. It must be opened and read until 00352 * A position where a expression starts. 00353 * @param errorHandler A reference to a ErrorHandler instance 00354 * @param symbols All available symbols 00355 * @param option The current option 00356 * @param state The current state 00357 */ 00358 ConditionalDecimalExpression(InputSource& input, 00359 ErrorHandler& errorHandler, 00360 Symbols& symbols, 00361 Option& option, 00362 State& state); 00363 00364 /** Destructor */ 00365 ~ConditionalDecimalExpression(); 00366 00367 /** Calculates the value of the decimal expression. */ 00368 virtual double getValue() const; 00369 00370 private: 00371 /** The condition */ 00372 BooleanExpression* condition; 00373 00374 /** The expression that is returned when the condition evaluates true */ 00375 DecimalExpression* expression1; 00376 00377 /** The expression that is returned when the condition evaluates false */ 00378 DecimalExpression* expression2; 00379 }; 00380 00381 } // namespace 00382 00383 #endif //__XabslDecimalExpression_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. | |