Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/Xabsl2/Xabsl2Engine/Xabsl2DecimalExpression.h

Go to the documentation of this file.

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