diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
| commit | 6232d13f5321b87ddf12a1aa36b4545da45f173d (patch) | |
| tree | 23f3316470a14136debd9d02f9e920ca2b06f4cc /src/looper.hh | |
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in
memroy.
Diffstat (limited to 'src/looper.hh')
| -rw-r--r-- | src/looper.hh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/looper.hh b/src/looper.hh new file mode 100644 index 0000000..3286cb1 --- /dev/null +++ b/src/looper.hh @@ -0,0 +1,38 @@ +#ifndef LOOPER_HH +#define LOOPER_HH + +#include <functional> +#include <memory> + +class Logger; + +class Looper { +public: + constexpr static uint8_t EVENT_READ = 1; + constexpr static uint8_t EVENT_WRITE = 2; + constexpr static uint8_t EVENT_ERROR = 4; + + virtual ~Looper() = default; + + static std::unique_ptr<Looper> create(); + + virtual void add(int fd, uint8_t events, + std::function<void(uint8_t)> 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<void(uint32_t)> callback) = 0; + virtual void cancel(uint32_t id) = 0; + + virtual bool run(Logger* logger) = 0; + virtual void quit() = 0; + +protected: + Looper() = default; + Looper(Looper const&) = delete; + Looper& operator=(Looper const&) = delete; +}; + +#endif // LOOPER_HH |
