Scid  4.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Member Functions | Public Attributes | List of all members
scidBaseT Struct Reference

#include <scidbase.h>

Collaboration diagram for scidBaseT:
Collaboration graph
[legend]

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 IndexEntrygetIndexEntry (gamenumT g) const
 
const IndexEntrygetIndexEntry_bounds (gamenumT g) const
 
const NameBasegetNameBase () 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 StatsgetStats () const
 Statistics. More...
 
std::vector< scidBaseT::TreeStatgetTreeStat (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)
 
SortCachecreateSortCache (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

Indexidx
 
bool inUse
 
treeT tree
 
TreeCache treeCache
 
ByteBufferbbuf
 
FilterdbFilter
 
FiltertreeFilter
 
Gamegame
 
int gameNumber
 
bool gameAltered
 
UndoRedo< Game, 100 > gameAlterations
 
std::pair< Game *, bool > deprecated_push_pop
 

Detailed Description

Definition at line 39 of file scidbase.h.

Constructor & Destructor Documentation

◆ scidBaseT()

scidBaseT::scidBaseT ( )

Definition at line 54 of file scidbase.cpp.

◆ ~scidBaseT()

scidBaseT::~scidBaseT ( )

Definition at line 70 of file scidbase.cpp.

Member Function Documentation

◆ beginTransaction()

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.

◆ Close()

errorT scidBaseT::Close ( )

Definition at line 114 of file scidbase.cpp.

◆ compact()

errorT scidBaseT::compact ( const Progress progress)

Definition at line 527 of file scidbase.cpp.

◆ composeFilter()

std::string scidBaseT::composeFilter ( const std::string &  mainFilter,
const std::string &  maskFilter 
) const

Definition at line 275 of file scidbase.cpp.

◆ createSortCache()

SortCache * scidBaseT::createSortCache ( const char *  criteria)

Increment the reference count of a SortCache object matching criteria.

Parameters
criteriathe 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.
Returns
a pointer to a SortCache object in case of success, NULL otherwise.

Definition at line 699 of file scidbase.cpp.

◆ deleteFilter()

void scidBaseT::deleteFilter ( const char *  filterId)

Definition at line 296 of file scidbase.cpp.

◆ endTransaction()

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.

Parameters
gameIdid of the modified game INVALID_GAMEID to update all games.
Returns
OK if successful or an error code.

Definition at line 157 of file scidbase.cpp.

◆ getCompactStat()

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.

◆ getDuplicates()

uint scidBaseT::getDuplicates ( gamenumT  gNum)
inline

Definition at line 281 of file scidbase.h.

◆ getExtraInfo()

std::vector<std::pair<const char*, std::string> > scidBaseT::getExtraInfo ( ) const
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.

◆ getFileName()

const std::string& scidBaseT::getFileName ( ) const
inline

Definition at line 97 of file scidbase.h.

◆ getFilter()

HFilter scidBaseT::getFilter ( const std::string &  filterId) const
inline

Definition at line 200 of file scidbase.h.

◆ getFlag()

bool scidBaseT::getFlag ( uint  flag,
uint  gNum 
) const
inline

Definition at line 180 of file scidbase.h.

◆ getGame() [1/3]

FastGame scidBaseT::getGame ( const IndexEntry ie) const
inline

Definition at line 141 of file scidbase.h.

◆ getGame() [2/3]

errorT scidBaseT::getGame ( const IndexEntry ie,
ByteBuffer destBuf 
) const
inline

Definition at line 147 of file scidbase.h.

◆ getGame() [3/3]

errorT scidBaseT::getGame ( const IndexEntry ie,
Game dest 
) const
inline

Definition at line 156 of file scidbase.h.

◆ getIndexEntry()

const IndexEntry* scidBaseT::getIndexEntry ( gamenumT  g) const
inline

Definition at line 131 of file scidbase.h.

◆ getIndexEntry_bounds()

const IndexEntry* scidBaseT::getIndexEntry_bounds ( gamenumT  g) const
inline

Definition at line 134 of file scidbase.h.

◆ getMainFilter()

HFilter scidBaseT::getMainFilter ( const std::string &  filterId) const
inline

Definition at line 203 of file scidbase.h.

◆ getNameBase()

const NameBase* scidBaseT::getNameBase ( ) const
inline

Definition at line 138 of file scidbase.h.

◆ getNameFreq()

uint scidBaseT::getNameFreq ( nameT  nt,
idNumberT  id 
)
inline

Definition at line 209 of file scidbase.h.

◆ getStats()

const scidBaseT::Stats & scidBaseT::getStats ( ) const

Statistics.

Definition at line 336 of file scidbase.cpp.

◆ getTreeStat()

std::vector< scidBaseT::TreeStat > scidBaseT::getTreeStat ( const HFilter filter)

Definition at line 458 of file scidbase.cpp.

◆ importGame()

errorT scidBaseT::importGame ( const scidBaseT srcBase,
uint  gNum 
)

Definition at line 194 of file scidbase.cpp.

◆ importGames() [1/2]

errorT scidBaseT::importGames ( const scidBaseT srcBase,
const HFilter filter,
const Progress progress 
)

Definition at line 205 of file scidbase.cpp.

◆ importGames() [2/2]

errorT scidBaseT::importGames ( ICodecDatabase::Codec  dbtype,
const char *  filename,
const Progress progress,
std::string &  errorMsg 
)

Definition at line 237 of file scidbase.cpp.

◆ invertFlag() [1/2]

errorT scidBaseT::invertFlag ( uint  flag,
uint  gNum 
)
inline

Definition at line 433 of file scidbase.h.

◆ invertFlag() [2/2]

errorT scidBaseT::invertFlag ( uint  flag,
const HFilter filter 
)
inline

Definition at line 437 of file scidbase.h.

◆ isReadOnly()

bool scidBaseT::isReadOnly ( ) const
inline

Definition at line 98 of file scidbase.h.

◆ listGames()

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).

Parameters
criteriathe 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.
startthe offset of the first row to return. The offset of the initial row is 0.
countmaximum number of rows to return.
filtera reference to a valid (!= NULL) HFilter object. Games not included into the filter will be ignored.
[out]destContvalid pointer to an array where the sorted list of games will be stored (should be able to contain at least count elements).
Returns
the number of games' ids stored into destCont.

Definition at line 707 of file scidbase.cpp.

◆ newFilter()

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.

◆ numGames()

gamenumT scidBaseT::numGames ( ) const
inline

Definition at line 99 of file scidbase.h.

◆ Open()

errorT scidBaseT::Open ( ICodecDatabase::Codec  dbtype,
fileModeT  mode,
const char *  filename = 0,
const Progress progress = Progress() 
)

Definition at line 84 of file scidbase.cpp.

◆ releaseSortCache()

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.

Parameters
criteriathe 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.

◆ saveGame()

errorT scidBaseT::saveGame ( Game game,
gamenumT  replacedGameId = INVALID_GAMEID 
)

Add or replace a game into the database.

Parameters
gamevalid pointer to a Game object with the data of the game.
replacedGameIdid of the game to replace. If >= numGames(), a new game will be added.
Returns
OK if successful or an error code.

Definition at line 177 of file scidbase.cpp.

◆ saveGameHelper()

errorT scidBaseT::saveGameHelper ( Game game,
gamenumT  gameId 
)

Definition at line 184 of file scidbase.cpp.

◆ setDuplicates()

void scidBaseT::setDuplicates ( uint duplicates)
inline

Definition at line 277 of file scidbase.h.

◆ setExtraInfo()

errorT scidBaseT::setExtraInfo ( const char *  tagname,
const char *  new_value 
)
inline

Store an extra information about the database (type, description, etc..)

Definition at line 108 of file scidbase.h.

◆ setFlag() [1/2]

errorT scidBaseT::setFlag ( bool  value,
uint  flag,
uint  gNum 
)
inline

Definition at line 447 of file scidbase.h.

◆ setFlag() [2/2]

errorT scidBaseT::setFlag ( bool  value,
uint  flag,
const HFilter filter 
)
inline

Definition at line 458 of file scidbase.h.

◆ sortedPosition()

size_t scidBaseT::sortedPosition ( const char *  criteria,
const HFilter filter,
gamenumT  gameId 
)

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).

Parameters
criteriathe 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.
filtera reference to a valid (!= NULL) HFilter object. Games not included into the filter will be ignored.
gameIdthe id of the game.
Returns
the sorted position of gameId.

Definition at line 716 of file scidbase.cpp.

◆ transformIndex()

template<typename TOper >
std::pair<errorT, size_t> scidBaseT::transformIndex ( HFilter  hfilter,
const Progress progress,
TOper  entry_op 
)
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.

Parameters
hfilterHFilter containing the games to be transformed.
progressa Progress object used for GUI communications.
entry_opoperator that will be applied to games' IndexEntry.
Returns
a std::pair containing OK (or an error code) and the number of games modified.

Definition at line 297 of file scidbase.h.

◆ transformNames()

template<typename TInitFunc , typename TMapFunc >
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.

Parameters
nttype of the names to be modified.
hfilterHFilter containing the games to be transformed.
progressa Progress object used for GUI communications.
newNamesoptional vector of names to be added to the database.
fnInitfunction that is invoked before beginning the transformation; must accept a vector that contains the idNumberTs of the names in newNames.
getIDfunction that maps the old idNumberTs to the new ones.
Returns
a std::pair containing OK (or an error code) and the number of games modified.

Definition at line 471 of file scidbase.h.

Member Data Documentation

◆ bbuf

ByteBuffer* scidBaseT::bbuf

Definition at line 350 of file scidbase.h.

◆ dbFilter

Filter* scidBaseT::dbFilter

Definition at line 351 of file scidbase.h.

◆ deprecated_push_pop

std::pair<Game*, bool> scidBaseT::deprecated_push_pop

Definition at line 360 of file scidbase.h.

◆ game

Game* scidBaseT::game

Definition at line 356 of file scidbase.h.

◆ gameAlterations

UndoRedo<Game, 100> scidBaseT::gameAlterations

Definition at line 359 of file scidbase.h.

◆ gameAltered

bool scidBaseT::gameAltered

Definition at line 358 of file scidbase.h.

◆ gameNumber

int scidBaseT::gameNumber

Definition at line 357 of file scidbase.h.

◆ idx

Index* scidBaseT::idx

Definition at line 346 of file scidbase.h.

◆ inUse

bool scidBaseT::inUse

Definition at line 347 of file scidbase.h.

◆ tree

treeT scidBaseT::tree

Definition at line 348 of file scidbase.h.

◆ treeCache

TreeCache scidBaseT::treeCache

Definition at line 349 of file scidbase.h.

◆ treeFilter

Filter* scidBaseT::treeFilter

Definition at line 352 of file scidbase.h.


The documentation for this struct was generated from the following files: