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