mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Clean db interface
This commit is contained in:
parent
1d78e106ad
commit
1c2d2a14ac
3 changed files with 12 additions and 12 deletions
|
@ -7,9 +7,9 @@ class GameBase {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual std::shared_ptr<Game> GetGame(std::uint32_t id) = 0;
|
virtual std::shared_ptr<Game> GetGame(std::uint32_t id) = 0;
|
||||||
virtual void Save(std::vector<std::uint32_t> to_ignore,
|
virtual void Save(std::vector<std::uint32_t> to_delete,
|
||||||
std::vector<std::shared_ptr<GameBase>> new_games_bases,
|
std::vector<std::shared_ptr<GameBase>> databases_to_import,
|
||||||
std::vector<std::shared_ptr<Game>> new_games) = 0;
|
std::vector<std::shared_ptr<Game>> games_to_import) = 0;
|
||||||
virtual std::shared_ptr<Game> GetCurrentGame() = 0;
|
virtual std::shared_ptr<Game> GetCurrentGame() = 0;
|
||||||
virtual bool NextGame() = 0;
|
virtual bool NextGame() = 0;
|
||||||
virtual std::string GetTag(std::string tag) = 0;
|
virtual std::string GetTag(std::string tag) = 0;
|
||||||
|
|
|
@ -63,9 +63,9 @@ std::shared_ptr<Game> PGNGameBase::GetGame(std::uint32_t id) {
|
||||||
return (std::shared_ptr<Game>(NULL));
|
return (std::shared_ptr<Game>(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PGNGameBase::Save(std::vector<std::uint32_t> to_ignore,
|
void PGNGameBase::Save(std::vector<std::uint32_t> to_delete,
|
||||||
std::vector<std::shared_ptr<GameBase>> new_games_bases,
|
std::vector<std::shared_ptr<GameBase>> databases_to_import,
|
||||||
std::vector<std::shared_ptr<Game>> new_games) {
|
std::vector<std::shared_ptr<Game>> games_to_import) {
|
||||||
wxStandardPaths stdPaths = wxStandardPaths::Get();
|
wxStandardPaths stdPaths = wxStandardPaths::Get();
|
||||||
wxString tmp = stdPaths.GetTempDir() + "/save_pgn_tmp.pgn";
|
wxString tmp = stdPaths.GetTempDir() + "/save_pgn_tmp.pgn";
|
||||||
wxFile new_pgn(tmp, wxFile::write);
|
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;
|
std::uint32_t id = 0;
|
||||||
bool several = false;
|
bool several = false;
|
||||||
while (NextGame()) {
|
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) {
|
if (several) {
|
||||||
new_pgn.Write("\n\n");
|
new_pgn.Write("\n\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,7 +87,7 @@ void PGNGameBase::Save(std::vector<std::uint32_t> to_ignore,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now add new games
|
// Now add new games
|
||||||
for (std::shared_ptr<GameBase> current : new_games_bases) {
|
for (std::shared_ptr<GameBase> current : databases_to_import) {
|
||||||
current->Reset();
|
current->Reset();
|
||||||
while (current->NextGame()) {
|
while (current->NextGame()) {
|
||||||
if (several) {
|
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) {
|
if (several) {
|
||||||
new_pgn.Write("\n\n");
|
new_pgn.Write("\n\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,9 +13,9 @@ public:
|
||||||
bool NextGame();
|
bool NextGame();
|
||||||
std::shared_ptr<Game> GetCurrentGame();
|
std::shared_ptr<Game> GetCurrentGame();
|
||||||
std::string GetTag(std::string tag);
|
std::string GetTag(std::string tag);
|
||||||
void Save(std::vector<std::uint32_t> to_ignore,
|
void Save(std::vector<std::uint32_t> to_delete,
|
||||||
std::vector<std::shared_ptr<GameBase>> new_games_bases,
|
std::vector<std::shared_ptr<GameBase>> databases_to_import,
|
||||||
std::vector<std::shared_ptr<Game>> new_games);
|
std::vector<std::shared_ptr<Game>> games_to_import);
|
||||||
void Reset();
|
void Reset();
|
||||||
void Export(std::shared_ptr<GameBase> base);
|
void Export(std::shared_ptr<GameBase> base);
|
||||||
std::string GetFormat() {return("PGN");};
|
std::string GetFormat() {return("PGN");};
|
||||||
|
|
Loading…
Add table
Reference in a new issue