Stateful
Stateful
#include <icy/stateful.h>State machine implementation.
For an example See also: PacketStream
Parameters
Thederived[State](icy-State.html#state)type.
Public Attributes
| Return | Name | Description |
|---|---|---|
Signal< void(void *, T &, const T &)> | StateChange | Signals when the state changes. |
StateChange
Signal< void(void *, T &, const T &)> StateChangeSignals when the state changes.
Public Methods
| Return | Name | Description |
|---|---|---|
Stateful inline | ||
bool | stateEquals virtual const inline | Returns true if the current state ID equals the given ID. |
bool | stateBetween virtual const inline | Returns true if the current state ID is in the inclusive range [lid, rid]. |
T & | state virtual inline | Returns a mutable reference to the current state. |
const T | state virtual const inline | Returns a copy of the current state. |
Stateful
inline
inline Stateful()stateEquals
virtual const inline
virtual inline bool stateEquals(typename T::ID id) constReturns true if the current state ID equals the given ID.
Parameters
idState 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) constReturns true if the current state ID is in the inclusive range [lid, rid].
Parameters
lidLower bound state ID.ridUpper 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() constReturns a copy of the current state.
Returns
Current state value.
Protected Attributes
| Return | Name | Description |
|---|---|---|
T | _state |
_state
T _stateProtected Methods
| Return | Name | Description |
|---|---|---|
bool | beforeStateChange virtual inline | Override to handle pre state change logic. Return false to prevent state change. |
void | onStateChange virtual inline | Override to handle post state change logic. |
bool | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
bool | setState virtual inline | Sets 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.
