proxygen
StateMachine.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #pragma once
10 
11 namespace fizz {
12 namespace sm {
13 
14 template <typename SM>
15 class StateMachine {
16  public:
17  using EventHandlerFun =
18  typename SM::Actions (*)(const typename SM::State&, typename SM::Param);
19 
24  typename SM::StateEnum state,
25  typename SM::Event event);
26 
27  private:
28  template <std::size_t i>
29  static constexpr EventHandlerFun getEventHandler();
30 
31  template <std::size_t... Indices>
32  static constexpr std::array<EventHandlerFun, sizeof...(Indices)>
33  getEventHandlers(std::index_sequence<Indices...>) {
34  return {{getEventHandler<Indices>()...}};
35  }
36 };
37 } // namespace sm
38 } // namespace fizz
39 
boost::variant< ClientHello, ServerHello, EndOfEarlyData, HelloRetryRequest, EncryptedExtensions, CertificateRequest, CompressedCertificate, CertificateMsg, CertificateVerify, Finished, NewSessionTicket, KeyUpdate, Alert, Accept, Connect, AppData, AppWrite, EarlyAppWrite, WriteNewSessionTicket > Param
Definition: Params.h:90
State
See Core for details.
Definition: Core.h:43
std::vector< Action > Actions
Definition: Actions.h:81
static EventHandlerFun getHandler(typename SM::StateEnum state, typename SM::Event event)
StateEnum
Definition: Actions.h:16
static constexpr std::array< EventHandlerFun, sizeof...(Indices)> getEventHandlers(std::index_sequence< Indices... >)
Definition: StateMachine.h:33
static constexpr EventHandlerFun getEventHandler()
Event
Definition: Events.h:15
typename SM::Actions(*)(const typename SM::State &, typename SM::Param) EventHandlerFun
Definition: StateMachine.h:18
state
Definition: http_parser.c:272