44template<
typename state_t>
81template<
typename state_t>
91 void ensure(std::initializer_list<state_type> expected)
93 for (
const auto& e : expected)
97 std::string states_str;
99 for (
const auto& e : expected)
100 if (e != *expected.end())
101 states_str += std::format(
"{},", e);
103 states_str += std::format(
"{}", e);
105 throw std::runtime_error(
106 std::format(
"Wrong State {} [must be in \"{}\"]", state_m,
107 std::string_view{states_str.begin(), states_str.end() - 1}));
113 throw std::runtime_error(
114 std::format(
"Wrong State \"{}\" [must be \"{}\"]", state_m, s));
120 throw std::runtime_error(
"Another transition in progress!");
131 throw std::runtime_error(
"Rollback while no transition!");
142 throw std::runtime_error(
"Commit while no transition!");
177 state_type::INITIALIZING, state_m);
179 state_m = state_type::INITIALIZING;
184 std::optional<state_type> next_m;
void debug(spdlog::source_loc loc, pars::lf lf, spdlog::format_string_t< args_t... > fmt, args_t &&... args)
void ensure(std::initializer_list< state_type > expected)
state_type current() const
state_tx< state_type > tx(state_type from_state, state_type to_state)
state_tx< state_type > tx(std::initializer_list< state_type > from_states, state_type to_state)
void ensure(state_type s)
state_tx< state_type > tx(state_type to_state)
state_machine(state_type s)
state_tx(state_machine< state_type > &sm, state_type to_state)