aboutsummaryrefslogtreecommitdiff
path: root/mapman/src/library.hpp
blob: 82babe0ecd4dbb303164537f96bdcee84d7f2415 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef LIBRARY_HPP
#define LIBRARY_HPP

#include "mapdump.hpp"

#include <filesystem>
#include <string>
#include <vector>

struct sqlite3;

class map_library
{
public:
    map_library();
    ~map_library();

    std::vector<int> map_ids() const;
    bool has_map(int id) const;
    void set_map(const map_t &map);
    map_t get_map(int id) const;

    std::vector<int64_t> groups() const;
    int64_t new_group(const map_group_t &g);
    bool has_group(int64_t gid) const;
    void set_group(int64_t gid, const map_group_t &g);
    map_group_t get_group(int64_t gid);
    void remove_group(int64_t gid) const;

    void tally_diff(const std::vector<int> &tally,
                          std::vector<int> &a_b,
                          std::vector<int> &b_a) const;

    bool open_db(const std::filesystem::path &p);
private:
    void init_db();
    bool verify_db();
    sqlite3 *db;
};

#endif