Stateful
Stateful
#include <icy/stateful.h>template<typename T>
class StatefulDefined in src/base/include/icy/stateful.h:97
State machine implementation.
For an example See also: PacketStream
Parameters
Thederived[State](icy-State.html#state)type.
List of all members
| Name | Kind | Owner |
|---|---|---|
StateChange | variable | Declared here |
Stateful | function | Declared here |
~Stateful | function | Declared here |
stateEquals | function | Declared here |
stateBetween | function | Declared here |
state | function | Declared here |
state | function | Declared here |
_state | variable | Declared here |
beforeStateChange | function | Declared here |
onStateChange | function | Declared here |
setState | function | Declared here |
setState | function | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
Signal< void(void *, T &, const T &)> | StateChange | Signals when the state changes. |
StateChange
Signal< void(void *, T &, const T &)> StateChangeDefined in src/base/include/icy/stateful.h:130
Signals 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()Defined in src/base/include/icy/stateful.h:100
stateEquals
virtual const inline
virtual inline bool stateEquals(typename T::ID id) constDefined in src/base/include/icy/stateful.h:107
Returns 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) constDefined in src/base/include/icy/stateful.h:116
Returns 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()Defined in src/base/include/icy/stateful.h:123
Returns a mutable reference to the current state.
Returns
Reference to the internal state object.
state
virtual const inline
virtual inline const T state() constDefined in src/base/include/icy/stateful.h:127
Returns a copy of the current state.
Returns
Current state value.
Protected Attributes
| Return | Name | Description |
|---|---|---|
T | _state |
_state
T _stateDefined in src/base/include/icy/stateful.h:170
Protected 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)Defined in src/base/include/icy/stateful.h:135
Override to handle pre state change logic. Return false to prevent state change.
onStateChange
virtual inline
virtual inline void onStateChange(T &, const T &)Defined in src/base/include/icy/stateful.h:143
Override to handle post state change logic.
Reimplemented by
setState
virtual inline
virtual inline bool setState(void * sender, typename T::ID id)Defined in src/base/include/icy/stateful.h:147
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)Defined in src/base/include/icy/stateful.h:156
Sets the state and sends the state signal if the state change was successful.
