#include <HSM.h>
Classes | |
| struct | Event |
| struct | State |
Public Types | |
| enum | ReservedEventIds { EnterEventId = -1 , ExitEventId = -2 } |
| typedef unsigned char | StateId |
| typedef AZStd::delegate< bool(HSM &sm, const Event &e)> | StateHandler |
Public Member Functions | |
| HSM (const char *name="HSM no name") | |
| const char * | GetName () const |
| void | Start () |
| Starts the state machine. | |
| bool | Dispatch (const Event &e) |
| Dispatches an event, return true if the event was processed, otherwise false. | |
| bool | IsDispatching () const |
| Return true if the state machine is currently dispatching an event. | |
| void | Transition (StateId target) |
| Transitions the state machine. This function can not be called from Enter / Exit events in the state handler. | |
| StateId | GetCurrentState () const |
| StateId | GetSourceState () const |
| void | SetStateHandler (StateId id, const char *name, const StateHandler &handler, StateId superId=InvalidStateId, StateId subId=InvalidStateId) |
| void | ClearStateHandler (StateId id) |
| Resets the state to invalid mode. | |
| const char * | GetStateName (StateId id) const |
| Event handing. | |
| StateId | GetSuperState (StateId id) const |
| bool | IsValidState (StateId id) const |
| bool | IsInState (StateId id) const |
Static Public Attributes | |
| static const unsigned char | MaxNumberOfStates = 254 |
| static const unsigned char | InvalidStateId = 255 |
| static const int | InvalidEventId = -4 |
Protected Member Functions | |
| int | StepsToCommonRoot (StateId source, StateId target) |
| void | OnEnterSubState () |
Protected Attributes | |
| const char * | m_name |
| StateId | m_curState |
| StateId | m_nextState |
| Pointer to next state. Valid only when a transition is taken. | |
| StateId | m_sourceState |
| Pointer to source state during last transition. | |
| StateId | m_curSourceState |
| Current transition source state. It may not actually complete. | |
| StateId | m_topState |
| bool | m_disallowTransition |
| AZStd::array< State, MaxNumberOfStates > | m_states |
Hierarchical state machine.
| void AZ::HSM::SetStateHandler | ( | StateId | id, |
| const char * | name, | ||
| const StateHandler & | handler, | ||
| StateId | superId = InvalidStateId, |
||
| StateId | subId = InvalidStateId |
||
| ) |
Set a handler for a state ID. This function will overwrite the current state handler.
| id | state id from 0 to MaxNumberOfStates |
| name | state debug name. |
| handler | delegate to the state function. |
| superId | id of the super state, if InvalidStateId this is a top state. Only one state can be a top state. |
| subId | if != InvalidStateId this sub state (child state) will be entered after the state Enter event is executed. |