Simplify Book APIs

Retire open(), close() and name() from public visibility
and greately simplify the code. It is amazing how much
can be squeezed out of an already mature code !

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2011-12-31 17:52:14 +01:00
parent c00443b19e
commit 8300ab149c
4 changed files with 100 additions and 147 deletions

View File

@@ -37,25 +37,22 @@ struct BookEntry {
uint32_t learn;
};
class Book {
class Book : private std::ifstream {
public:
Book();
~Book();
void open(const std::string& fileName);
void close();
Move probe(const Position& pos, bool findBestMove);
const std::string name() const { return bookName; }
Move probe(const Position& pos, const std::string& fName, bool pickBest);
private:
template<typename T> Book& operator>>(T& n);
BookEntry read_entry(int idx);
int first_entry(uint64_t key);
bool open(const char* fName);
void binary_search(uint64_t key);
RKISS RKiss;
std::ifstream bookFile;
std::string bookName;
int bookSize;
std::string fileName;
size_t size;
};
#endif // !defined(BOOK_H_INCLUDED)