fsmlite API Reference¶
-
template<class Derived, class State = int>
class fsm¶ Finite state machine (FSM) base class template.
- Template Parameters:
Derived – the derived state machine class
State – the FSM’s state type, defaults to
int
Public Functions
-
inline 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>
inline void process_event(const Event &event)¶ Process an event.
Warning
This member function must not be called recursively, e.g. from another
fsminstance.- Template Parameters:
Event – the event type
- Parameters:
event – the event instance
- Throws:
std::logic_error – if a recursive invocation is detected
-
inline state_type current_state() const¶
Return the state machine’s current state.
Protected Types
Protected Functions
-
template<class Event>
inline state_type no_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.
- Template Parameters:
Event – the event type
- Parameters:
event – the event instance
- Returns:
the FSM’s new state
-
template<State start, class Event, State target, class Action = std::nullptr_t, Action action = nullptr, class Guard = std::nullptr_t, Guard guard = nullptr>
struct basic_row : public fsmlite::fsm<start, Event, target>::row_base¶ Basic transition class template.
- Template Parameters:
start – the start state of the transition
Event – the event type triggering the transition
target – the target state of the transition
Action – an action function type, or
std::nullptr_taction – a static
ActioninstanceGuard – a guard function type, or
std::nullptr_tguard – a static
Guardinstance
-
template<State start, class Event, State target, void (Derived::* action)(const Event&) = nullptr, bool (Derived::* guard)(const Event&) const = nullptr>
struct mem_fn_row : public fsmlite::fsm<start, Event, target>::row_base¶ Member function transition class template.
- Deprecated:
since version 1.0
- Template Parameters:
start – the start state of the transition
Event – the event type triggering the transition
target – the target state of the transition
action – an action member function, or
nullptrguard – a guard member function, or
nullptr
-
template<State start, class Event, State target, auto action = nullptr, auto guard = nullptr>
struct row : public fsmlite::fsm<start, Event, target>::row_base¶ Generic transition class template.
- Template Parameters:
start – the start state of the transition
Event – the event type triggering the transition
target – the target state of the transition
action – a static action function pointer, or
nullptrguard – a static guard function pointer, or
nullptr