proxygen
fizz::sm::StateMachine< SM > Class Template Reference

#include <StateMachine.h>

Public Types

using EventHandlerFun = typename SM::Actions(*)(const typename SM::State &, typename SM::Param)
 

Static Public Member Functions

static EventHandlerFun getHandler (typename SM::StateEnum state, typename SM::Event event)
 

Static Private Member Functions

template<std::size_t i>
static constexpr EventHandlerFun getEventHandler ()
 
template<std::size_t... Indices>
static constexpr std::array< EventHandlerFun, sizeof...(Indices)> getEventHandlers (std::index_sequence< Indices... >)
 

Detailed Description

template<typename SM>
class fizz::sm::StateMachine< SM >

Definition at line 15 of file StateMachine.h.

Member Typedef Documentation

template<typename SM>
using fizz::sm::StateMachine< SM >::EventHandlerFun = typename SM::Actions (*)(const typename SM::State&, typename SM::Param)

Definition at line 18 of file StateMachine.h.

Member Function Documentation

template<typename SM >
template<std::size_t i>
constexpr StateMachine< SM >::EventHandlerFun fizz::sm::StateMachine< SM >::getEventHandler ( )
staticprivate

Definition at line 77 of file StateMachine-inl.h.

References i.

77  {
78  return EventHandler<
79  SM,
80  static_cast<typename SM::StateEnum>(i / SM::NumEvents),
81  static_cast<typename SM::Event>(i % SM::NumEvents)>::handle;
82 }
StateEnum
template<typename SM>
template<std::size_t... Indices>
static constexpr std::array<EventHandlerFun, sizeof...(Indices)> fizz::sm::StateMachine< SM >::getEventHandlers ( std::index_sequence< Indices... >  )
inlinestaticprivate

Definition at line 33 of file StateMachine.h.

33  {
34  return {{getEventHandler<Indices>()...}};
35  }
template<typename SM >
StateMachine< SM >::EventHandlerFun fizz::sm::StateMachine< SM >::getHandler ( typename SM::StateEnum  state,
typename SM::Event  event 
)
static

Returns the appropriate event handler for event in state.

Definition at line 63 of file StateMachine-inl.h.

References i.

Referenced by fizz::server::detail::processEvent(), and fizz::client::detail::processEvent().

65  {
66  static constexpr auto handlers = getEventHandlers(
67  std::make_index_sequence<SM::NumStates * SM::NumEvents>());
68  const auto i = static_cast<std::size_t>(state) * SM::NumEvents +
69  static_cast<std::size_t>(event);
70  CHECK_LT(i, handlers.size()) << "Out of bounds handler requested";
71  return handlers[i];
72 }
static constexpr std::array< EventHandlerFun, sizeof...(Indices)> getEventHandlers(std::index_sequence< Indices... >)
Definition: StateMachine.h:33
state
Definition: http_parser.c:272

The documentation for this class was generated from the following files: