Base module

Stateful

[State]({#ref classicy_1_1State #}) machine implementation.

Stateful

#include <icy/stateful.h>

State machine implementation.

For an example See also: PacketStream

Parameters

  • The derived [State](icy-State.html#state) type.

Public Attributes

ReturnNameDescription
Signal< void(void *, T &, const T &)>StateChangeSignals when the state changes.

StateChange

Signal< void(void *, T &, const T &)> StateChange

Signals when the state changes.

Public Methods

ReturnNameDescription
Stateful inline
boolstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
boolstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
T &state virtual inlineReturns a mutable reference to the current state.
const Tstate virtual const inlineReturns a copy of the current state.

Stateful

inline

inline Stateful()

stateEquals

virtual const inline

virtual inline bool stateEquals(typename T::ID id) const

Returns true if the current state ID equals the given ID.

Parameters

  • id State ID to compare against.

Returns

True if the current state matches.


stateBetween

virtual const inline

virtual inline bool stateBetween(typename T::ID lid, typename T::ID rid) const

Returns true if the current state ID is in the inclusive range [lid, rid].

Parameters

  • lid Lower bound state ID.

  • rid Upper bound state ID.

Returns

True if lid <= state.id() <= rid.


state

virtual inline

virtual inline T & state()

Returns a mutable reference to the current state.

Returns

Reference to the internal state object.


state

virtual const inline

virtual inline const T state() const

Returns a copy of the current state.

Returns

Current state value.

Protected Attributes

ReturnNameDescription
T_state

_state

T _state

Protected Methods

ReturnNameDescription
boolbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
voidonStateChange virtual inlineOverride to handle post state change logic.
boolsetState virtual inlineSets the state and sends the state signal if the state change was successful.
boolsetState virtual inlineSets the state and sends the state signal if the state change was successful.

beforeStateChange

virtual inline

virtual inline bool beforeStateChange(const T & state)

Override to handle pre state change logic. Return false to prevent state change.


onStateChange

virtual inline

virtual inline void onStateChange(T &, const T &)

Override to handle post state change logic.


setState

virtual inline

virtual inline bool setState(void * sender, typename T::ID id)

Sets the state and sends the state signal if the state change was successful.


setState

virtual inline

virtual inline bool setState(void * sender, const T & state)

Sets the state and sends the state signal if the state change was successful.