Clean db interface

This commit is contained in:
Loic Guegan 2022-12-26 13:39:33 +01:00
parent 1d78e106ad
commit 1c2d2a14ac
3 changed files with 12 additions and 12 deletions

View file

@ -7,9 +7,9 @@ class GameBase {
public:
virtual std::shared_ptr<Game> GetGame(std::uint32_t id) = 0;
virtual void Save(std::vector<std::uint32_t> to_ignore,
std::vector<std::shared_ptr<GameBase>> new_games_bases,
std::vector<std::shared_ptr<Game>> new_games) = 0;
virtual void Save(std::vector<std::uint32_t> to_delete,
std::vector<std::shared_ptr<GameBase>> 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;

View file

@ -63,9 +63,9 @@ std::shared_ptr<Game> PGNGameBase::GetGame(std::uint32_t id) {
return (std::shared_ptr<Game>(NULL));
}
void PGNGameBase::Save(std::vector<std::uint32_t> to_ignore,
std::vector<std::shared_ptr<GameBase>> new_games_bases,
std::vector<std::shared_ptr<Game>> new_games) {
void PGNGameBase::Save(std::vector<std::uint32_t> to_delete,
std::vector<std::shared_ptr<GameBase>> databases_to_import,
std::vector<std::shared_ptr<Game>> games_to_import) {
wxStandardPaths stdPaths = wxStandardPaths::Get();
wxString tmp = stdPaths.GetTempDir() + "/save_pgn_tmp.pgn";
wxFile new_pgn(tmp, wxFile::write);
@ -74,7 +74,7 @@ void PGNGameBase::Save(std::vector<std::uint32_t> to_ignore,
std::uint32_t id = 0;
bool several = false;
while (NextGame()) {
if (std::find(to_ignore.begin(), to_ignore.end(), id) == to_ignore.end()) {
if (std::find(to_delete.begin(), to_delete.end(), id) == to_delete.end()) {
if (several) {
new_pgn.Write("\n\n");
} else {
@ -87,7 +87,7 @@ void PGNGameBase::Save(std::vector<std::uint32_t> to_ignore,
}
// Now add new games
for (std::shared_ptr<GameBase> current : new_games_bases) {
for (std::shared_ptr<GameBase> current : databases_to_import) {
current->Reset();
while (current->NextGame()) {
if (several) {
@ -100,7 +100,7 @@ void PGNGameBase::Save(std::vector<std::uint32_t> to_ignore,
}
}
for (std::shared_ptr<Game> g : new_games) {
for (std::shared_ptr<Game> g : games_to_import) {
if (several) {
new_pgn.Write("\n\n");
} else {

View file

@ -13,9 +13,9 @@ public:
bool NextGame();
std::shared_ptr<Game> GetCurrentGame();
std::string GetTag(std::string tag);
void Save(std::vector<std::uint32_t> to_ignore,
std::vector<std::shared_ptr<GameBase>> new_games_bases,
std::vector<std::shared_ptr<Game>> new_games);
void Save(std::vector<std::uint32_t> to_delete,
std::vector<std::shared_ptr<GameBase>> databases_to_import,
std::vector<std::shared_ptr<Game>> games_to_import);
void Reset();
void Export(std::shared_ptr<GameBase> base);
std::string GetFormat() {return("PGN");};