5#include "./abstract_state_machine.h"
49 std::function<void(T, T)> mTransitionCallback;
62 if (mFiniteStateMachine)
64 mFiniteStateMachine->
Transit(mState, nextState);
71 mFiniteStateMachine{
nullptr}
76 virtual ~MachineState() =
default;
95 mFiniteStateMachine = finiteStateMachine;
Abstract Finite State Machine (FMS) that transits between states.
Definition: abstract_state_machine.h:14
virtual void Transit(T previousState, T nextState)=0
Tranit from the current state to a new state.
Machine state abstract class.
Definition: machine_state.h:46
virtual void Deactivate(T nextState)=0
Deactivating the current state before transiting to the next state.
T GetState() const noexcept
Get the machine state.
Definition: machine_state.h:82
MachineState(T state) noexcept
Constructor.
Definition: machine_state.h:70
void Register(AbstractStateMachine< T > *finiteStateMachine) noexcept
Register the state to a finite state machine (FSM)
Definition: machine_state.h:93
void Transit(T nextState)
Transit to the next state.
Definition: machine_state.h:59
virtual void Activate(T previousState)=0
Activate the state.
SdClientState
Service discovery client machine state.
Definition: machine_state.h:24
@ ServiceNotSeen
Service is not requested and not seen.
@ ServiceSeen
Service is not requsted, but seen.
@ RepetitionPhase
Client service is in repetition phase.
@ Stopped
Service is stopped.
@ ServiceReady
Service is ready.
@ InitialWaitPhase
Client service is in initial waiting phase.
SdServerState
Service discovery server machine state.
Definition: machine_state.h:15
@ RepetitionPhase
Server's service is in repetition phase.
@ MainPhase
Server's service is in main phase.
@ NotReady
Server's service is down.
@ InitialWaitPhase
Server's service is in initial waiting phase.
PubSubState
Publish-subscribe server machine state.
Definition: machine_state.h:35
@ NotSubscribed
Service server is up, but there is no subscriber.
@ Subscribed
Service server is up, and there is at least a subscriber.
@ ServiceDown
Service server is down.