1 /**************************************************************************** 2 * Copyright (C) 2017 by Jens Nissen jens-chessx@gmx.net * 3 ****************************************************************************/ 4 5 #ifndef ARENABOOK_H 6 #define ARENABOOK_H 7 8 #include "board.h" 9 #include "database.h" 10 #include "gamex.h" 11 #include "movedata.h" 12 13 struct ABK_MOVE; 14 15 class ArenaBook : public Database 16 { 17 Q_OBJECT 18 public: 19 ArenaBook(); 20 ~ArenaBook(); 21 22 /** Opens the given database */ 23 virtual bool open(const QString& filename, bool); 24 /** Parse the database */ 25 virtual bool parseFile(); 26 /** File-based database name */ 27 virtual QString filename() const; 28 29 /** Get the number of stored games*/ 30 virtual quint64 count() const; 31 /** Get the number of stored positions*/ 32 quint64 positionCount() const; 33 34 /** Loads a game at @p index, returns true if successful */ 35 virtual bool loadGame(GameId gameId, GameX& game); 36 /** Loads only moves into a game from the given position */ 37 virtual void loadGameMoves(GameId id, GameX& game); 38 /** Loads game moves and try to find a position */ 39 virtual int findPosition(GameId, const BoardX &position); 40 hasIndexFile()41 virtual bool hasIndexFile() const { return true; } 42 /** Open a book data File */ 43 bool openFile(const QString& filename, bool readOnly=false); 44 /** Closes the database */ 45 void close(); 46 47 private: // BOOK Parser 48 QString m_filename; 49 QIODevice* m_file; 50 quint64 m_posCount; 51 quint64 m_count; 52 void add_move(GameX *game, const ABK_MOVE* move); 53 void tag_game(GameX* game, int ply, GameId index); 54 55 private: // Game list 56 QVector<GameX*> m_games; 57 }; 58 59 #endif // ARENABOOK_H 60