#include <icy/stateful.h>Subclassed by:
DiagnosticState,PacketStreamState,TransactionState,EncoderState,InstallationState,ClientState,ClientState
State class for state machines.
This class defines the state for a state machine, and should be extended and passed to implementations of the [Stateful](icy-Stateful.html#stateful) template.
For an example See also: PacketStreamState
| Return | Name | Description |
|---|---|---|
State | #### Parameters | |
State | Copy constructor. | |
State & | operator= | Copy assignment. |
ID | id const | Returns the current state ID. |
void | set | Sets the state ID. |
std::string | str virtual const | Returns a human-readable string for the given state ID. Override in derived classes to provide meaningful names. |
std::string | toString virtual const | Returns a human-readable string for the current state ID. |
bool | equals const | Returns true if the current state ID equals the given ID. |
bool | between const | Returns true if the current state ID is in the inclusive range [lid, rid]. |
bool | operator== const inline | |
bool | operator== const inline |
State(ID id)id Initial state ID. Defaults to 0.State(const State & that)Copy constructor.
that State to copy from.State & operator=(const State & that)Copy assignment.
that State to assign from.const
ID id() constReturns the current state ID.
Atomic state ID value.
void set(ID id)Sets the state ID.
id New state ID to assign.virtual const
virtual std::string str(ID id) constReturns a human-readable string for the given state ID. Override in derived classes to provide meaningful names.
id State ID to convert.String representation of the state, or "undefined" by default.
virtual const
virtual std::string toString() constReturns a human-readable string for the current state ID.
Result of str(id()).
const
bool equals(ID id) constReturns true if the current state ID equals the given ID.
id State ID to compare against.True if IDs match.
const
bool between(ID lid, ID rid) constReturns true if the current state ID is in the inclusive range [lid, rid].
lid Lower bound state ID.
rid Upper bound state ID.
True if lid <= id() <= rid.
const inline
inline bool operator==(const State & that) constconst inline
inline bool operator==(const State::ID & that) const| Return | Name | Description |
|---|---|---|
std::atomic< ID > | _id |
std::atomic< ID > _id| Name | Description |
|---|---|
ID |
uint32_t ID()