proxygen
proxygen::StateMachine< T > Class Template Reference

#include <StateMachine.h>

Public Types

using State = typename T::State
 
using Event = typename T::Event
 

Static Public Member Functions

static State getNewInstance ()
 
static bool transit (State &state, Event event)
 
static bool canTransit (const State state, Event event)
 

Detailed Description

template<typename T>
class proxygen::StateMachine< T >

Definition at line 18 of file StateMachine.h.

Member Typedef Documentation

template<typename T >
using proxygen::StateMachine< T >::Event = typename T::Event

Definition at line 21 of file StateMachine.h.

template<typename T >
using proxygen::StateMachine< T >::State = typename T::State

Definition at line 20 of file StateMachine.h.

Member Function Documentation

template<typename T >
static bool proxygen::StateMachine< T >::canTransit ( const State  state,
Event  event 
)
inlinestatic

Definition at line 44 of file StateMachine.h.

Referenced by proxygen::HTTPTransaction::canSendHeaders().

44  {
45  bool ok;
46 
47  std::tie(std::ignore, ok) = T::find(state, event);
48  return ok;
49  }
state
Definition: http_parser.c:272
template<typename T >
static State proxygen::StateMachine< T >::getNewInstance ( )
inlinestatic

Definition at line 23 of file StateMachine.h.

23  {
24  return T::getInitialState();
25  }
template<typename T >
static bool proxygen::StateMachine< T >::transit ( State state,
Event  event 
)
inlinestatic

Definition at line 27 of file StateMachine.h.

References proxygen::ERROR.

Referenced by EgressStateMachineFixture::fail(), IngressStateMachineFixture::fail(), EgressStateMachineFixture::follow(), IngressStateMachineFixture::follow(), proxygen::HTTPTransaction::sendBody(), proxygen::HTTPTransaction::sendBodyNow(), proxygen::HTTPTransaction::sendChunkHeader(), proxygen::HTTPTransaction::sendChunkTerminator(), proxygen::HTTPTransaction::sendEOM(), proxygen::HTTPTransaction::sendEOMNow(), proxygen::HTTPTransaction::sendHeadersWithOptionalEOM(), proxygen::HTTPTransaction::sendTrailers(), and proxygen::HTTPTransaction::validateIngressStateTransition().

27  {
28  bool ok;
29  State newState;
30 
31  std::tie(newState, ok) = T::find(state, event);
32  if (!ok) {
33  LOG(ERROR) << T::getName() << ": invalid transition tried: " << state
34  << " " << event;
35  return false;
36  } else {
37  VLOG(6) << T::getName() << ": transitioning from " << state << " to "
38  << newState;
39  state = newState;
40  return true;
41  }
42  }
typename T::State State
Definition: StateMachine.h:20
state
Definition: http_parser.c:272

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