summaryrefslogtreecommitdiff
path: root/src/file_opener.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
commit6232d13f5321b87ddf12a1aa36b4545da45f173d (patch)
tree23f3316470a14136debd9d02f9e920ca2b06f4cc /src/file_opener.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/file_opener.hh')
-rw-r--r--src/file_opener.hh33
1 files changed, 33 insertions, 0 deletions
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 <filesystem>
+#include <functional>
+#include <memory>
+
+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<FileOpener> create(std::shared_ptr<TaskRunner> runner,
+ size_t threads = 1);
+
+ // Never returns 0.
+ virtual uint32_t open(std::filesystem::path path,
+ std::function<void(uint32_t, unique_fd)> 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