FSM.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __FINITE_STATE_MACHINE_H
  11. #define __FINITE_STATE_MACHINE_H
  12. #include "DS_List.h"
  13. class State;
  14. // Finite state machine
  15. // Stores a stack of states
  16. // The top of the stack is the current state. There is only one current state. The stack contains the state history.
  17. // OnEnter, OnLeave, FSMAddRef, FSMRemoveRef of class State is called as appropriate.
  18. class FSM
  19. {
  20. public:
  21. FSM();
  22. ~FSM();
  23. void Clear(void);
  24. State *CurrentState(void) const;
  25. State *GetState(const int index) const;
  26. int GetStateIndex(State *state) const;
  27. int GetStateHistorySize(void) const;
  28. void RemoveState(const int index);
  29. void AddState(State *state);
  30. void ReplaceState(const int index, State *state);
  31. void SetPriorState(const int index);
  32. protected:
  33. DataStructures::List<State*> stateHistory;
  34. };
  35. #endif
粤ICP备19079148号