>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
XabslState.hGo to the documentation of this file.00001 /** 00002 * @file XabslState.h 00003 * 00004 * Definition of class State 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 __XabslState_h_ 00010 #define __XabslState_h_ 00011 00012 #include "XabslStatement.h" 00013 #include "XabslBasicBehavior.h" 00014 #include "XabslDecimalExpression.h" 00015 #include "XabslBooleanExpression.h" 00016 #include "XabslEnumeratedExpression.h" 00017 #include "XabslAction.h" 00018 00019 namespace xabsl 00020 { 00021 00022 // class prototype needed for declaration of State 00023 class Option; 00024 00025 /** 00026 * @class State 00027 * 00028 * Represents a single state written in 00029 * 00030 * @author <a href="http://www.martin-loetzsch.de">Martin Loetzsch</a> 00031 */ 00032 class State : public NamedItem 00033 { 00034 public: 00035 /** 00036 * Constructor. Does not create the state. 00037 * @param name The name of the state. For debugging purposes. 00038 * @param errorHandler A reference to a ErrorHandler instance 00039 * @param time The system time in ms. 00040 * @param optionIndex Index of the corresponding option this state belongs to 00041 * @param index Index of the state in array states in corresponding option 00042 */ 00043 State(const char* name, 00044 ErrorHandler& errorHandler, 00045 const unsigned& time, 00046 int optionIndex, 00047 int index); 00048 00049 /** Destructor */ 00050 ~State(); 00051 00052 /** 00053 * Creates the state and it's subelements from the intermediate code. 00054 * @param input An input source for the intermediate code. It must be opened and read until 00055 * A position where a state starts. 00056 * @param options All available options 00057 * @param basicBehaviors All available basicBehaviors 00058 * @param states All states of the option 00059 * @param symbols All available symbols 00060 */ 00061 void create(InputSource& input, 00062 NamedArray<Option*>& options, 00063 NamedArray<BasicBehavior*>& basicBehaviors, 00064 NamedArray<State*>& states, 00065 Symbols& symbols); 00066 00067 /** 00068 * Executes the decision tree and determines the next active state (can be the same). 00069 */ 00070 virtual State* getNextState(); 00071 00072 /** The actions of the state */ 00073 Array<Action*> actions; 00074 00075 /** 00076 * The first subsequent option that is executed after that option if the state is active. 00077 * If 0, no subsequent option is executed after that option. 00078 * This pointer is present just for compatibility reasons, please use getactions instead 00079 */ 00080 Option* subsequentOption; 00081 00082 /** The time how long the state is already active */ 00083 unsigned timeOfStateExecution; 00084 00085 /** Sets the time when the state was activated to 0 */ 00086 void reset(); 00087 00088 /** Returns wheter the state is a target state */ 00089 bool isTargetState() const; 00090 00091 /** Index of the state in array states in corresponding option */ 00092 int index; 00093 00094 /** The time, when the state was activated */ 00095 unsigned timeWhenStateWasActivated; 00096 00097 /** Index of the corresponding option this state belongs to */ 00098 int optionIndex; 00099 00100 /** Check whether this state can be entered, or whether entering is blocked due to cooperating agents */ 00101 virtual bool coopCheck() {return true;} 00102 00103 /** Whether this state is currently conflicted, i.e whether cooperation conditions are violated */ 00104 virtual bool getConflict() {return false;} 00105 00106 protected: 00107 00108 /** If true, the state is a target state */ 00109 bool targetState; 00110 00111 /** Used for error handling */ 00112 ErrorHandler& errorHandler; 00113 00114 /** The root element of the decision tree */ 00115 Statement* decisionTree; 00116 00117 /** The system time in ms. */ 00118 const unsigned& time; 00119 00120 }; 00121 00122 } // namespace 00123 00124 #endif //__XabslState_h_ Up | Main Page | Generated at Wed Aug 19 17:32:29 2009.
|
|
Copyright 2002 - 2009 by the XABSL developer team. See the licence for details. | |