#ifndef SOPHIAR2_TRISTATE_OBJ_H #define SOPHIAR2_TRISTATE_OBJ_H #include "core/global_io_context.hpp" #include #include #include #include namespace sophiar { template class tristate_obj : public use_context, private boost::noncopyable { public: enum class state_type { INITIAL, INITIALIZING, RESETTING, PENDING, STARTING, STOPPING, RUNNING, }; tristate_obj(); virtual ~tristate_obj(); boost::asio::awaitable init(); boost::asio::awaitable start(); boost::asio::awaitable stop(); boost::asio::awaitable reset(); state_type get_state() const; protected: virtual boost::asio::awaitable on_init() { co_return true; } // TODO add no_throw virtual boost::asio::awaitable on_start() { co_return true; } virtual boost::asio::awaitable on_stop() { co_return; } virtual boost::asio::awaitable on_reset() { co_return; } private: struct impl; std::unique_ptr pimpl; }; } #endif //SOPHIAR2_TRISTATE_OBJ_H