>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
XabslBooleanExpression.hGo to the documentation of this file.00001 /** 00002 * @file XabslBooleanExpression.h 00003 * 00004 * Definition of BooleanExpression 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 */ 00009 00010 #ifndef __XabslBooleanExpression_h_ 00011 #define __XabslBooleanExpression_h_ 00012 00013 #include "XabslDecimalExpression.h" 00014 00015 namespace xabsl 00016 { 00017 00018 /** 00019 * @class BooleanExpression 00020 * 00021 * Base class for all boolean expressions inside an option graph. 00022 * 00023 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00024 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00025 */ 00026 class BooleanExpression 00027 { 00028 public: 00029 /** Evaluates the boolean expression. */ 00030 virtual bool getValue() const = 0; 00031 00032 /** 00033 * Creates a boolean expression depending on the input. 00034 * @param input An input source for the intermediate code. It must be opened and read until 00035 * A position where a boolean expression starts. 00036 * @param errorHandler A reference to a ErrorHandler instance 00037 * @param symbols All available symbols 00038 * @param option The current option 00039 * @param state The current state 00040 */ 00041 static BooleanExpression* create(InputSource& input, 00042 ErrorHandler& errorHandler, 00043 Symbols& symbols, 00044 Option& option, 00045 State& state); 00046 00047 /** Destructor */ 00048 virtual ~BooleanExpression() = 0; 00049 00050 /** 00051 * Creates a boolean expression depending on the input. 00052 * Uses the create() function to create boolean operands. 00053 * @param operand The expression to be created 00054 * @param input An input source for the intermediate code. It must be opened and read until 00055 * A position where a boolean operand starts. 00056 * @param errorHandler A reference to a ErrorHandler instance 00057 * @param symbols All available symbols 00058 * @param option The current option 00059 * @param state The current state 00060 * @return If the creation was successful 00061 */ 00062 static bool createOperand( 00063 BooleanExpression*& operand, 00064 InputSource& input, 00065 ErrorHandler& errorHandler, 00066 Symbols& symbols, 00067 Option& option, 00068 State& state); 00069 }; 00070 00071 /** 00072 * @class BooleanValue 00073 * 00074 * Represents a boolean value. 00075 * 00076 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00077 */ 00078 class BooleanValue : public BooleanExpression 00079 { 00080 public: 00081 /** 00082 * Constructor. Creates the value 00083 * @param input An input source for the intermediate code. It must be opened and read until 00084 * A position where a value starts. 00085 * @param errorHandler A reference to a ErrorHandler instance 00086 */ 00087 BooleanValue(InputSource& input, 00088 ErrorHandler& errorHandler); 00089 00090 /** 00091 * Constructor. Creates an expression for a fixed boolean value 00092 * @param value The boolean value 00093 */ 00094 BooleanValue(bool value) : value(value) {} 00095 00096 /** Calculates the value of the decimal expression. */ 00097 virtual bool getValue() const; 00098 00099 private: 00100 /** The value */ 00101 bool value; 00102 }; 00103 00104 /** 00105 * @class BooleanOptionParameterRef 00106 * 00107 * Represents a reference to a decimal option parameter. 00108 * 00109 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00110 */ 00111 class BooleanOptionParameterRef : public BooleanExpression 00112 { 00113 public: 00114 /** 00115 * Constructor. Creates the reference 00116 * @param input An input source for the intermediate code. It must be opened and read until 00117 * A position where the expression starts. 00118 * @param errorHandler A reference to a ErrorHandler instance 00119 * @param option The current option 00120 */ 00121 BooleanOptionParameterRef(InputSource& input, 00122 ErrorHandler& errorHandler, 00123 Option& option); 00124 00125 /** Calculates the value of the boolean expression. */ 00126 virtual bool getValue() const; 00127 00128 private: 00129 /** A pointer to the parameter */ 00130 bool* parameter; 00131 }; 00132 00133 /** 00134 * @class AndOperator 00135 * 00136 * Represents an 'and' element of the option graph 00137 * 00138 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00139 */ 00140 class AndOperator : public BooleanExpression 00141 { 00142 public: 00143 /** Constructor */ 00144 AndOperator(); 00145 00146 /** Destructor. Deletes the two operands */ 00147 ~AndOperator(); 00148 00149 /** Evaluates the boolean expression.*/ 00150 virtual bool getValue() const; 00151 00152 /** Adds an operand to the operands array */ 00153 void addOperand(BooleanExpression* operand); 00154 00155 private: 00156 /** the 2+n operands of the operator */ 00157 Array<BooleanExpression*> operands; 00158 }; 00159 00160 /** 00161 * @class OrOperator 00162 * 00163 * Represents an 'or' element of the option graph 00164 * 00165 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00166 */ 00167 class OrOperator : public BooleanExpression 00168 { 00169 public: 00170 /** Constructor */ 00171 OrOperator(); 00172 00173 /** Destructor. Deletes the two operands */ 00174 ~OrOperator(); 00175 00176 /** Evaluates the boolean expression. */ 00177 virtual bool getValue() const; 00178 00179 /** Adds an operand to the operands array */ 00180 void addOperand(BooleanExpression* operand); 00181 00182 private: 00183 /** the 2+n operands of the operator */ 00184 Array<BooleanExpression*> operands; 00185 }; 00186 00187 00188 /** 00189 * @class NotOperator 00190 * 00191 * Represents an 'not' element of the option graph 00192 * 00193 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00194 */ 00195 class NotOperator : public BooleanExpression 00196 { 00197 public: 00198 /** 00199 * Constructor. Creates the element. 00200 * @param operand1 A boolean expression 00201 */ 00202 NotOperator(BooleanExpression* operand1); 00203 00204 /** Destructor. Deletes the operand */ 00205 ~NotOperator(); 00206 00207 /** Evaluates the boolean expression. */ 00208 virtual bool getValue() const; 00209 00210 private: 00211 /** operand 1 */ 00212 BooleanExpression* operand1; 00213 }; 00214 00215 /** 00216 * @class BooleanInputSymbolRef 00217 * 00218 * Represents an 'boolean-input-symbol-ref' element of the option graph 00219 * 00220 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00221 */ 00222 class BooleanInputSymbolRef : public BooleanExpression 00223 { 00224 public: 00225 /** 00226 * Constructor. Creates the element 00227 * @param input An input source for the intermediate code. It must be opened and read until 00228 * A position where a expression starts. 00229 * @param errorHandler A reference to a ErrorHandler instance 00230 * @param symbols All available symbols 00231 * @param option The current option 00232 * @param state The current state 00233 */ 00234 BooleanInputSymbolRef(InputSource& input, 00235 ErrorHandler& errorHandler, 00236 Symbols& symbols, 00237 Option& option, 00238 State& state); 00239 00240 /** Destructor */ 00241 ~BooleanInputSymbolRef(); 00242 00243 /** Evaluates the boolean expression. */ 00244 virtual bool getValue() const; 00245 00246 private: 00247 /** The referenced symbol */ 00248 BooleanInputSymbol* symbol; 00249 00250 /** The parameter assignments of the referenced symbol */ 00251 ParameterAssignment* parameters; 00252 }; 00253 00254 /** 00255 * @class BooleanOutputSymbolRef 00256 * 00257 * Represents a reference to a boolean input symbol. 00258 * 00259 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a> 00260 */ 00261 class BooleanOutputSymbolRef : public BooleanExpression 00262 { 00263 public: 00264 /** Calculates the value of the boolean expression. */ 00265 virtual bool getValue() const; 00266 00267 /** 00268 * Constructor. Creates the function call depending on the input. 00269 * @param input An input source for the intermediate code. It must be opened and read until 00270 * A position where the function reference starts. 00271 * @param errorHandler A reference to a ErrorHandler instance 00272 * @param symbols All available symbols 00273 */ 00274 BooleanOutputSymbolRef(InputSource& input, 00275 ErrorHandler& errorHandler, 00276 Symbols& symbols); 00277 00278 private: 00279 /** The referenced symbol */ 00280 BooleanOutputSymbol* symbol; 00281 }; 00282 00283 /** 00284 * @class SubsequentOptionReachedTargetStateCondition 00285 * 00286 * Represents an 'subsequent-option-reached-target-state' element of the option graph 00287 * 00288 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00289 */ 00290 class SubsequentOptionReachedTargetStateCondition : public BooleanExpression 00291 { 00292 public: 00293 /** 00294 * Constructor. Creates the element. 00295 * @param errorHandler A reference to a ErrorHandler instance 00296 * @param state The current state 00297 */ 00298 SubsequentOptionReachedTargetStateCondition( 00299 ErrorHandler& errorHandler, 00300 State& state); 00301 00302 /** Evaluates the boolean expression. */ 00303 virtual bool getValue() const; 00304 00305 private: 00306 /** The state */ 00307 State& state; 00308 }; 00309 00310 /** 00311 * @class ConflictCondition 00312 * 00313 * Represents an 'conflict' element of the option graph 00314 * 00315 * @author Max Risler 00316 */ 00317 class ConflictCondition : public BooleanExpression 00318 { 00319 public: 00320 /** 00321 * Constructor. Creates the element. 00322 * @param errorHandler A reference to a ErrorHandler instance 00323 * @param state The current state 00324 */ 00325 ConflictCondition( 00326 ErrorHandler& errorHandler, 00327 State& state); 00328 00329 /** Evaluates the boolean expression. */ 00330 virtual bool getValue() const; 00331 00332 private: 00333 /** The state */ 00334 State& state; 00335 }; 00336 00337 /** 00338 * @class EnumeratedInputSymbolComparison 00339 * 00340 * Represents an 'enumerated-input-symbol-comparison' element of the option graph 00341 * 00342 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00343 */ 00344 class EnumeratedInputSymbolComparison : public BooleanExpression 00345 { 00346 public: 00347 /** 00348 * Constructor. Creates the element 00349 * @param input An input source for the intermediate code. It must be opened and read until 00350 * A position where a expression starts. 00351 * @param errorHandler A reference to a ErrorHandler instance 00352 * @param symbols All available symbols 00353 * @param option The current option 00354 * @param state The current state 00355 */ 00356 EnumeratedInputSymbolComparison(InputSource& input, 00357 ErrorHandler& errorHandler, 00358 Symbols& symbols, 00359 Option& option, 00360 State& state); 00361 00362 /** Destructor. Deletes the two operands */ 00363 ~EnumeratedInputSymbolComparison(); 00364 00365 /** Evaluates the boolean expression.*/ 00366 virtual bool getValue() const; 00367 00368 protected: 00369 /** operand 1 */ 00370 const EnumeratedExpression* operand1; 00371 00372 /** operand 2 */ 00373 const EnumeratedExpression* operand2; 00374 }; 00375 00376 /** 00377 * @class RelationalAndEqualityOperator 00378 * 00379 * Base class for the operators <, <=, >, >=, == and != 00380 * 00381 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00382 */ 00383 class RelationalAndEqualityOperator : public BooleanExpression 00384 { 00385 public: 00386 /** 00387 * Creates the element. 00388 * @param operand1 A decimal expression 00389 * @param operand2 A decimal expression 00390 */ 00391 void create(DecimalExpression* operand1, 00392 DecimalExpression* operand2); 00393 00394 /** Destructor. Deletes the two operands */ 00395 ~RelationalAndEqualityOperator(); 00396 00397 /** Evaluates the boolean expression.*/ 00398 virtual bool getValue() const = 0; 00399 00400 protected: 00401 /** operand 1 */ 00402 DecimalExpression* operand1; 00403 00404 /** operand 2 */ 00405 DecimalExpression* operand2; 00406 }; 00407 00408 /** 00409 * @class EqualToOperator 00410 * 00411 * Represents an 'equal-to' element of the option graph 00412 * 00413 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00414 */ 00415 class EqualToOperator : public RelationalAndEqualityOperator 00416 { 00417 public: 00418 /** Evaluates the boolean expression.*/ 00419 virtual bool getValue() const; 00420 }; 00421 00422 /** 00423 * @class NotEqualToOperator 00424 * 00425 * Represents an 'not-equal-to' element of the option graph 00426 * 00427 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00428 */ 00429 class NotEqualToOperator : public RelationalAndEqualityOperator 00430 { 00431 public: 00432 /** Evaluates the boolean expression.*/ 00433 virtual bool getValue() const; 00434 }; 00435 00436 /** 00437 * @class LessThanOperator 00438 * 00439 * Represents an 'less-than' element of the option graph 00440 * 00441 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00442 */ 00443 class LessThanOperator : public RelationalAndEqualityOperator 00444 { 00445 public: 00446 /** Evaluates the boolean expression.*/ 00447 virtual bool getValue() const; 00448 }; 00449 00450 /** 00451 * @class LessThanOrEqualToOperator 00452 * 00453 * Represents an 'less-than-or-equal-to' element of the option graph 00454 * 00455 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00456 */ 00457 class LessThanOrEqualToOperator : public RelationalAndEqualityOperator 00458 { 00459 public: 00460 /** Evaluates the boolean expression.*/ 00461 virtual bool getValue() const; 00462 }; 00463 00464 /** 00465 * @class GreaterThanOperator 00466 * 00467 * Represents an 'greater-than' element of the option graph 00468 * 00469 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00470 */ 00471 class GreaterThanOperator : public RelationalAndEqualityOperator 00472 { 00473 public: 00474 /** Evaluates the boolean expression.*/ 00475 virtual bool getValue() const; 00476 }; 00477 00478 /** 00479 * @class GreaterThanOrEqualToOperator 00480 * 00481 * Represents an 'greater-than-or-equal-to' element of the option graph 00482 * 00483 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00484 */ 00485 class GreaterThanOrEqualToOperator : public RelationalAndEqualityOperator 00486 { 00487 public: 00488 /** Evaluates the boolean expression.*/ 00489 virtual bool getValue() const; 00490 }; 00491 00492 00493 } // namespace 00494 00495 #endif //__XabslBooleanExpression_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. | |