Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.1 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: statemachinebase.h
  5. //
  6. // Description: Header file for a state machine base class
  7. //
  8. // Author: Mike Swafford (MikeSwa)
  9. //
  10. // History:
  11. // 12/11/2000 - MikeSwa Created from t-toddc's work
  12. //
  13. // Copyright (C) 2000 Microsoft Corporation
  14. //
  15. //-----------------------------------------------------------------------------
  16. #ifndef __STATE_MACHINE_BASE__
  17. #define __STATE_MACHINE_BASE__
  18. #define STATE_MACHINE_BASE_SIG ' MTS'
  19. // A 3-tuple transition consisting of
  20. // current state, action, and next state.
  21. typedef struct _STATE_TRANSITION
  22. {
  23. DWORD dwCurrentState;
  24. DWORD dwAction;
  25. DWORD dwNextState;
  26. } STATE_TRANSITION;
  27. //---[ CStateMachineBase ]-------------------------------------------------
  28. //
  29. //
  30. // Description:
  31. // Base class for all state machines. It is responsible for maintaining
  32. // the current state, ensuring that the state table it is handling is in
  33. // fact valid, and performing thread-safe state transitions.
  34. // The pure virtual function exists because the base machine is not
  35. // responsible for maintaining the state transition table, only
  36. // performing operations of the state. This is not designed to be
  37. // used by itself.
  38. //
  39. // Author: Todd Coleman (t-toddc)
  40. //
  41. // History:
  42. // 6/5/00 - t-toddc Created
  43. //
  44. // Copyright (C) 2000 Microsoft Corporation
  45. //
  46. //-----------------------------------------------------------------------------
  47. class CStateMachineBase
  48. {
  49. private:
  50. DWORD m_dwSignature;
  51. DWORD m_dwStateMachineSignature;
  52. DWORD m_dwCurrentState;
  53. protected:
  54. CStateMachineBase(DWORD dwInitialState, DWORD dwStateMachineSignature);
  55. DWORD dwGetCurrentState();
  56. DWORD dwGetNextState(DWORD dwAction);
  57. BOOL fValidateStateTable();
  58. DWORD dwCalcStateFromStateAndAction(DWORD dwStartState, DWORD dwAction);
  59. virtual void getTransitionTable(const STATE_TRANSITION** ppTransitionTable,
  60. DWORD* pdwNumTransitions) = 0;
  61. };
  62. #endif