![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
Manages states, events, actions and transitions between states. More...
#include <FSM.h>
Classes | |
| struct | CallbackFunction |
| struct | Transition |
| struct | TransitionKey |
Public Member Functions | |
| void | AddTransition (unsigned int state, unsigned int eventType, unsigned int nextState, Action *pAction=nullptr, Context *pContext=nullptr) |
| Adds a new transistion to the state machine. More... | |
| 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 |
| bool | Update (unsigned int eventType, void *pEventData) |
| Updates the FSM and retrieves next state. More... | |
| bool | IsDone () const |
| Tests whether the state machine has finished its work. More... | |
Private Types | |
| using | Action = bool(Context *pContext, CFsmEvent *pEvent) |
| using | TransitionMap = std::unordered_map< TransitionKey, const Transition, typename TransitionKey::Hash > |
Private Member Functions | |
| bool | IsFirstTime () const |
| Verifies whether state machine has already been updated. More... | |
Private Attributes | |
| bool | m_Done {false} |
| unsigned int | m_FirstState {FSM_INVALID_STATE} |
| unsigned int | m_CurrState {FSM_INVALID_STATE} |
| unsigned int | m_NextState {FSM_INVALID_STATE} |
| TransitionMap | 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.
|
private |
|
private |
|
inline |
Adds a new transistion to the state machine.
|
inline |
|
inline |
|
inline |
Tests whether the state machine has finished its work.
|
inlineprivate |
Verifies whether state machine has already been updated.
|
inline |
Sets the current state and update the last state to the current state.
|
inline |
Sets the initial state for FSM.
|
inline |
|
inline |
Updates the FSM and retrieves next state.
|
private |
|
private |
|
private |
|
private |
|
private |