// -*- mode: c++; c-basic-offset: 2; -*- #ifndef LOOPER_HH #define LOOPER_HH #include #include class Looper { public: typedef std::chrono::steady_clock clock; typedef std::function FdCallback; typedef std::function ScheduleCallback; virtual ~Looper() { } static const uint8_t EVENT_READ; static const uint8_t EVENT_WRITE; // Always reported, need not be set static const uint8_t EVENT_HUP; static const uint8_t EVENT_ERROR; static Looper* create(); virtual void add(int fd, uint8_t events, FdCallback const& callback) = 0; virtual void modify(int fd, uint8_t events) = 0; virtual void remove(int fd) = 0; virtual void* schedule(float delay_s, ScheduleCallback const& callback) = 0; virtual void cancel(void* handle) = 0; virtual bool run() = 0; virtual void quit() = 0; virtual clock::time_point now() const = 0; protected: Looper() { } Looper(Looper const&) = delete; }; #endif // LOOPER_HH