StateMachine Class Reference

#include <StateMachine.h>

List of all members.

Public Member Functions

 StateMachine (void)
 ~StateMachine (void)
void Start (__in UINT32 state=SMSTATE_STARTED)
void Stop (void)
bool IsEnabled (void)
bool IsReady (void)
UINT32 GetCurrentState (void)
void ClearAllEvents (void)
bool WaitForEvents (__in Event **pEvents, __in UINT32 cEvents, __in UINT32 stateNext, __in UINT32 flags)

Detailed Description

This class defines and implements the StateMachine object.


Constructor & Destructor Documentation

StateMachine::StateMachine ( void   )  [inline]

Constructor: Create an instance of the StateMachine object. It initializes the state machine to disabled mode.

StateMachine::~StateMachine ( void   )  [inline]

Destructor: Destroy an instance of the StateMachine object.


Member Function Documentation

void StateMachine::ClearAllEvents ( void   )  [inline]

This function is called to clear all events.

UINT32 StateMachine::GetCurrentState ( void   )  [inline]

This function is called to get the current state of the state machine.

Returns:
Returns the current state of the state machine.
bool StateMachine::IsEnabled ( void   )  [inline]

This function is called to check if the state machine is enabled.

Returns:
Returns true if the state machine is enabled, false otherwise.
bool StateMachine::IsReady ( void   )  [inline]

This function is called periodically when processing the state machine. It checks if the state machine is enabled and ready. If the state machine is enabled but not ready, it will check if all the events it is waiting for are signaled. If so, the state machine is advanced to the next state and transitioned to ready state. If the state machine is enabled and in ready state, the caller will perform the task according to the current state. The task usually involves initiating the next operation and waits for it to complete. While it is waiting, the state machine will be put back in non-ready state.

Returns:
Returns true if the state machine is ready, false otherwise.
void StateMachine::Start ( __in UINT32  state = SMSTATE_STARTED  )  [inline]

This function is called to start the state machine.

Parameters:
state Optionally specifies the initial state to start in.
void StateMachine::Stop ( void   )  [inline]

This function is called to stop the state machine.

bool StateMachine::WaitForEvents ( __in Event **  pEvents,
__in UINT32  cEvents,
__in UINT32  stateNext,
__in UINT32  flags 
) [inline]

This function specfies an array of events to wait for and sets the state machine to waiting state.

Parameters:
pEvents Points to the array of event object pointers to wait for.
cEvents Specifies the number of event pointers in the array.
stateNext Specifies the next state to advance to once the event(s) occurred.
flags Specifies the option flags of the wait. If the SMF_WAIT_ALL flag is set, all the events in the array must be in signaled state before the state machine will move on to the next state. Otherwise, the state machine will advance to the next state if any one of the events is signaled.
Returns:
Success: returns true. Failure: returns false.

The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2