9 #ifndef FAIRMQSTATEMACHINE_H_
10 #define FAIRMQSTATEMACHINE_H_
12 #include <fairmq/States.h>
26 virtual ~StateMachine();
28 bool ChangeState(
const Transition transition);
29 bool ChangeState(
const std::string& transition) {
return ChangeState(GetTransition(transition)); }
31 void SubscribeToStateChange(
const std::string& key, std::function<
void(
const State)> callback);
32 void UnsubscribeFromStateChange(
const std::string& key);
34 void HandleStates(std::function<
void(
const State)> callback);
35 void StopHandlingStates();
37 void SubscribeToNewTransition(
const std::string& key, std::function<
void(
const Transition)> callback);
38 void UnsubscribeFromNewTransition(
const std::string& key);
40 bool NewStatePending()
const;
41 void WaitForPendingState()
const;
42 bool WaitForPendingStateFor(
const int durationInMs)
const;
44 State GetCurrentState()
const;
45 std::string GetCurrentStateName()
const;
51 struct ErrorStateException : std::runtime_error {
using std::runtime_error::runtime_error; };
54 std::shared_ptr<void> fFsm;