#ifndef LOOPER_HH #define LOOPER_HH #include #include #include namespace logger { class Logger; } // namespace logger namespace looper { constexpr static uint8_t EVENT_READ = 1; constexpr static uint8_t EVENT_WRITE = 2; constexpr static uint8_t EVENT_ERROR = 4; class Looper { public: virtual ~Looper() = default; virtual void add(int fd, uint8_t events, std::function callback) = 0; virtual void update(int fd, uint8_t events) = 0; virtual void remove(int fd) = 0; // Returned id is never 0 virtual uint32_t schedule(double delay, std::function callback) = 0; virtual void cancel(uint32_t id) = 0; virtual bool run(logger::Logger& logger) = 0; virtual void quit() = 0; protected: Looper() = default; Looper(Looper const&) = delete; Looper& operator=(Looper const&) = delete; }; [[nodiscard]] std::unique_ptr create(); } // namespace looper #endif // LOOPER_HH