Hierarchical State Machine class (QMsm-style state machine implementation strategy) More...
#include "qp.hpp"
Public Member Functions | |
void | init (void const *const e, std::uint_fast8_t const qsId) override |
void | init (std::uint_fast8_t const qsId) override |
void | dispatch (QEvt const *const e, std::uint_fast8_t const qsId) override |
QStateHandler | getStateHandler () noexcept override |
bool | isIn (QStateHandler const state) noexcept override |
bool | isInState (QMState const *const stateObj) const noexcept |
QMState const * | childStateObj (QMState const *const parent) const noexcept |
QMState const * | topQMState () const noexcept |
Public Member Functions inherited from QP::QAsm | |
virtual | ~QAsm () noexcept |
QStateHandler | state () const noexcept |
QMState const * | stateObj () const noexcept |
Protected Member Functions | |
QMsm (QStateHandler const initial) noexcept | |
Protected Member Functions inherited from QP::QAsm | |
QAsm () noexcept | |
QState | tran (QStateHandler const target) noexcept |
QState | tran_hist (QStateHandler const hist) noexcept |
QState | super (QStateHandler const superstate) noexcept |
QState | qm_tran (void const *const tatbl) noexcept |
QState | qm_tran_init (void const *const tatbl) noexcept |
QState | qm_tran_hist (QMState const *const hist, void const *const tatbl) noexcept |
QState | qm_tran_ep (void const *const tatbl) noexcept |
QState | qm_tran_xp (QActionHandler const xp, void const *const tatbl) noexcept |
QState | qm_entry (QMState const *const s) noexcept |
QState | qm_exit (QMState const *const s) noexcept |
QState | qm_sm_exit (QMState const *const s) noexcept |
QState | qm_super_sub (QMState const *const s) noexcept |
Private Member Functions | |
QState | execTatbl_ (QMTranActTable const *const tatbl, std::uint_fast8_t const qsId) |
void | exitToTranSource_ (QMState const *const cs, QMState const *const ts, std::uint_fast8_t const qsId) |
QState | enterHistory_ (QMState const *const hist, std::uint_fast8_t const qsId) |
Additional Inherited Members | |
Public Types inherited from QP::QAsm | |
enum | QStateRet : QState { Q_RET_SUPER , Q_RET_SUPER_SUB , Q_RET_UNHANDLED , Q_RET_HANDLED , Q_RET_IGNORED , Q_RET_ENTRY , Q_RET_EXIT , Q_RET_NULL , Q_RET_TRAN , Q_RET_TRAN_INIT , Q_RET_TRAN_EP , Q_RET_TRAN_HIST , Q_RET_TRAN_XP } |
enum | ReservedSig : QSignal { Q_EMPTY_SIG , Q_ENTRY_SIG , Q_EXIT_SIG , Q_INIT_SIG } |
Reserved signals by the QP-framework. More... | |
Static Public Member Functions inherited from QP::QAsm | |
static QState | top (void *const me, QEvt const *const e) noexcept |
Protected Attributes inherited from QP::QAsm | |
QAsmAttr | m_state |
QAsmAttr | m_temp |
Hierarchical State Machine class (QMsm-style state machine implementation strategy)
QMsm
(QM State Machine) provides a more efficient state machine implementation strategy than QP::QHsm, but requires the use of the QM modeling tool, but are the fastest and need the least run-time support (the smallest event-processor taking up the least code space).
The following example illustrates how to derive a state machine class from QP::QMsm.
|
explicitprotectednoexcept |
Constructor of QP::QMsm
Performs the first step of QMsm initialization by assigning the initial pseudostate to the currently active state of the state machine.
[in] | initial | the top-most initial transition for the MSM. |
The following example illustrates how to invoke QMsm() constructor in the "constructor" of a derived state machine:
Definition at line 97 of file qep_msm.cpp.
|
overridevirtual |
Virtual function to take the top-most initial transition in the state machine.
Synchronously executes the top-most initial transition in a state machine (must be overridden in the subclasses).
[in] | e | pointer to an initialization parameter (might be nullptr) |
[in] | qsId | QS-id of this state machine (for QS local filter) |
qep_asm:200
Implements QP::QAsm.
Definition at line 105 of file qep_msm.cpp.
|
inlineoverridevirtual |
Virtual function to take the top-most initial transition in the state machine (overloaded).
Synchronously executes the top-most initial transition in a state machine. This overloaded version takes no initialization parameter.
[in] | qsId | QS-id of this state machine (for QS local filter) |
Reimplemented from QP::QAsm.
|
overridevirtual |
Virtual function to dispatch an event to the state machine.
Synchronously dispatches an event for processing to a state machine (must be overridden in the subclasses). The processing of an event represents one run-to-completion (RTC) step.
[in] | e | pointer to the event to be dispatched to the MSM |
[in] | qsId | QS-id of this state machine (for QS local filter) |
qep_asm:302
Implements QP::QAsm.
Definition at line 166 of file qep_msm.cpp.
|
inlineoverridevirtualnoexcept |
Implementation of getting the state handler in a QP::QMsm subclass
Obtain the current active state from a MSM (read only)
Reimplemented from QP::QAsm.
|
overridevirtualnoexcept |
Check if a given state is part of the current active state configuration in QMsm subclasses. Please note that in a hierarchical state machine, to "be in a state" means also to be in a superstate of of the state.
qep_hsm:602
Reimplemented from QP::QAsm.
Definition at line 376 of file qep_msm.cpp.
|
noexcept |
Checks if a state machine derived from QMsm is-in a given state.
[in] | stateObj | pointer to the QMState object that corresponds to the tested state. |
state
and 'false' otherwise Definition at line 400 of file qep_msm.cpp.
Obtain the current active child state of a given parent in QP::QMsm
Finds the child state of the given parent
, such that this child state is an ancestor of the currently active state. The main purpose of this function is to support **shallow history*transitions in state machines derived from QMsm.
[in] | parent | pointer to the state-handler object |
parent
state, which is an ancestor of the currently active state. For the corner case when the currently active state is the given parent
state, function returns the parent
state.qep_msm:890
Definition at line 424 of file qep_msm.cpp.
|
private |
Execute transition-action table
Helper function to execute transition sequence in a transition-action table.
[in] | tatbl | pointer to the transition-action table |
[in] | qsId | QS-id of this state machine (for QS local filter) |
qep_msm:400
Definition at line 473 of file qep_msm.cpp.
|
private |
Exit the current state up to the explicit transition source
Static helper function to exit the current state configuration to the transition source, which in a hierarchical state machine might be a superstate of the current state.
[in] | cs | pointer to the current state |
[in] | ts | pointer to the transition source state |
[in] | qsId | QS-id of this state machine (for QS local filter) |
Definition at line 550 of file qep_msm.cpp.
Enter history of a composite state
Static helper function to execute the segment of transition to history after entering the composite state and
[in] | hist | pointer to the history substate |
[in] | qsId | QS-id of this state machine (for QS local filter) |
Definition at line 595 of file qep_msm.cpp.
|
noexcept |
Definition at line 664 of file qep_msm.cpp.