A fiber-aware FSM implementation for C++14 and later, with concise eDSL and constexpr compatible.
More...
A fiber-aware FSM implementation for C++14 and later, with concise eDSL and constexpr compatible.
- See also
- fsm14.cpp
◆ State
A state within the FSM.
Definition at line 277 of file fsm14.h.
◆ action()
template<typename T >
| constexpr auto zth::fsm::action |
( |
T && |
a, |
|
|
char const * |
name = nullptr |
|
) |
| |
|
constexpr |
Create an action from a function.
The supported types are:
- function pointer:
void (*)(A)
- member function pointer:
void (C::*)()
- const member function pointer
void (C::*)() const
- lambda (C++17 when used in a
constexpr): [...](A) {...}
The argument A may be omitted. If provided, it must be zth::fsm::BasicFsm&, or a reference to the actual subclass type of zth::fsm::BasicFsm.
The class type C must be zth::fsm::BasicFsm, or the type of the subclass of zth::fsm::BasicFsm. The member function does not have to be static.
For C++17 and higher, these function can also be noexcept.
- Returns
- an Action object, to be used in the FSM transitions description.
Definition at line 654 of file fsm14.h.
◆ compile()
template<typename... T>
| constexpr auto zth::fsm::compile |
( |
T &&... |
t | ) |
|
|
constexpr |
Compile a transition description.
Definition at line 1284 of file fsm14.h.
◆ guard() [1/2]
| constexpr auto zth::fsm::guard |
( |
Symbol && |
input | ) |
|
|
inlineconstexprnoexcept |
Create a guard from a input symbol.
Using input("symbol") is usually better than guard("symbol"). However, you can create a constexpr guard using this function, while input() only returns a temporary object.
- Returns
- a Guard object, to be used in the FSM transitions description.
- See also
- input(Symbol&&)
Definition at line 553 of file fsm14.h.
◆ guard() [2/2]
template<typename T >
| constexpr auto zth::fsm::guard |
( |
T && |
g, |
|
|
char const * |
name = nullptr |
|
) |
| |
|
constexpr |
Create a guard from a function.
The supported types are:
- function pointer:
R (*)(A)
- member function pointer:
R (C::*)()
- const member function pointer
R (C::*)() const
- lambda (C++17 when used in a
constexpr): [...](A) -> R {...}
The return type R must be bool or zth::TimeInterval. The TimeInterval indicates the time until the guard may become enabled and should be checked again. When the interval is 0 or negative, the guard is supposed to be enabled.
In case the return type is bool, true is equivalent to a time interval of 0. false is equivalent to an infinite time interval.
The argument A may be omitted. If provided, it must be zth::fsm::BasicFsm&, or a reference to the actual subclass type of zth::fsm::BasicFsm.
The class type C must be zth::fsm::BasicFsm, or the type of the subclass of zth::fsm::BasicFsm. The member function does not have to be static.
For C++17 and higher, these function can also be noexcept.
- Returns
- a Guard object, to be used in the FSM transitions description.
Definition at line 537 of file fsm14.h.
◆ input()
| constexpr auto zth::fsm::input |
( |
Symbol && |
symbol | ) |
|
|
inlineconstexprnoexcept |
Create a guard from an input symbol.
This function returns a temporary, while guard("symbol") returns an object that can be constexpr.
- See also
- guard(Symbol&&)
Definition at line 787 of file fsm14.h.
◆ operator""_S()
| constexpr Symbol zth::fsm::operator""_S |
( |
char const * |
s, |
|
|
size_t |
len |
|
) |
| |
|
constexprnoexcept |
◆ always
| constexpr auto zth::fsm::always |
|
inlineconstexpr |
Trivial guard that is always enabled.
Definition at line 571 of file fsm14.h.
◆ consume
| constexpr auto zth::fsm::consume |
|
inlineconstexpr |
Action consume the current input symbol.
Usually, combined with the input guard. When a transition is taken because of an input symbol, remove that symbol from the list of inputs symbol. If consume is not used, the symbol guard will be enabled again the next evaluation of the guards.
Definition at line 2062 of file fsm14.h.
◆ entry
| constexpr auto zth::fsm::entry |
|
inlineconstexpr |
Guard that is only enabled upon entry of a state.
Definition at line 2020 of file fsm14.h.
◆ never
| constexpr auto zth::fsm::never |
|
inlineconstexpr |
Trivial guard that is never enabled.
Definition at line 583 of file fsm14.h.
◆ nothing
| constexpr auto zth::fsm::nothing |
|
inlineconstexpr |
Trivial action that does nothing.
Definition at line 666 of file fsm14.h.
◆ pop
| constexpr auto zth::fsm::pop |
|
inlineconstexpr |
Action to pop the current state from the stack.
Definition at line 2035 of file fsm14.h.
◆ popped
| constexpr auto zth::fsm::popped |
|
inlineconstexpr |
Guard to indicate that the current state was reached via pop.
Definition at line 2042 of file fsm14.h.
◆ push
| constexpr auto zth::fsm::push |
|
inlineconstexpr |
◆ stop
| constexpr auto zth::fsm::stop |
|
inlineconstexpr |
◆ timeout_ms
template<uint64_t ms>
| constexpr auto zth::fsm::timeout_ms |
|
inlineconstexpr |
A guard that is enabled after a ms milliseconds after entering the current state.
Definition at line 2081 of file fsm14.h.
◆ timeout_s
template<time_t s>
| constexpr auto zth::fsm::timeout_s |
|
inlineconstexpr |
A guard that is enabled after a s seconds after entering the current state.
Definition at line 2072 of file fsm14.h.
◆ timeout_us
template<uint64_t us>
| constexpr auto zth::fsm::timeout_us |
|
inlineconstexpr |
A guard that is enabled after a us microseconds after entering the current state.
Definition at line 2090 of file fsm14.h.