>xabsl   The Extensible Agent Behavior Specification Language

XabslEngine Class Library Reference

 

XabslEnumeratedExpression.h

Go to the documentation of this file.
00001 /** 
00002 * @file XabslEnumeratedExpression.h
00003 *
00004 * Definition of EnumeratedExpression and derivates
00005 *
00006 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
00007 */
00008 
00009 #ifndef __XabslEnumeratedExpression_h_
00010 #define __XabslEnumeratedExpression_h_
00011 
00012 #include "XabslSymbols.h"
00013 #include "XabslDecimalExpression.h"
00014 
00015 namespace xabsl 
00016 {
00017 
00018 /** 
00019 * @class EnumeratedExpression
00020 * 
00021 * Base class for all enumerated expressions inside an option graph.
00022 *
00023 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
00024 */
00025 class EnumeratedExpression
00026 {
00027 public:
00028   /** Evaluates the enumerated expression. */
00029   virtual int getValue() const = 0;
00030   
00031   /**
00032   * Creates an enumerated expression depending on the input.
00033   * @param enumeration A reference to the enumeration which is the domain of this expression
00034   * @param input An input source for the intermediate code. It must be opened and read until 
00035   *              A position where a enumerated 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 EnumeratedExpression* create(const Enumeration* enumeration,
00042     InputSource& input, 
00043     ErrorHandler& errorHandler,
00044     Symbols& symbols,
00045     Option& option,
00046     State& state);
00047   
00048   /** 
00049   * Creates an enumerated expression depending on the input. 
00050   * Uses the create() function to create enumerated operands.
00051   * @param operand The expression to be created
00052   * @param enumeration A reference to the enumeration which is the domain of this expression
00053   * @param input An input source for the intermediate code. It must be opened and read until 
00054   *              A position where a decimal operand starts.
00055   * @param errorHandler A reference to a ErrorHandler instance
00056   * @param symbols All available symbols
00057   * @param option The current option
00058   * @param state The current state
00059   * @return If the creation was successful
00060   */
00061   static bool createOperand(
00062     const EnumeratedExpression*& operand,
00063     const Enumeration* enumeration,
00064     InputSource& input, 
00065     ErrorHandler& errorHandler,
00066     Symbols& symbols,
00067     Option& option,
00068     State& state);
00069 
00070   /** Destructor */
00071   virtual ~EnumeratedExpression() = 0;
00072 
00073   const Enumeration* enumeration;
00074 };
00075 
00076 /** 
00077 * @class EnumeratedValue
00078 * 
00079 * Represents a enumerated value.
00080 *
00081 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
00082 */
00083 class EnumeratedValue : public EnumeratedExpression
00084 {
00085 public:
00086   /**
00087   * Constructor. Creates the value
00088   * @param enumeration A reference to the enumeration which is the domain of this expression
00089   * @param input An input source for the intermediate code. It must be opened and read until 
00090   *              A position where a value starts.
00091   * @param errorHandler A reference to a ErrorHandler instance
00092   */
00093   EnumeratedValue(const Enumeration* enumeration,
00094     InputSource& input, 
00095     ErrorHandler& errorHandler);
00096   
00097   /**
00098   * Constructor. Creates an expression for a fixed enumerated value
00099   * @param value The enumerated value
00100   */
00101   EnumeratedValue(const Enumeration* enumeration, int value) : 
00102     value(value) 
00103   {
00104     this->enumeration = enumeration;
00105   }
00106 
00107   /** Calculates the value of the decimal expression. */
00108   virtual int getValue() const;
00109   
00110 private:
00111   /** The value */
00112   int value;
00113 };
00114 
00115 /** 
00116 * @class EnumeratedOptionParameterRef
00117 * 
00118 * Represents a reference to a enumerated option parameter.
00119 *
00120 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
00121 */
00122 class EnumeratedOptionParameterRef : public EnumeratedExpression
00123 {
00124 public:
00125   /**
00126   * Constructor. Creates the reference 
00127   * @param enumeration A reference to the enumeration which is the domain of this expression
00128   * @param input An input source for the intermediate code. It must be opened and read until 
00129   *              A position where the expression starts.
00130   * @param errorHandler A reference to a ErrorHandler instance
00131   * @param option The current option
00132   */
00133   EnumeratedOptionParameterRef(const Enumeration* enumeration,
00134     InputSource& input, 
00135     ErrorHandler& errorHandler,
00136     Option& option);
00137   
00138   /** Calculates the value of the enumerated expression. */
00139   virtual int getValue() const;
00140   
00141 private:
00142   /** A pointer to the parameter */
00143   int* parameter;
00144 };
00145 
00146 /** 
00147 * @class EnumeratedInputSymbolRef
00148 *
00149 * Represents an 'enumerated-input-symbol-ref' element of the option graph 
00150 *
00151 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
00152 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a>
00153 */
00154 class EnumeratedInputSymbolRef : public EnumeratedExpression
00155 {
00156 public:
00157   /**
00158   * Constructor. Creates the element
00159   * @param enumeration A reference to the enumeration which is the domain of this expression
00160   * @param input An input source for the intermediate code. It must be opened and read until 
00161   *              A position where a expression starts.
00162   * @param errorHandler A reference to a ErrorHandler instance
00163   * @param symbols All available symbols
00164   * @param option The current option
00165   * @param state The current state
00166   */
00167   EnumeratedInputSymbolRef(const Enumeration* enumeration,
00168     InputSource& input, 
00169     ErrorHandler& errorHandler,
00170     Symbols& symbols,
00171     Option& option,
00172     State& state);
00173   
00174   /** Destructor */
00175   ~EnumeratedInputSymbolRef();
00176 
00177   /** Evaluates the enumerated expression. */
00178   virtual int getValue() const;
00179   
00180 private:
00181   /** The referenced symbol */
00182   EnumeratedInputSymbol* symbol;
00183 
00184   /** The parameter assignments of the referenced symbol */
00185   ParameterAssignment* parameters;
00186 };
00187 
00188 /** 
00189 * @class EnumeratedOutputSymbolRef
00190 * 
00191 * Represents a reference to a enumerated input symbol.
00192 *
00193 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a>
00194 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
00195 */
00196 class EnumeratedOutputSymbolRef : public EnumeratedExpression
00197 {
00198 public:
00199   /** Calculates the value of the enumerated expression. */
00200   virtual int getValue() const;
00201   
00202   /**
00203   * Constructor. Creates the function call depending on the input.
00204   * @param enumeration A reference to the enumeration which is the domain of this expression
00205   * @param input An input source for the intermediate code. It must be opened and read until 
00206   *              A position where the function reference starts.
00207   * @param errorHandler A reference to a ErrorHandler instance
00208   * @param symbols All available symbols
00209   */
00210   EnumeratedOutputSymbolRef(const Enumeration* enumeration,
00211     InputSource& input, 
00212     ErrorHandler& errorHandler,
00213     Symbols& symbols);
00214 
00215 private:
00216   /** The referenced symbol */
00217   const EnumeratedOutputSymbol* symbol;
00218 };
00219 
00220 /** 
00221 * @class ConditionalEnumeratedExpression
00222 * 
00223 * Represents an ANSI C (condition?expression:expression) question mark operator
00224 *
00225 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a>
00226 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
00227 */
00228 class ConditionalEnumeratedExpression : public EnumeratedExpression
00229 {
00230 public:
00231   /**
00232   * Constructor. Creates the expression
00233   * @param input An input source for the intermediate code. It must be opened and read until 
00234   *              A position where a expression starts.
00235   * @param errorHandler A reference to a ErrorHandler instance
00236   * @param symbols All available symbols
00237   * @param option The current option
00238   * @param state The current state
00239   */
00240   ConditionalEnumeratedExpression(const Enumeration* enumeration,
00241     InputSource& input, 
00242     ErrorHandler& errorHandler,
00243     Symbols& symbols,
00244     Option& option,
00245     State& state);  
00246 
00247   /** Destructor */
00248   ~ConditionalEnumeratedExpression();
00249 
00250   /** Calculates the value of the decimal expression. */
00251   virtual int getValue() const;
00252 
00253 private:
00254   /** The condition */
00255   const BooleanExpression* condition;
00256 
00257   /** The expression that is returned when the condition evaluates true */
00258   const EnumeratedExpression* expression1;
00259 
00260   /** The expression that is returned when the condition evaluates false */
00261   const EnumeratedExpression* expression2;
00262 };
00263 
00264 } // namespace
00265 
00266 #endif //__XabslEnumeratedExpression_h_

Up | Main Page | Generated at Wed Aug 19 17:32:29 2009.