00001 #ifndef __FINITE_STATE_MACHINE_H 00002 #define __FINITE_STATE_MACHINE_H 00003 00004 #include "DS_List.h" 00005 00006 class State; 00007 00008 // Finite state machine 00009 // Stores a stack of states 00010 // The top of the stack is the current state. There is only one current state. The stack contains the state history. 00011 // OnEnter, OnLeave, FSMAddRef, FSMRemoveRef of class State is called as appropriate. 00012 class FSM 00013 { 00014 public: 00015 FSM(); 00016 ~FSM(); 00017 void Clear(void); 00018 State *CurrentState(void) const; 00019 State *GetState(const int index) const; 00020 int GetStateIndex(State *state) const; 00021 int GetStateHistorySize(void) const; 00022 void RemoveState(const int index); 00023 void AddState(State *state); 00024 void ReplaceState(const int index, State *state); 00025 void SetPriorState(const int index); 00026 00027 protected: 00028 DataStructures::List<State*> stateHistory; 00029 }; 00030 00031 00032 #endif
1.7.1