QP/C++ 8.1.3
Real-Time Event Framework
Loading...
Searching...
No Matches
QP::QHsmDummy Class Reference

Dummy hierarchical state machine class for testing. More...

#include <qs.hpp>

Inheritance diagram for QP::QHsmDummy:
QP::QAsm

Public Member Functions

 QHsmDummy ()
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 dispatch (QEvt const *const e, std::uint_fast8_t const qsId) override
 Virtual function to dispatch an event to the state machine.
bool isIn (QStateHandler const stateHndl) override
 Virtual function to check whether the state machine is in a given state.
QStateHandler getStateHandler () const noexcept override
 Virtual method for getting the current state handler.
Public Member Functions inherited from QP::QAsm
virtual ~QAsm ()=default
 Virtual destructor of the QP::QAsm abstract base class.
virtual void init (std::uint_fast8_t const qsId)
 Virtual function to take the top-most initial transition in the state machine (overloaded).
QStateHandler state () const noexcept
QMState const * stateObj () const noexcept

Additional Inherited Members

Static Public Member Functions inherited from QP::QAsm
static constexpr QState Q_HANDLED ()
static constexpr QState Q_UNHANDLED ()
static constexpr QState QM_HANDLED ()
static constexpr QState QM_UNHANDLED ()
static constexpr QState QM_SUPER ()
static QState top (void *const me, QEvt const *const e) noexcept
 Top state handler that ignores all events.
Public Attributes inherited from QP::QAsm
QAsmAttr m_state
 Current state (pointer to the current state-handler function).
QAsmAttr m_temp
 Temporary storage for target/act-table etc.
Static Public Attributes inherited from QP::QAsm
static constexpr QState Q_RET_SUPER {0U}
static constexpr QState Q_RET_UNHANDLED {1U}
static constexpr QState Q_RET_HANDLED {2U}
static constexpr QState Q_RET_TRAN {3U}
static constexpr QState Q_RET_TRAN_HIST {4U}
static constexpr QState Q_RET_IGNORED {5U}
static constexpr QState Q_RET_ENTRY {6U}
static constexpr QState Q_RET_EXIT {7U}
static constexpr QState Q_RET_TRAN_INIT {8U}
static constexpr QSignal Q_EMPTY_SIG {0U}
static constexpr QSignal Q_ENTRY_SIG {1U}
static constexpr QSignal Q_EXIT_SIG {2U}
static constexpr QSignal Q_INIT_SIG {3U}
static constexpr QMState const * QM_STATE_NULL { nullptr }
static constexpr QActionHandler const Q_ACTION_NULL { nullptr }
Protected Member Functions inherited from QP::QAsm
 QAsm () noexcept
 Constructor of the QP::QAsm base class.
QState tran (QStateHandler const target) noexcept
 Internal helper function to take a state transition in sublclasses of QP::QAsm.
QState tran_hist (QStateHandler const hist) noexcept
 Internal helper function to take a state transition to history in sublclasses of QP::QAsm.
QState super (QStateHandler const superstate) noexcept
 Internal helper function to indicate superstate of a given state in sublclasses of QP::QAsm.
QState qm_tran (void const *const tatbl) noexcept
 Internal helper function to take a state transition in QP::QMsm.
QState qm_tran_init (void const *const tatbl) noexcept
QState qm_tran_hist (QMState const *const hist, void const *const tatbl) noexcept
 Internal helper function to take a state transition to history in QP::QMsm.
QState qm_entry (QMState const *const s) noexcept
 Internal helper function to execute state entry actions in QP::QMsm.
QState qm_exit (QMState const *const s) noexcept
 Internal helper function to execute state exit actions in QP::QMsm.

Detailed Description

Dummy hierarchical state machine class for testing.

Details
QP::QHsmDummy is a test double for the role of "Orthogonal Components" state machine objects in QUTest unit testing.

Note
QPP::QHsmDummy can be used for testing subclasses of both ::QHsm and ::QMsm base classes.

Definition at line 691 of file qs.hpp.

Constructor & Destructor Documentation

◆ QHsmDummy()

QP::QHsmDummy::QHsmDummy ( )

Definition at line 394 of file qutest.cpp.

Member Function Documentation

◆ init()

void QP::QHsmDummy::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]epointer to an initialization parameter (might be nullptr)
[in]qsIdQS-id of this state machine (for QS local filter)

Implements QP::QAsm.

Definition at line 399 of file qutest.cpp.

◆ dispatch()

void QP::QHsmDummy::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]epointer to the event to be dispatched to the MSM
[in]qsIdQS-id of this state machine (for QS local filter)

Implements QP::QAsm.

Definition at line 430 of file qutest.cpp.

◆ isIn()

bool QP::QHsmDummy::isIn ( QStateHandler const state)
overridevirtual

Virtual function to check whether the state machine is in a given state.

Details
Tests if a given state is part of the current active state configuration. Please note that in a hierarchical state machine, to "be in a state" means also to be in a superstate of the state.

Parameters
[in]statepointer to the state-handler function to be checked
Returns
'true' if the state machine "is in" the state and 'false' otherwise
Attention
The QAsm::isIn() operation is available only for tracing/testing (when Q_SPY is defined). This is to prevent the following problematic uses of the "is-in" query:
  • Querying the current state inside the state machine in question (e.g., as a guard condition based on QAsm::isIn()) is generally a bad design and often makes no sense because the state machine might be in the middle of a transition, where the current state is not well-defined.
  • Querying the current state of a concurrently executing state machine (e.g., from one active object to the other) is a bad idea because such a state can change asynchronously. Also, the other state machine might be in the middle of a state transition, where the "current state" is not well-defined.
  • Querying the current state requires exposing the state handlers to the rest of the system. (The QAsm::isIn() requires the state-handler parameter).

Backward Traceability

  • SRS_QP_SM_25: All State Machine Implementation Strategies provided by the QP/C++ Framework component might supply a method for checking if a state machine is in a given state.

Implements QP::QAsm.

Definition at line 445 of file qutest.cpp.

◆ getStateHandler()

QStateHandler QP::QHsmDummy::getStateHandler ( ) const
overridevirtualnoexcept

Virtual method for getting the current state handler.

Details
This virtual call applies to all subclasses of QP::QAsm, such as: QP::QHsm, QP::QMsm, QP::QActive, and QP::QMActive.

Returns
the current state-handler of the type QP::QStateHandler (pointer to function)
Note
This function can be called in any context (including from a critical section) and also not necessarily in the "stable state configuration". When called during a state transition in the state machine, it returns the source state.

Backward Traceability

  • SRS_QP_SM_26: All State Machine Implementation Strategies provided by the QP/C++ Framework component might supply a method for obtaining the current state.

Usage
The following example illustrates how to obtain the current state handler of an Active Object:

QStateHandler handler = myAO->getStateHandler();
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Definition qp.hpp:141

Implements QP::QAsm.

Definition at line 450 of file qutest.cpp.


The documentation for this class was generated from the following files: