defmodule <%= inspect(@module) %> do @moduledoc """ `Finitomata`-based implementation of … """ @fsm """ <%= String.trim(@fsm) %> """ <%= @use_clause %> # State @type t :: %{ __struct__: __MODULE__, name: Finitomata.fsm_name() } defstruct name: nil # Interface @spec start_fsm(Finitomata.id(), Finitomata.fsm_name()) :: DynamicSupervisor.on_start_child() def start_fsm(id \\ nil, name), do: Finitomata.start_fsm(id, name, __MODULE__, %__MODULE__{name: name}) # Implementation <%= for %Finitomata.Transition{from: from, to: to, event: event} <- @transitions, from != :* do %> <%= if to != :* or not @auto_terminate? do %> @impl Finitomata def on_transition(:<%= from %>, :<%= event %>, _event_payload, state) do {:ok, :<%= to %>, state} end <% end %> <% end %> <%= if @timer? do %> @impl Finitomata def on_timer(_fsm_state, state) do {:ok, state} end <% end %> <%= if :on_enter in @to_implement do %> @impl Finitomata def on_enter(_fsm_state, _state) do :ok end <% end %> <%= if :on_exit in @to_implement do %> @impl Finitomata def on_exit(_fsm_state, _state) do :ok end <% end %> <%= if :on_failure in @to_implement do %> @impl Finitomata def on_failure(_event, _event_payload, _state) do :ok end <% end %> <%= if :on_terminate in @to_implement do %> @impl Finitomata def on_terminate(_state) do :ok end <% end %> end