]> git.sesse.net Git - nageru/blob - futatabi/db.h
Persist quality settings in the database.
[nageru] / futatabi / 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         SettingsProto get_settings();
21         void store_settings(const SettingsProto &settings);
22
23         struct FrameOnDiskAndStreamIdx {
24                 FrameOnDisk frame;
25                 unsigned stream_idx;
26         };
27         std::vector<FrameOnDiskAndStreamIdx> load_frame_file(const std::string &filename, size_t size, unsigned frame_idx);  // Empty = none found, or there were no frames.
28         void store_frame_file(const std::string &filename, size_t size, const std::vector<FrameOnDiskAndStreamIdx> &frames);
29         void clean_unused_frame_files(const std::vector<std::string> &used_filenames);
30
31 private:
32         StateProto state;
33         sqlite3 *db;
34 };
35
36 #endif  // !defined(DB_H)