14 #include "detail/state_manager.h" 20 template<
class States,
class Events,
class Context,
class Tracer = detail::NullTracer>
24 using states_type = States;
25 using events_type = Events;
26 using tracer_type = Tracer;
36 std::enable_if_t<std::is_constructible_v<T>,
bool> =
true>
39 , manager_ {context_, tracer_}
52 std::enable_if_t<std::is_lvalue_reference_v<T>,
bool> =
true>
55 , manager_ {context_, tracer_}
62 std::enable_if_t<!std::is_lvalue_reference_v<T>,
bool> =
true>
64 : context_ {std::move(ctx)}
65 , manager_ {context_, tracer_}
75 template<
class S,
class E,
class C>
77 : context_ {std::forward<C>(ctx)}
78 , manager_ {context_, tracer_}
87 , tracer_ {std::move(
tracer)}
88 , manager_ {context_,
tracer}
98 return manager_.dispatch(e);
106 return manager_.dispatch(e);
142 std::remove_reference_t<Context>,
auto & tracer()
Gets a reference to a tracer object.
Definition: state_machine.h:112
auto const & context() const
Gets a reference to a context.
Definition: state_machine.h:133
Definition: testJsonContexts.cpp:18
Manages a set of state, creates, destroys and pass events to a proper state.
Definition: state_manager.h:42
Definition: state_machine.h:21
auto & context()
Gets a reference to a context.
Definition: state_machine.h:126
state_machine(Context &ctx)
Creates a state machine with a reference to a context.
Definition: state_machine.h:53
auto const & tracer() const
Gets a reference to a tracer object.
Definition: state_machine.h:119
Definition: compressed_pair.h:10
auto dispatch(E const &e)
Dispatch an event to a current state.
Definition: state_machine.h:97
state_machine()
Creates a state machine.
Definition: state_machine.h:37
state_machine(States, Events, Context &ctx, Tracer &&tracer)
Creates a state machine with a context and a tracer.
Definition: state_machine.h:85
state_machine(S, E, C &&ctx)
Creates a state machine with a context.
Definition: state_machine.h:76
auto dispatch(E const &e) const
Dispatch an event to a current state.
Definition: state_machine.h:105