12#ifndef MAKI_TRANSITION_TABLE_HPP
13#define MAKI_TRANSITION_TABLE_HPP
17#include "event_set.hpp"
18#include "state_set.hpp"
23#include "detail/impl.hpp"
24#include "detail/state_builder_fwd.hpp"
25#include "detail/tuple.hpp"
32 template<
class... Transitions>
33 struct transition_table_impl
35 static constexpr auto size =
sizeof...(Transitions);
36 tuple<Transitions...> transitions;
40#ifdef MAKI_DETAIL_DOXYGEN
60template<
class Impl = IMPLEMENTATION_DETAIL>
63template<
class Impl = detail::transition_table_impl<>>
71 class SourceStateBuilder,
72 class TargetStateBuilder,
81 SourceStateBuilder source_state_builder;
82 TargetStateBuilder target_state_builder;
84 action<ActionSignature, ActionCallable> act;
85 guard<GuardSignature, GuardCallable> grd;
90 class SourceStateBuilder,
91 class TargetStateBuilder,
103 action<ActionSignature, ActionCallable>,
104 guard<GuardSignature, GuardCallable>
116 template<
class... Transitions>
117 constexpr auto make_transition_table(
const tuple<Transitions...>& transitions)
119 using impl_t = transition_table_impl<Transitions...>;
120 return transition_table<impl_t>{impl_t{transitions}};
124 constexpr const auto& rows(
const transition_table<Impl>& table)
126 return impl_of(table).transitions;
130 constexpr decltype(
auto) store_state_builder(T&& obj)
132 return std::forward<T>(obj);
136 constexpr auto store_state_builder(
init_t )
138 return &detail::state_builders::null;
142 constexpr auto store_state_builder(
final_t )
144 return &detail::state_builders::final;
148 template<
class OptionSet>
149 constexpr auto store_state_builder(
const state_builder<OptionSet>& builder)
200 class ActionOrNull =
null_t,
201 class GuardOrNull =
null_t
203 constexpr auto operator()
205 const Source& source_state_builder,
206 const Target& target_state_builder,
207 const EventSet& evt_set = null,
208 const ActionOrNull&
action = null,
209 const GuardOrNull&
guard = null
213 if constexpr(Impl::size == 0)
217 detail::is_init_v<Source>,
218 "Source (1st argument) of first transition must be `maki::init`. (Note: Composite state regions without initial pseudostate are not implemented yet.)"
225 detail::is_state_builder_v<Source> || detail::is_state_set_v<Source>,
226 "Source (1st argument) must be an instance of `maki::state_builder` or an instance of `maki::state_set`"
231 if constexpr(detail::is_init_v<Source>)
235 detail::is_state_builder_v<Target>,
236 "Target (2nd argument) of transition from initial pseudostate must be an instance of `maki::state_builder`."
243 detail::is_state_builder_v<Target> || detail::is_null_v<Target> || detail::is_final_v<Target>,
244 "Target (2nd argument) must be an instance of `maki::state_builder`, `maki::null` or `maki::final`."
249 if constexpr(detail::is_init_v<Source>)
253 detail::is_null_v<EventSet>,
254 "Event (3rd argument) of transition from initial pseudostate must be `maki::null`"
261 detail::is_event_v<EventSet> || detail::is_event_set_v<EventSet> || detail::is_null_v<EventSet>,
262 "Event (3rd argument) must be an instance of `maki::event_t`, an instance of `maki::event_set`, or `maki::null`"
269 detail::is_action_v<ActionOrNull> || detail::is_null_v<ActionOrNull>,
270 "Action (4th argument) must be an instance of `maki::action` or `maki::null`."
274 if constexpr(detail::is_init_v<Source>)
278 detail::is_null_v<GuardOrNull>,
279 "Guard (5th argument) of transition from initial pseudostate must be `maki::null`."
286 detail::is_guard_v<GuardOrNull> || detail::is_null_v<GuardOrNull>,
287 "Guard (5th argument) must be an instance of `maki::guard` or `maki::null`."
291 return detail::make_transition_table
298 detail::store_state_builder(source_state_builder),
299 detail::store_state_builder(target_state_builder),
301 detail::to_action(action),
302 detail::to_guard(guard)
309 using impl_type = Impl;
311#ifndef MAKI_DETAIL_DOXYGEN
312 template<
class... Transitions>
313 friend constexpr auto detail::make_transition_table(
const detail::tuple<Transitions...>&);
321 MAKI_DETAIL_FRIENDLY_IMPL
Represents a transition table.
Definition transition_table.hpp:157
constexpr transition_table(const transition_table &)=default
Copy constructor.
transition_table & operator=(transition_table &&)=delete
Deleted move operator.
transition_table(transition_table &&)=delete
Deleted move constructor.
transition_table & operator=(const transition_table &)=delete
Deleted assignment operator.
constexpr transition_table()=default
Default constructor.
IMPLEMENTATION_DETAIL init_t
The type of maki::init
Definition init.hpp:19
IMPLEMENTATION_DETAIL final_t
The type of maki::final
Definition final.hpp:19
IMPLEMENTATION_DETAIL null_t
The type of maki::null
Definition null.hpp:26
guard_signature
The set of arguments taken by a guard callable.
Definition guard.hpp:26
action_signature
The set of arguments taken by an action callable.
Definition action.hpp:26
Represents an action to be given to maki::transition_table.
Definition action.hpp:60
Represents a guard to be given to maki::transition_table. Use the builder functions (maki::guard_v() ...
Definition guard.hpp:86