blob: b2c148885bb67f487cbca67bb48d4af1a4880226 (
plain)
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
42
43
44
45
46
47
48
49
50
51
|
#pragma once
#include "game_tab/Game.hpp"
#include <algorithm>
#include <vector>
/**
* @brief Represent the interface that each database type (such as PGNGameBase) must follow
* to be accessible in OChess.
*/
class GameBase {
public:
virtual std::shared_ptr<Game> GetGame(std::uint32_t id) = 0;
virtual void Save(std::vector<std::uint32_t> to_delete,
std::vector<std::string> databases_to_import,
std::vector<std::shared_ptr<Game>> games_to_import) = 0;
virtual std::shared_ptr<Game> GetCurrentGame() = 0;
virtual bool NextGame() = 0;
virtual std::string GetTag(std::string tag) = 0;
virtual void Reset() = 0;
virtual std::string GetFormat() = 0;
virtual std::string GetFilePath() = 0;
/**
* @brief Save the given base into current base format (export)
*
* @param base
*/
virtual void Export(std::shared_ptr<GameBase> base) = 0;
/**
* @brief An additionnal static method is expected with the following signature:
* static void CreateDatabaseFile(std::string path);
*/
};
/**
* @brief Open a data
*
* @param dbpath
* @return std::shared_ptr<GameBase>
*/
std::shared_ptr<GameBase> OpenDatabase(const std::string &dbpath, bool createIfNotExist=true);
/**
* @brief Single game open
*
* @param dbpath
* @param id
* @return std::shared_ptr<Game>
*/
std::shared_ptr<Game> OpenGameX(const std::string &dbpath, long id);
void SaveGame(const std::string &dbpath, std::shared_ptr<Game> g);
|