fsmlite API Reference¶
-
template <class Derived, class State = int>
classfsm
¶ Finite state machine (FSM) base class template.
- Template Parameters
Derived
: the derived state machine classState
: the FSM’s state type, defaults toint
Public Types
-
typedef State
state_type
¶ The FSM’s state type.
Public Functions
-
fsm
(state_type init_state = state_type())¶ Create a state machine with an optional initial state.
- Parameters
init_state
: the FSM’s initial state
-
template <class Event>
voidprocess_event
(const Event &event)¶ Process an event.
- Warning
- This member function must not be called recursively, e.g. from another
fsm
instance. - Template Parameters
Event
: the event type
- Parameters
event
: the event instance
- Exceptions
std::logic_error
: if a recursive invocation is detected
-
state_type
current_state
() const¶ Return the state machine’s current state.
Protected Types
-
template<>
usingtable
= detail::list<Rows...>¶ Transition table variadic class template.
Each derived state machine class must define a nested non-template type
transition_table
that’s either derived from or a type alias oftable
.
Protected Functions
-
template <class Event>
state_typeno_transition
(const Event&)¶ Called when no transition can be found for the given event in the current state.
Derived state machines may override this to throw an exception, or change to some other (error) state. The default is to return the current state, so no state change occurs.
- Return
- the FSM’s new state
- Template Parameters
Event
: the event type
- Parameters
event
: the event instance
-
template <State start, class Event, State target, class Action = std::nullptr_t, Action action = nullptr, class Guard = std::nullptr_t, Guard guard = nullptr>
structbasic_row
: public fsmlite::fsm<start, Event, target>::row_base¶ Basic transition class template.
- Template Parameters
start
: the start state of the transitionEvent
: the event type triggering the transitiontarget
: the target state of the transitionAction
: an action function type, orstd::nullptr_t
action
: a staticAction
instanceGuard
: a guard function type, orstd::nullptr_t
guard
: a staticGuard
instance
-
template <State start, class Event, State target, void(Derived::*)(const Event &) action = nullptr, bool(Derived::*)(const Event &) const guard = nullptr>
structmem_fn_row
: public fsmlite::fsm<start, Event, target>::row_base¶ Member function transition class template.
- Template Parameters
start
: the start state of the transitionEvent
: the event type triggering the transitiontarget
: the target state of the transitionaction
: an action member function, ornullptr
guard
: a guard member function, ornullptr
-
template <State start, class Event, State target, auto action = nullptr, auto guard = nullptr>
structrow
: public fsmlite::fsm<start, Event, target>::row_base¶ Generic transition class template (requires C++17).
- Template Parameters
start
: the start state of the transitionEvent
: the event type triggering the transitiontarget
: the target state of the transitionaction
: a static action function pointer, ornullptr
guard
: a static guard function pointer, ornullptr