]> git.sesse.net Git - nageru/blobdiff - futatabi/db.h
Move everything into a separate futatabi/ subdir, for the upcoming merge with Nageru.
[nageru] / futatabi / db.h
diff --git a/futatabi/db.h b/futatabi/db.h
new file mode 100644 (file)
index 0000000..f8032c0
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef DB_H
+#define DB_H 1
+
+#include "state.pb.h"
+
+#include <sqlite3.h>
+#include <string>
+#include <vector>
+
+#include "frame_on_disk.h"
+
+class DB {
+public:
+       explicit DB(const std::string &filename);
+       DB(const DB &) = delete;
+
+       StateProto get_state();
+       void store_state(const StateProto &state);
+
+       struct FrameOnDiskAndStreamIdx {
+               FrameOnDisk frame;
+               unsigned stream_idx;
+       };
+       std::vector<FrameOnDiskAndStreamIdx> load_frame_file(const std::string &filename, size_t size, unsigned frame_idx);  // Empty = none found, or there were no frames.
+       void store_frame_file(const std::string &filename, size_t size, const std::vector<FrameOnDiskAndStreamIdx> &frames);
+       void clean_unused_frame_files(const std::vector<std::string> &used_filenames);
+
+private:
+       StateProto state;
+       sqlite3 *db;
+};
+
+#endif  // !defined(DB_H)