>xabsl   The Extensible Agent Behavior Specification Language

XabslEngine Class Library Reference

 

XabslStatement.h

Go to the documentation of this file.
00001 /**
00002 * @file XabslStatement.h
00003 * 
00004 * Definition of class Statement 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 __XabslStatement_h_
00010 #define __XabslStatement_h_
00011 
00012 #include "XabslBooleanExpression.h"
00013 
00014 namespace xabsl 
00015 {
00016 
00017 // class prototype needed for the declaration of Statement
00018 class State;
00019 
00020 /** 
00021 * @class Statement 
00022 * 
00023 * An element of a decision that that determines a transition to a state.
00024 * It can be either a transition to a state or a if/else-if/else block containing other statements.
00025 * 
00026 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a>
00027 * @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
00028 */
00029 class Statement
00030 {
00031 public:
00032   /** Executes the statement and determines the next active state (can be the same). */
00033   virtual State* getNextState() = 0;
00034   
00035   /** 
00036   * Creates a statement depending on the input.
00037   * @param input An input source for the intermediate code. It must be opened and read until 
00038   *              A position where a statement starts.
00039   * @param errorHandler A reference to a ErrorHandler instance
00040   * @param symbols All available symbols
00041   * @param option The current option
00042   * @param state The current state
00043   */
00044   static Statement* createStatement(InputSource& input,    
00045     ErrorHandler& errorHandler,
00046     Symbols& symbols,    
00047     Option& option,
00048     State& state);
00049   
00050   /** Destructor */
00051   virtual ~Statement() = 0;
00052 };
00053 
00054 /**
00055 * @class IfElseBlock
00056 *
00057 * An element of a decision tree that that contains of an if - (else-if) - else block
00058 * 
00059 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a>
00060 */
00061 class IfElseBlock : public Statement
00062 {
00063 public:
00064   /** 
00065   * Constructor. Creates the if / else statement
00066   * @param input An input source for the intermediate code. It must be opened and read until 
00067   *              A position where a transition starts.
00068   * @param errorHandler A reference to a ErrorHandler instance
00069   * @param symbols All available symbols
00070   * @param option The current option
00071   * @param state The current state
00072   */
00073   IfElseBlock(InputSource& input, 
00074     ErrorHandler& errorHandler,
00075     Symbols& symbols,
00076     Option& option,
00077     State& state
00078     );
00079   
00080   /** Destructor. Deletes all statements and conditions */
00081   ~IfElseBlock();
00082   
00083   /** Executes the statement and determines the next active state (can be the same). */
00084   virtual State* getNextState();
00085   
00086 private:
00087   /** The boolean expression that is evaluated for the if case */
00088   BooleanExpression* ifCondition;
00089   
00090   /** The statement that is executed if the if condition is true */
00091   Statement* ifStatement;
00092   
00093   /** The boolean expressions for the else-if cases */
00094   NamedArray<BooleanExpression*> elseIfConditions;
00095   
00096   /** The statements that are executed if the else-if condition are true */
00097   NamedArray<Statement*> elseIfStatements;
00098   
00099   /** The statement that is executed if all if and else-if conditions fail */
00100   Statement* elseStatement;
00101 };
00102 
00103 
00104 /**
00105 * Represents a transition to a state inside a decision tree
00106 */
00107 class TransitionToState : public Statement
00108 {
00109 public:
00110   /** 
00111   * Constructor. Creates the transition object
00112   * @param input An input source for the intermediate code. It must be opened and read until 
00113   *              A position where a transition starts.
00114   * @param errorHandler A reference to a ErrorHandler instance
00115   * @param option The current option
00116   */
00117   TransitionToState(InputSource& input, 
00118     ErrorHandler& errorHandler,
00119     Option& option);
00120   
00121   /** Executes the statement and determines the next active state (can be the same). */
00122   virtual State* getNextState();
00123   
00124 private:
00125   /** The state where that transition points to */
00126   State* nextState;
00127 };
00128 
00129 } // namespace
00130 
00131 #endif // __XabslStatement_h_

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