Scid
4.7.0
|
#include <scidbase.h>
Classes | |
struct | Stats |
struct | TreeStat |
Public Member Functions | |
scidBaseT () | |
~scidBaseT () | |
errorT | Open (ICodecDatabase::Codec dbtype, fileModeT mode, const char *filename=0, const Progress &progress=Progress()) |
errorT | Close () |
const std::string & | getFileName () const |
bool | isReadOnly () const |
gamenumT | numGames () const |
std::vector< std::pair< const char *, std::string > > | getExtraInfo () const |
Returns a vector of tag pairs containing extra information about the database (type, description, autoload, etc..) More... | |
errorT | setExtraInfo (const char *tagname, const char *new_value) |
Store an extra information about the database (type, description, etc..) More... | |
const IndexEntry * | getIndexEntry (gamenumT g) const |
const IndexEntry * | getIndexEntry_bounds (gamenumT g) const |
const NameBase * | getNameBase () const |
FastGame | getGame (const IndexEntry *ie) const |
errorT | getGame (const IndexEntry *ie, ByteBuffer *destBuf) const |
errorT | getGame (const IndexEntry &ie, Game &dest) const |
errorT | importGame (const scidBaseT *srcBase, uint gNum) |
errorT | importGames (const scidBaseT *srcBase, const HFilter &filter, const Progress &progress) |
errorT | importGames (ICodecDatabase::Codec dbtype, const char *filename, const Progress &progress, std::string &errorMsg) |
errorT | saveGame (Game *game, gamenumT replacedGameId=INVALID_GAMEID) |
Add or replace a game into the database. More... | |
errorT | saveGameHelper (Game *game, gamenumT gameId) |
bool | getFlag (uint flag, uint gNum) const |
errorT | setFlag (bool value, uint flag, uint gNum) |
errorT | setFlag (bool value, uint flag, const HFilter &filter) |
errorT | invertFlag (uint flag, uint gNum) |
errorT | invertFlag (uint flag, const HFilter &filter) |
std::string | newFilter () |
A Filter is a selection of games, usually obtained searching the database. More... | |
std::string | composeFilter (const std::string &mainFilter, const std::string &maskFilter) const |
void | deleteFilter (const char *filterId) |
HFilter | getFilter (const std::string &filterId) const |
HFilter | getMainFilter (const std::string &filterId) const |
const Stats & | getStats () const |
Statistics. More... | |
std::vector< scidBaseT::TreeStat > | getTreeStat (const HFilter &filter) |
uint | getNameFreq (nameT nt, idNumberT id) |
errorT | getCompactStat (unsigned long long *n_deleted, unsigned long long *n_unused, unsigned long long *n_sparse, unsigned long long *n_badNameId) |
errorT | compact (const Progress &progress) |
SortCache * | createSortCache (const char *criteria) |
Increment the reference count of a SortCache object matching criteria. More... | |
void | releaseSortCache (const char *criteria) |
Decrement the reference count of the SortCache object matching criteria. More... | |
size_t | listGames (const char *criteria, size_t start, size_t count, const HFilter &filter, gamenumT *destCont) |
Retrieve a list of ordered game indexes sorted by criteria. More... | |
size_t | sortedPosition (const char *criteria, const HFilter &filter, gamenumT gameId) |
Get the sorted position of a game. More... | |
void | setDuplicates (uint *duplicates) |
uint | getDuplicates (gamenumT gNum) |
template<typename TOper > | |
std::pair< errorT, size_t > | transformIndex (HFilter hfilter, const Progress &progress, TOper entry_op) |
Transform the IndexEntries of the games included in hfilter. More... | |
template<typename TInitFunc , typename TMapFunc > | |
std::pair< errorT, size_t > | transformNames (nameT nt, HFilter hfilter, const Progress &progress, const std::vector< std::string > &newNames, TInitFunc fnInit, TMapFunc getID) |
Transform the names of the games included in hfilter. More... | |
void | beginTransaction () |
This function must be called before modifying the games of the database. More... | |
errorT | endTransaction (gamenumT gameId=INVALID_GAMEID) |
Update caches and flush the database's files. More... | |
Public Attributes | |
Index * | idx |
bool | inUse |
treeT | tree |
TreeCache | treeCache |
ByteBuffer * | bbuf |
Filter * | dbFilter |
Filter * | treeFilter |
Game * | game |
int | gameNumber |
bool | gameAltered |
UndoRedo< Game, 100 > | gameAlterations |
std::pair< Game *, bool > | deprecated_push_pop |
Definition at line 39 of file scidbase.h.
scidBaseT::scidBaseT | ( | ) |
Definition at line 54 of file scidbase.cpp.
scidBaseT::~scidBaseT | ( | ) |
Definition at line 70 of file scidbase.cpp.
void scidBaseT::beginTransaction | ( | ) |
This function must be called before modifying the games of the database.
Currently this function do not guarantees that the database is not altered in case of errors.
Definition at line 151 of file scidbase.cpp.
errorT scidBaseT::Close | ( | ) |
Definition at line 114 of file scidbase.cpp.
Definition at line 527 of file scidbase.cpp.
std::string scidBaseT::composeFilter | ( | const std::string & | mainFilter, |
const std::string & | maskFilter | ||
) | const |
Definition at line 275 of file scidbase.cpp.
SortCache * scidBaseT::createSortCache | ( | const char * | criteria | ) |
Increment the reference count of a SortCache object matching criteria.
criteria | the list of fields by which games will be ordered. Each field should be followed by '+' to indicate an ascending order or by '-' for a descending order. |
Definition at line 699 of file scidbase.cpp.
void scidBaseT::deleteFilter | ( | const char * | filterId | ) |
Definition at line 296 of file scidbase.cpp.
errorT scidBaseT::endTransaction | ( | gamenumT | gameId = INVALID_GAMEID | ) |
Update caches and flush the database's files.
This function must be called after changing one or more games.
gameId | id of the modified game INVALID_GAMEID to update all games. |
Definition at line 157 of file scidbase.cpp.
errorT scidBaseT::getCompactStat | ( | unsigned long long * | n_deleted, |
unsigned long long * | n_unused, | ||
unsigned long long * | n_sparse, | ||
unsigned long long * | n_badNameId | ||
) |
Definition at line 491 of file scidbase.cpp.
Definition at line 281 of file scidbase.h.
|
inline |
Returns a vector of tag pairs containing extra information about the database (type, description, autoload, etc..)
Definition at line 103 of file scidbase.h.
|
inline |
Definition at line 97 of file scidbase.h.
|
inline |
Definition at line 200 of file scidbase.h.
Definition at line 180 of file scidbase.h.
|
inline |
Definition at line 141 of file scidbase.h.
|
inline |
Definition at line 147 of file scidbase.h.
|
inline |
Definition at line 156 of file scidbase.h.
|
inline |
Definition at line 131 of file scidbase.h.
|
inline |
Definition at line 134 of file scidbase.h.
|
inline |
Definition at line 203 of file scidbase.h.
|
inline |
Definition at line 138 of file scidbase.h.
Definition at line 209 of file scidbase.h.
const scidBaseT::Stats & scidBaseT::getStats | ( | ) | const |
Statistics.
Definition at line 336 of file scidbase.cpp.
std::vector< scidBaseT::TreeStat > scidBaseT::getTreeStat | ( | const HFilter & | filter | ) |
Definition at line 458 of file scidbase.cpp.
Definition at line 194 of file scidbase.cpp.
errorT scidBaseT::importGames | ( | const scidBaseT * | srcBase, |
const HFilter & | filter, | ||
const Progress & | progress | ||
) |
Definition at line 205 of file scidbase.cpp.
errorT scidBaseT::importGames | ( | ICodecDatabase::Codec | dbtype, |
const char * | filename, | ||
const Progress & | progress, | ||
std::string & | errorMsg | ||
) |
Definition at line 237 of file scidbase.cpp.
Definition at line 433 of file scidbase.h.
Definition at line 437 of file scidbase.h.
|
inline |
Definition at line 98 of file scidbase.h.
size_t scidBaseT::listGames | ( | const char * | criteria, |
size_t | start, | ||
size_t | count, | ||
const HFilter & | filter, | ||
gamenumT * | destCont | ||
) |
Retrieve a list of ordered game indexes sorted by criteria.
This function will be much faster if a SortCache object matching criteria already exists (previously created with createSortCache).
criteria | the list of fields by which games will be ordered. Each field should be followed by '+' to indicate an ascending order or by '-' for a descending order. | |
start | the offset of the first row to return. The offset of the initial row is 0. | |
count | maximum number of rows to return. | |
filter | a reference to a valid (!= NULL) HFilter object. Games not included into the filter will be ignored. | |
[out] | destCont | valid pointer to an array where the sorted list of games will be stored (should be able to contain at least count elements). |
Definition at line 707 of file scidbase.cpp.
std::string scidBaseT::newFilter | ( | ) |
A Filter is a selection of games, usually obtained searching the database.
Filters.
A new Filter is created calling the function newFilter() and must be released calling the function deleteFilter(). A composed Filter is a special construct created combining two Filters and includes only the games contained in both Filters. A composed Filter should NOT be released.
Definition at line 262 of file scidbase.cpp.
|
inline |
Definition at line 99 of file scidbase.h.
errorT scidBaseT::Open | ( | ICodecDatabase::Codec | dbtype, |
fileModeT | mode, | ||
const char * | filename = 0 , |
||
const Progress & | progress = Progress() |
||
) |
Definition at line 84 of file scidbase.cpp.
void scidBaseT::releaseSortCache | ( | const char * | criteria | ) |
Decrement the reference count of the SortCache object matching criteria.
Cached objects with refCount <= 0 are destroyed independently from the value of criteria.
criteria | the list of fields by which games will be ordered. Each field should be followed by '+' to indicate an ascending order or by '-' for a descending order. |
Definition at line 685 of file scidbase.cpp.
errorT scidBaseT::saveGame | ( | Game * | game, |
gamenumT | replacedGameId = INVALID_GAMEID |
||
) |
Add or replace a game into the database.
game | valid pointer to a Game object with the data of the game. |
replacedGameId | id of the game to replace. If >= numGames(), a new game will be added. |
Definition at line 177 of file scidbase.cpp.
Definition at line 184 of file scidbase.cpp.
|
inline |
Definition at line 277 of file scidbase.h.
|
inline |
Store an extra information about the database (type, description, etc..)
Definition at line 108 of file scidbase.h.
Definition at line 447 of file scidbase.h.
Definition at line 458 of file scidbase.h.
Get the sorted position of a game.
This function will be much faster if a SortCache object matching criteria already exists (previously created with createSortCache).
criteria | the list of fields by which games will be ordered. Each field should be followed by '+' to indicate an ascending order or by '-' for a descending order. |
filter | a reference to a valid (!= NULL) HFilter object. Games not included into the filter will be ignored. |
gameId | the id of the game. |
Definition at line 716 of file scidbase.cpp.
|
inline |
Transform the IndexEntries of the games included in hfilter.
The entry_op must accept a IndexEntry& parameter and return true when the IndexEntry was modified.
hfilter | HFilter containing the games to be transformed. |
progress | a Progress object used for GUI communications. |
entry_op | operator that will be applied to games' IndexEntry. |
Definition at line 297 of file scidbase.h.
std::pair< errorT, size_t > scidBaseT::transformNames | ( | nameT | nt, |
HFilter | hfilter, | ||
const Progress & | progress, | ||
const std::vector< std::string > & | newNames, | ||
TInitFunc | fnInit, | ||
TMapFunc | getID | ||
) |
Transform the names of the games included in hfilter.
The function getID maps all the old idNumberT to the new idNumberT. It's invoked for each game and must accept as parameters a idNumberT and a const IndexEntry&; must return the (eventually different) idNumberT.
nt | type of the names to be modified. |
hfilter | HFilter containing the games to be transformed. |
progress | a Progress object used for GUI communications. |
newNames | optional vector of names to be added to the database. |
fnInit | function that is invoked before beginning the transformation; must accept a vector that contains the idNumberTs of the names in newNames. |
getID | function that maps the old idNumberTs to the new ones. |
Definition at line 471 of file scidbase.h.
ByteBuffer* scidBaseT::bbuf |
Definition at line 350 of file scidbase.h.
Filter* scidBaseT::dbFilter |
Definition at line 351 of file scidbase.h.
std::pair<Game*, bool> scidBaseT::deprecated_push_pop |
Definition at line 360 of file scidbase.h.
Game* scidBaseT::game |
Definition at line 356 of file scidbase.h.
Definition at line 359 of file scidbase.h.
bool scidBaseT::gameAltered |
Definition at line 358 of file scidbase.h.
int scidBaseT::gameNumber |
Definition at line 357 of file scidbase.h.
Index* scidBaseT::idx |
Definition at line 346 of file scidbase.h.
bool scidBaseT::inUse |
Definition at line 347 of file scidbase.h.
treeT scidBaseT::tree |
Definition at line 348 of file scidbase.h.
TreeCache scidBaseT::treeCache |
Definition at line 349 of file scidbase.h.
Filter* scidBaseT::treeFilter |
Definition at line 352 of file scidbase.h.