From 6232d13f5321b87ddf12a1aa36b4545da45f173d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 17 Nov 2021 22:34:57 +0100 Subject: Travel3: Simple image and video display site Reads the images and videos from filesystem and builds a site in memroy. --- src/file_opener.hh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/file_opener.hh (limited to 'src/file_opener.hh') diff --git a/src/file_opener.hh b/src/file_opener.hh new file mode 100644 index 0000000..7b01b9f --- /dev/null +++ b/src/file_opener.hh @@ -0,0 +1,33 @@ +#ifndef FILE_OPENER_HH +#define FILE_OPENER_HH + +#include "unique_fd.hh" + +#include +#include +#include + +class TaskRunner; + +class FileOpener { +public: + virtual ~FileOpener() = default; + + // All callbacks are posted to runner. open() and cancel() must be called + // on same thread as runner "runs" on. + static std::unique_ptr create(std::shared_ptr runner, + size_t threads = 1); + + // Never returns 0. + virtual uint32_t open(std::filesystem::path path, + std::function callback) = 0; + + virtual void cancel(uint32_t id) = 0; + +protected: + FileOpener() = default; + FileOpener(FileOpener const&) = delete; + FileOpener& operator=(FileOpener const&) = delete; +}; + +#endif // FILE_OPENER_HH -- cgit v1.2.3-70-g09d2