19 #ifndef FF_UTIL_FF_FSM_H_
20 #define FF_UTIL_FF_FSM_H_
41 state_(initial_state), callback_(callback) {}
47 for (
size_t i = 0; i < 8 *
sizeof(
Event); i++) {
48 if (
mask & (1 << i)) {
49 fsm_[std::make_pair(s1, 1 << i)] = callback;
58 for (
size_t i = 0; i < 8 *
sizeof(
Event); i++) {
59 if (
mask & (1 << i)) {
60 fsm_[std::make_pair(s1, 1 << i)] = callback;
61 fsm_[std::make_pair(s2, 1 << i)] = callback;
70 for (
size_t i = 0; i < 8 *
sizeof(
Event); i++) {
71 if (
mask & (1 << i)) {
72 fsm_[std::make_pair(s1, 1 << i)] = callback;
73 fsm_[std::make_pair(s2, 1 << i)] = callback;
74 fsm_[std::make_pair(s3, 1 << i)] = callback;
81 for (
size_t i = 0; i < 8 *
sizeof(
Event); i++)
82 if (
mask & (1 << i)) catchall_[1 << i] = callback;
98 if (catchall_.find(event) != catchall_.end()) {
99 state_ = catchall_[event](state_, event);
101 callback_(state_, event);
105 std::pair<State, Event> key = std::make_pair(state_, event);
106 if (fsm_.find(key) != fsm_.end()) {
107 state_ = fsm_[key](event);
109 callback_(state_, event);
117 std::map<Event, CatchallCallback> catchall_;
123 #endif // FF_UTIL_FF_FSM_H_