State
State
#include <icy/stateful.h>class StateDefined in src/base/include/icy/stateful.h:31
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
List of all members
| Name | Kind | Owner |
|---|---|---|
operator<< | friend | Declared here |
State | function | Declared here |
State | function | Declared here |
operator= | function | Declared here |
~State | function | Declared here |
id | function | Declared here |
set | function | Declared here |
str | function | Declared here |
toString | function | Declared here |
equals | function | Declared here |
between | function | Declared here |
operator== | function | Declared here |
operator== | function | Declared here |
_id | variable | Declared here |
ID | typedef | Declared here |
Friends
| Name | Description |
|---|---|
operator<< inline |
operator<<
inline
friend inline std::ostream & operator<<(std::ostream & os, const State & state)Defined in src/base/include/icy/stateful.h:80
Public Methods
| Return | Name | Description |
|---|---|---|
State | ||
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
State(ID id = 0)Defined in src/base/include/icy/stateful.h:37
Parameters
idInitial state ID. Defaults to 0.
State
State(const State & that)Defined in src/base/include/icy/stateful.h:41
Copy constructor.
Parameters
thatState to copy from.
operator=
State & operator=(const State & that)Defined in src/base/include/icy/stateful.h:45
Copy assignment.
Parameters
thatState to assign from.
id
const
ID id() constDefined in src/base/include/icy/stateful.h:50
Returns the current state ID.
Returns
Atomic state ID value.
set
void set(ID id)Defined in src/base/include/icy/stateful.h:54
Sets the state ID.
Parameters
idNew state ID to assign.
str
virtual const
virtual std::string str(ID id) constDefined in src/base/include/icy/stateful.h:60
Returns a human-readable string for the given state ID. Override in derived classes to provide meaningful names.
Parameters
idState ID to convert.
Returns
String representation of the state, or "undefined" by default.
toString
virtual const
virtual std::string toString() constDefined in src/base/include/icy/stateful.h:64
Returns a human-readable string for the current state ID.
Returns
Result of str(id()).
Reimplemented by
equals
const
bool equals(ID id) constDefined in src/base/include/icy/stateful.h:69
Returns true if the current state ID equals the given ID.
Parameters
idState ID to compare against.
Returns
True if IDs match.
between
const
bool between(ID lid, ID rid) constDefined in src/base/include/icy/stateful.h:75
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 <= id() <= rid.
operator==
const inline
inline bool operator==(const State & that) constDefined in src/base/include/icy/stateful.h:77
operator==
const inline
inline bool operator==(const State::ID & that) constDefined in src/base/include/icy/stateful.h:78
Protected Attributes
| Return | Name | Description |
|---|---|---|
std::atomic< ID > | _id |
_id
std::atomic< ID > _idDefined in src/base/include/icy/stateful.h:87
Public Types
| Name | Description |
|---|---|
ID |
ID
using ID = uint32_t