-}
-
-
-////
-//// Classes
-////
-
-/// EndgameFunctions class stores endgame evaluation and scaling functions
-/// in two std::map. Because STL library is not guaranteed to be thread
-/// safe even for read access, the maps, although with identical content,
-/// are replicated for each thread. This is faster then using locks.
-
-class EndgameFunctions {
-public:
- EndgameFunctions();
- ~EndgameFunctions();
- template<class T> T* get(Key key) const;
-
-private:
- template<class T> void add(const string& keyCode);
-
- static Key buildKey(const string& keyCode);
- static const string swapColors(const string& keyCode);
-
- // Here we store two maps, for evaluate and scaling functions
- pair<map<Key, EF*>, map<Key, SF*> > maps;
-
- // Maps accessing functions returning const and non-const references
- template<typename T> const map<Key, T*>& get() const { return maps.first; }
- template<typename T> map<Key, T*>& get() { return maps.first; }
-};
-
-// Explicit specializations of a member function shall be declared in
-// the namespace of which the class template is a member.
-template<> const map<Key, SF*>&
-EndgameFunctions::get<SF>() const { return maps.second; }
-
-template<> map<Key, SF*>&
-EndgameFunctions::get<SF>() { return maps.second; }
-
-
-////
-//// Functions
-////
-
-/// MaterialInfoTable c'tor and d'tor, called once by each thread
-
-MaterialInfoTable::MaterialInfoTable(unsigned int numOfEntries) {
-
- size = numOfEntries;
- entries = new MaterialInfo[size];
- funcs = new EndgameFunctions();
-
- if (!entries || !funcs)
- {
- cerr << "Failed to allocate " << numOfEntries * sizeof(MaterialInfo)
- << " bytes for material hash table." << endl;
- Application::exit_with_failure();
- }
-}
-
-MaterialInfoTable::~MaterialInfoTable() {