Hierarchical State Machine class (QMsm-style state machine implementation strategy)
More...
#include "qp.hpp"
|
void | init (void const *const e, std::uint_fast8_t const qsId) override |
| Virtual function to take the top-most initial transition in the state machine.
|
|
void | init (std::uint_fast8_t const qsId) override |
| Virtual function to take the top-most initial transition in the state machine (overloaded).
|
|
void | dispatch (QEvt const *const e, std::uint_fast8_t const qsId) override |
| Virtual function to dispatch an event to the state machine.
|
|
QStateHandler | getStateHandler () noexcept override |
| Obtain the current active state from a MSM (read only)
|
|
bool | isIn (QStateHandler const stateHndl) noexcept override |
|
QMState const * | childStateObj (QMState const *const parentHndl) const noexcept |
|
QMState const * | topQMState () const noexcept |
|
virtual | ~QAsm () noexcept |
| Virtual destructor of the QP::QAsm abstract base class.
|
|
QStateHandler | state () const noexcept |
|
QMState const * | stateObj () const noexcept |
|
Hierarchical State Machine class (QMsm-style state machine implementation strategy)
- Details
- QP::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).
- Note
- QP::QMsm is not intended to be instantiated directly, but rather serves as the abstract base class for derivation of state machines in the application code.
- Backward Traceability
- SRS_QP_SM_21: QP Framework should provide a State Machine Implementation Strategy optimized for "automatic code generation"
- SDS_QP_QMsm: QMsm State machine class.
- Usage
- The following example illustrates how to derive a state machine class from QP::QMsm.
public:
ToasterOven();
public:
protected:
. . .
};
Hierarchical State Machine class (QMsm-style state machine implementation strategy)
QMsm(QStateHandler const initial) noexcept
#define Q_STATE_CAST(handler_)
#define QM_STATE_DECL(state_)
#define QM_ACTION_DECL(action_)
Definition at line 360 of file qp.hpp.
◆ QMsm()
|
explicitprotectednoexcept |
Constructor of QP::QMsm
- Details
- Performs the first step of QMsm initialization by assigning the initial pseudostate to the currently active state of the state machine.
- Parameters
-
[in] | initial | the top-most initial transition for the MSM. |
- Usage
- The following example illustrates how to invoke QMsm() constructor in the "constructor" of a derived state machine:
void Calc::Calc()
. . .
{
. . .
}
◆ init() [1/2]
void QP::QMsm::init |
( |
void const *const | e, |
|
|
std::uint_fast8_t const | qsId ) |
|
overridevirtual |
Virtual function to take the top-most initial transition in the state machine.
- Details
- Synchronously executes the top-most initial transition in a state machine (must be overridden in the subclasses).
- Parameters
-
[in] | e | pointer to an initialization parameter (might be nullptr) |
[in] | qsId | QS-id of this state machine (for QS local filter) |
Implements QP::QAsm.
◆ init() [2/2]
void QP::QMsm::init |
( |
std::uint_fast8_t const | qsId | ) |
|
|
inlineoverridevirtual |
Virtual function to take the top-most initial transition in the state machine (overloaded).
- Details
- Synchronously executes the top-most initial transition in a state machine. This overloaded version takes no initialization parameter.
- Parameters
-
[in] | qsId | QS-id of this state machine (for QS local filter) |
Reimplemented from QP::QAsm.
Definition at line 368 of file qp.hpp.
◆ dispatch()
void QP::QMsm::dispatch |
( |
QEvt const *const | e, |
|
|
std::uint_fast8_t const | qsId ) |
|
overridevirtual |
Virtual function to dispatch an event to the state machine.
- Details
- 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.
- Parameters
-
[in] | e | pointer to the event to be dispatched to the MSM |
[in] | qsId | QS-id of this state machine (for QS local filter) |
Implements QP::QAsm.
◆ getStateHandler()
|
inlineoverridevirtualnoexcept |
Obtain the current active state from a MSM (read only)
Implementation of getting the state handler in a QP::QMsm subclass
- Returns
- the current active state-handler
- Note
- This function is used for state history (deep history) in the auto-generated code by the QM modeling tool. Reimplemented from QP::QAsm.
Reimplemented from QP::QAsm.
Definition at line 376 of file qp.hpp.
◆ isIn()
@code_uid{QP::QMsm::isIn()Tests if a given state is part of the current active state configuration}
- Details
- 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.
- See also
- QP::QAsm::isIn()
- Attention
- This function must be called only on a state machine that is in the "stable state configuration". Among others, this means that the state machine cannot call it in the middle of its own transition.
- Backward Traceability
-
Reimplemented from QP::QAsm.
◆ childStateObj()
QMState const * QP::QMsm::childStateObj |
( |
QMState const *const | parentHndl | ) |
const |
|
noexcept |
Obtain the current active child state of a given parent in QP::QMsm
- Details
- 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.
- Parameters
-
[in] | parent | pointer to the state-handler object |
- Returns
- the child of a given
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.
- Postcondition
qep_msm:890
-
- Note
- This function is used in the QM modeling tool for auto-generating code for state history (shallow history)
- Backward Traceability
-
◆ execTatbl_()
Execute transition-action table
- Details
- Helper function to execute transition sequence in a transition-action table.
- Parameters
-
[in] | tatbl | pointer to the transition-action table |
[in] | qsId | QS-id of this state machine (for QS local filter) |
- Returns
- status of the last action from the transition-action table.
- Precondition
qep_msm:400
- provided state table cannot be NULL
- Note
- This function is for internal use inside the QEP event processor and should **not* be called directly from the applications.
◆ exitToTranSource_()
void QP::QMsm::exitToTranSource_ |
( |
QMState const *const | cs, |
|
|
QMState const *const | ts, |
|
|
std::uint_fast8_t const | qsId ) |
|
private |
Exit the current state up to the explicit transition source
- Details
- 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.
- Parameters
-
[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) |
◆ enterHistory_()
QState QP::QMsm::enterHistory_ |
( |
QMState const *const | hist, |
|
|
std::uint_fast8_t const | qsId ) |
|
private |
Enter history of a composite state
- Details
- Static helper function to execute the segment of transition to history after entering the composite state and
- Parameters
-
[in] | hist | pointer to the history substate |
[in] | qsId | QS-id of this state machine (for QS local filter) |
- Returns
- Q_RET_TRAN_INIT, if an initial transition has been executed in the last entered state or Q_RET_NULL if no such transition was taken.
◆ topQMState()
QMState const * QP::QMsm::topQMState |
( |
| ) |
const |
|
noexcept |
The documentation for this class was generated from the following files: