fsm 0.4.1
Header-only C++20 hierarchical table-driven FSM
Loading...
Searching...
No Matches
fsm::row< State, Event, Context, Payload, Reason > Struct Template Reference

One transition-table row: {from, on, when, then, to}. More...

#include <fsm.hpp>

Collaboration diagram for fsm::row< State, Event, Context, Payload, Reason >:

Public Types

using payload_type = Payload
 
using reason_type = Reason
 
using guard_fn = typename detail::fn_sigs< Context, Payload >::guard
 
using action_fn = typename detail::fn_sigs< Context, Payload >::action
 

Public Attributes

from_spec< State > from
 Source state or fsm::any (mandatory).
 
on_spec< Event > on
 Trigger event (mandatory).
 
guard_fn when = nullptr
 Optional guard.
 
action_fn then = nullptr
 Optional action.
 
target< State, Reason > to
 Transition/internal/refuse (mandatory).
 
const char * label = nullptr
 

Detailed Description

template<class State, class Event, class Context, class Payload = void, class Reason = uint8_t>
struct fsm::row< State, Event, Context, Payload, Reason >

One transition-table row: {from, on, when, then, to}.

Rows are plain constexpr data: enumerable, dumpable, diagrammable. Matching walks the active state chain leaf → ancestors → fsm::any rows; within a level, table order, first row whose guard passes wins.

Template Parameters
Statestate enum (dense, Count sentinel)
Eventevent enum (dense, Count sentinel)
Contextuser context passed to guards/actions by reference
Payloadoptional event payload type (void = none)
Reasonrefusal reason type

Member Typedef Documentation

◆ action_fn

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
using fsm::row< State, Event, Context, Payload, Reason >::action_fn = typename detail::fn_sigs<Context, Payload>::action

Transition/internal action. nullptr = none.

◆ guard_fn

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
using fsm::row< State, Event, Context, Payload, Reason >::guard_fn = typename detail::fn_sigs<Context, Payload>::guard

Guard: arbitrary predicate over context (+ payload). nullptr = always pass.

◆ payload_type

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
using fsm::row< State, Event, Context, Payload, Reason >::payload_type = Payload

◆ reason_type

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
using fsm::row< State, Event, Context, Payload, Reason >::reason_type = Reason

Member Data Documentation

◆ from

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
from_spec<State> fsm::row< State, Event, Context, Payload, Reason >::from

Source state or fsm::any (mandatory).

◆ label

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
const char* fsm::row< State, Event, Context, Payload, Reason >::label = nullptr

Optional human-readable note ("why this row exists"), shown by dump() and fsm::write_dot(). Guards/actions are bare function pointers, so this is the only place introspection can find intent.

◆ on

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
on_spec<Event> fsm::row< State, Event, Context, Payload, Reason >::on

Trigger event (mandatory).

◆ then

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
action_fn fsm::row< State, Event, Context, Payload, Reason >::then = nullptr

Optional action.

◆ to

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
target<State, Reason> fsm::row< State, Event, Context, Payload, Reason >::to

Transition/internal/refuse (mandatory).

◆ when

template<class State , class Event , class Context , class Payload = void, class Reason = uint8_t>
guard_fn fsm::row< State, Event, Context, Payload, Reason >::when = nullptr

Optional guard.


The documentation for this struct was generated from the following file: