OS
v1.7.5
Documentation
|
A state object. More...
#include <fsm.hpp>
Public Member Functions | |
state ()=default | |
bool | add (sm::state &s, const sm::stateCallback_t &sFcn, sm::state &init) noexcept |
Add the specified state as a child state. | |
bool | add (sm::state &s, const sm::stateCallback_t &sFcn) noexcept |
Add the specified state as a child state. | |
bool | install (transition *table, size_t n) noexcept |
Install a table with the outgoing transitions for this state. | |
template<size_t numberOfTransitions> | |
bool | install (transition(&table)[numberOfTransitions]) noexcept |
Install a table with the outgoing transitions for this state. | |
bool | install (transition *table, size_t nTable, timeoutStateDefinition *def, size_t nDef) |
Install both, a table with the outgoing transitions for this state and fixed timeouts for the specified state using a lookup-table. | |
template<size_t numberOfTransitions, size_t numberOfTimeoutDefs> | |
bool | install (transition(&table)[numberOfTransitions], timeoutStateDefinition(&def)[numberOfTimeoutDefs]) noexcept |
Install both, a table with the outgoing transitions for this state and fixed timeouts for the specified state using a lookup-table. | |
bool | install (timeoutStateDefinition *def, size_t n) noexcept |
Install fixed timeouts for the specified state using a lookup-table. | |
template<size_t numberOfTimeoutDefs> | |
bool | install (timeoutStateDefinition(&def)[numberOfTimeoutDefs]) noexcept |
Install fixed timeouts for the specified state using a lookup-table. | |
void * | getData (void) noexcept |
Retrieve the state data or storage-pointer. | |
void | setData (void *pData) noexcept |
Set the state data or storage-pointer. | |
transition * | getTransitionTable (void) noexcept |
Retrieve a pointer to the state transition table. | |
void | setCallback (const stateCallback_t sFcn) noexcept |
Set/Change the state callback. | |
Protected Member Functions | |
virtual sm::status | activities (sm::handler_t h) |
A state object.
States are represented as instances of the state object. One important attribute of this object is the callback function, which is used to describe the behavior specific to the state. Also there is a pointer to the parent state to define nesting of the state and its place in the hierarchical topology.
So concrete state machine are built by adding an arbitrary number states and defining callback functions.
State machines are constructed by composition, therefore, the topology of a state machine is determined upon construction. In this FSM implementation, there are not distinction between composite states(states containing sub-states) and leaf states. All states are potentially composite.
The APIs stateMachine::add() and state::add() should be used to initialize the state and define its position in the topology.
|
default |
|
protectedvirtual |
|
inlinenoexcept |
Add the specified state as a child state.
[in] | s | The state object. |
[in] | sFcn | The handler function associated to the state. |
Prototype:
true
on success, otherwise return false
.
|
inlinenoexcept |
Add the specified state as a child state.
[in] | s | The state object. |
[in] | sFcn | The handler function associated to the state. |
Prototype:
[in] | init | The first child-state to be executed if the subscribed state its a parent in an hierarchical pattern. (default transition). You can ignore this argument. |
true
on success, otherwise return false
.
|
noexcept |
Retrieve the state data or storage-pointer.
|
noexcept |
Retrieve a pointer to the state transition table.
nullptr
.
|
noexcept |
Install fixed timeouts for the specified state using a lookup-table.
[in] | def | The lookup table matching the requested timeout values with their respective options. { [Timeout value], [Options(Combined with a bitwise OR)] } |
[in] | n | The number of elements inside def. |
true
on success, otherwise returns false
.
|
inlinenoexcept |
Install fixed timeouts for the specified state using a lookup-table.
numberOfTimeoutDefs | The number of elements in def |
[in] | def | The lookup table matching the requested timeout values with their respective options. { [Timeout value], [Options(Combined with a bitwise OR)] } |
true
on success, otherwise returns false
.
|
noexcept |
Install a table with the outgoing transitions for this state.
[in] | table | An array of entries of type sm::transition_t with the outgoing transitions. Each entry relates signals, actions and the target state using the following layout: { [Signal], [Action/Guard], [Target state], [History Mode] } |
[in] | n | The number of elements inside table. |
true
on success, otherwise return false
.
|
inline |
Install both, a table with the outgoing transitions for this state and fixed timeouts for the specified state using a lookup-table.
[in] | table | An array of entries of type sm::transition_t with the outgoing transitions. Each entry relates signals, actions and the target state using the following layout: { [Signal], [Action/Guard], [Target state], [History Mode] } |
[in] | nTable | The number of elements inside table. |
[in] | def | The lookup table matching the requested timeout values with their respective options. { [Timeout value], [Options(Combined with a bitwise OR)] } |
[in] | nDef | The number of elements inside def. |
true
on success, otherwise return false
.
|
inlinenoexcept |
Install a table with the outgoing transitions for this state.
numberOfTransitions | The array size |
[in] | table | An array of entries of type sm::transition_t with the outgoing transitions. Each entry relates signals, actions and the target state using the following layout: { [Signal], [Action/Guard], [Target state], [History Mode] } |
true
on success, otherwise return false
.
|
inlinenoexcept |
Install both, a table with the outgoing transitions for this state and fixed timeouts for the specified state using a lookup-table.
numberOfTransitions | The number of elements in table |
numberOfTimeoutDefs | The number of elements in def |
[in] | table | An array of entries of type sm::transition_t with the outgoing transitions. Each entry relates signals, actions and the target state using the following layout: { [Signal], [Action/Guard], [Target state], [History Mode] } |
[in] | def | The lookup table matching the requested timeout values with their respective options. { [Timeout value], [Options(Combined with a bitwise OR)] } |
true
on success, otherwise return false
.
|
noexcept |
Set/Change the state callback.
[in] | sFcn | The state callback function. |
|
noexcept |
Set the state data or storage-pointer.
[in] | pData | The state data or storage-pointer. |