]> git.sesse.net Git - nageru/blob - db.h
Remove frame files that do not exist from the database.
[nageru] / db.h
1 #ifndef DB_H
2 #define DB_H 1
3
4 #include "state.pb.h"
5
6 #include <sqlite3.h>
7 #include <string>
8 #include <vector>
9
10 #include "frame_on_disk.h"
11
12 class DB {
13 public:
14         explicit DB(const std::string &filename);
15         DB(const DB &) = delete;
16
17         StateProto get_state();
18         void store_state(const StateProto &state);
19
20         struct FrameOnDiskAndStreamIdx {
21                 FrameOnDisk frame;
22                 unsigned stream_idx;
23         };
24         std::vector<FrameOnDiskAndStreamIdx> load_frame_file(const std::string &filename, size_t size, unsigned frame_idx);  // Empty = none found, or there were no frames.
25         void store_frame_file(const std::string &filename, size_t size, const std::vector<FrameOnDiskAndStreamIdx> &frames);
26         void clean_unused_frame_files(const std::vector<std::string> &used_filenames);
27
28 private:
29         StateProto state;
30         sqlite3 *db;
31 };
32
33 #endif  // !defined(DB_H)