Pyrogenesis
trunk
|
Manages states, events, actions and transitions between states. More...
#include <FSM.h>
Public Member Functions | |
CFsm () | |
virtual | ~CFsm () |
virtual void | Setup () |
Constructs the state machine. More... | |
void | Shutdown () |
Clear event, action and condition lists and reset state machine. More... | |
void | AddState (unsigned int state) |
Adds the specified state to the internal list of states. More... | |
CFsmEvent * | AddEvent (unsigned int eventType) |
Adds the specified event to the internal list of events. More... | |
CFsmTransition * | AddTransition (unsigned int state, unsigned int eventType, unsigned int nextState) |
Adds a new transistion to the state machine. More... | |
CFsmTransition * | AddTransition (unsigned int state, unsigned int eventType, unsigned int nextState, void *pAction, void *pContext) |
Adds a new transition to the state machine. More... | |
CFsmTransition * | GetTransition (unsigned int state, unsigned int eventType) const |
Looks up the transition given the state, event and next state to transition to. More... | |
CFsmTransition * | GetEventTransition (unsigned int eventType) const |
void | SetFirstState (unsigned int firstState) |
Sets the initial state for FSM. More... | |
void | SetCurrState (unsigned int state) |
Sets the current state and update the last state to the current state. More... | |
unsigned int | GetCurrState () const |
void | SetNextState (unsigned int nextState) |
unsigned int | GetNextState () const |
const StateSet & | GetStates () const |
const EventMap & | GetEvents () const |
const TransitionList & | GetTransitions () const |
bool | Update (unsigned int eventType, void *pEventData) |
Updates the FSM and retrieves next state. More... | |
bool | IsValidState (unsigned int state) const |
Verifies whether the specified state is managed by the FSM. More... | |
bool | IsValidEvent (unsigned int eventType) const |
Verifies whether the specified event is managed by the FSM. More... | |
virtual bool | IsDone () const |
Tests whether the state machine has finished its work. More... | |
Private Member Functions | |
NONCOPYABLE (CFsm) | |
bool | IsFirstTime () const |
Verifies whether state machine has already been updated. More... | |
Private Attributes | |
bool | m_Done |
unsigned int | m_FirstState |
unsigned int | m_CurrState |
unsigned int | m_NextState |
StateSet | m_States |
EventMap | m_Events |
TransitionList | m_Transitions |
Manages states, events, actions and transitions between states.
It provides an interface for advertising events and track the current state. The implementation is a Mealy state machine, so the system respond to events and execute some action.
A Mealy state machine has behaviour associated with state transitions; Mealy machines are event driven where an event triggers a state transition.
CFsm::CFsm | ( | ) |
|
virtual |
CFsmEvent * CFsm::AddEvent | ( | unsigned int | eventType | ) |
Adds the specified event to the internal list of events.
void CFsm::AddState | ( | unsigned int | state | ) |
Adds the specified state to the internal list of states.
CFsmTransition * CFsm::AddTransition | ( | unsigned int | state, |
unsigned int | eventType, | ||
unsigned int | nextState | ||
) |
Adds a new transistion to the state machine.
CFsmTransition * CFsm::AddTransition | ( | unsigned int | state, |
unsigned int | eventType, | ||
unsigned int | nextState, | ||
void * | pAction, | ||
void * | pContext | ||
) |
Adds a new transition to the state machine.
|
inline |
|
inline |
CFsmTransition* CFsm::GetEventTransition | ( | unsigned int | eventType | ) | const |
|
inline |
|
inline |
CFsmTransition * CFsm::GetTransition | ( | unsigned int | state, |
unsigned int | eventType | ||
) | const |
Looks up the transition given the state, event and next state to transition to.
|
inline |
|
virtual |
Tests whether the state machine has finished its work.
|
private |
Verifies whether state machine has already been updated.
bool CFsm::IsValidEvent | ( | unsigned int | eventType | ) | const |
Verifies whether the specified event is managed by the FSM.
bool CFsm::IsValidState | ( | unsigned int | state | ) | const |
Verifies whether the specified state is managed by the FSM.
|
private |
void CFsm::SetCurrState | ( | unsigned int | state | ) |
Sets the current state and update the last state to the current state.
void CFsm::SetFirstState | ( | unsigned int | firstState | ) |
Sets the initial state for FSM.
|
inline |
|
virtual |
Constructs the state machine.
This method must be overriden so that connections are constructed for the particular state machine implemented.
void CFsm::Shutdown | ( | ) |
Clear event, action and condition lists and reset state machine.
bool CFsm::Update | ( | unsigned int | eventType, |
void * | pEventData | ||
) |
Updates the FSM and retrieves next state.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |