#include <HSM.h>
|
enum | ReservedEventIds { EnterEventId = -1
, ExitEventId = -2
} |
|
typedef unsigned char | StateId |
|
typedef AZStd::delegate< bool(HSM &sm, const Event &e)> | StateHandler |
|
|
| 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 const unsigned char | MaxNumberOfStates = 254 |
|
static const unsigned char | InvalidStateId = 255 |
|
static const int | InvalidEventId = -4 |
|
|
int | StepsToCommonRoot (StateId source, StateId target) |
|
void | OnEnterSubState () |
|
|
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.
- Note
- This implementation have the standard restriction for HSM:
- You can not call Transition from HSM::EnterEventId and HSM::ExitEventId! These event are provided to execute your construction/destruction. Use custom events for that.
- You are not allowed to dispatch an event from within an event dispatch. You should queue events if you want such behavior. This restriction is imposed only to prevent the user from creating extremely complicated to trace state machines (which is what we are trying to avoid).
◆ SetStateHandler()
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.
- Parameters
-
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. |
The documentation for this class was generated from the following file:
- Code/Framework/AzCore/AzCore/State/HSM.h