00001 #if !defined(AFX_FSMSTATE_H__72C06899_E8FF_4311_A306_97314E778192__INCLUDED_)
00002 #define AFX_FSMSTATE_H__72C06899_E8FF_4311_A306_97314E778192__INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #include "FSMObject.h"
00066
00068 namespace FSM {
00069
00070
00071 class CFiniteStateMachine;
00072 class CFSMTransition;
00073 class CFSMAction;
00074 class CFSMCondition;
00075
00076 typedef list< CFSMTransition* > Transition_List;
00077 typedef list< CFSMAction* > Action_List;
00078
00079 class CFSMState : public CFSMObject
00080 {
00081 public:
00082 friend class CFiniteStateMachine;
00083
00084
00085 CFSMTransition* AddTransition(const char* onEvent="ANY", const char *className="SimpleTransition");
00086 CFSMTransition* AddSimpleTransition(const char *toStateName, const char* onEvent="ANY");
00087
00089 int GetTransitionNumber() const;
00090
00092 CFSMTransition* GetTransition(int index) const;
00093
00095 bool DeleteTransition(CFSMTransition* trans);
00096
00102 Transition_List::const_iterator GetTransitionsBegin() const;
00103
00105 Transition_List::const_iterator GetTransitionsEnd() const;
00106
00107
00109 CFSMAction* AddEnterAction(const char *className);
00110
00112 CFSMAction* AddLeaveAction(const char *className);
00113
00115 bool DeleteAction(CFSMAction *action);
00116
00118 CFSMAction* GetEnterAction(int index) const;
00119
00121 CFSMAction* GetLeaveAction(int index) const;
00122
00128 Action_List::const_iterator GetEnterActionsBegin() const;
00129
00131 Action_List::const_iterator GetEnterActionsEnd() const;
00132
00138 Action_List::const_iterator GetLeaveActionsBegin() const;
00139
00141 Action_List::const_iterator GetLeaveActionsEnd() const;
00142
00143
00144 const char* GetName() const;
00145
00146 protected:
00147
00148 static CFSMObject *Create();
00149 virtual void DeleteThis();
00150
00151
00152 void SetName(const char *name);
00153
00154
00163 virtual bool GetTransition(CFSMTransition** trans, const char *event, void *a, void *b);
00164
00169 virtual bool Activate();
00170
00175 virtual bool Deactivate();
00176
00178 Transition_List m_Transitions;
00179
00181 Action_List m_EnterActions;
00182
00184 Action_List m_LeaveActions;
00185
00187 CFSMState();
00188
00190 virtual ~CFSMState();
00191
00192 private:
00193
00194 string m_Name;
00195 };
00196
00197 };
00198
00199 #endif // !defined(AFX_FSMSTATE_H__72C06899_E8FF_4311_A306_97314E778192__INCLUDED_)