Scid  4.6.5
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  GamePos
 
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
 
errorT getExtraInfo (const std::string &tagname, std::string *res) const
 
errorT setExtraInfo (const std::string &tagname, const char *new_value)
 
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, std::vector< GamePos > &dest)
 scidBaseT::getGame() - returns all the positions of a game : a valid pointer to the IndexEntry of the desired game : a container of GamePos objects where the positions will be stored. More...
 
errorT importGame (const scidBaseT *srcBase, uint gNum)
 
errorT importGames (const scidBaseT *srcBase, const HFilter &filter, const Progress &progress)
 
template<class T , class P >
errorT importGames (T &codec, const P &progress, uint &nImported, 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 ()
 Filters : unique identifier of a Filter. 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 (uint *n_deleted, uint *n_unused, uint *n_sparse, uint *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)
 
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
 
NameBasenb
 
bool inUse
 
treeT tree
 
TreeCache treeCache
 
ByteBufferbbuf
 
FilterdbFilter
 
FiltertreeFilter
 
Gamegame
 
int gameNumber
 
bool gameAltered
 
UndoRedo< Game, 100 > gameAlterations
 

Detailed Description

Definition at line 37 of file scidbase.h.

Constructor & Destructor Documentation

scidBaseT::scidBaseT ( )

Definition at line 58 of file scidbase.cpp.

scidBaseT::~scidBaseT ( )

Definition at line 75 of file scidbase.cpp.

Member Function Documentation

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 163 of file scidbase.cpp.

errorT scidBaseT::Close ( )

Definition at line 124 of file scidbase.cpp.

errorT scidBaseT::compact ( const Progress progress)

Definition at line 688 of file scidbase.cpp.

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

Definition at line 427 of file scidbase.cpp.

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 855 of file scidbase.cpp.

void scidBaseT::deleteFilter ( const char *  filterId)

Definition at line 448 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.

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

Definition at line 169 of file scidbase.cpp.

errorT scidBaseT::getCompactStat ( uint n_deleted,
uint n_unused,
uint n_sparse,
uint n_badNameId 
)

Definition at line 652 of file scidbase.cpp.

uint scidBaseT::getDuplicates ( gamenumT  gNum)
inline

Definition at line 257 of file scidbase.h.

errorT scidBaseT::getExtraInfo ( const std::string &  tagname,
std::string *  res 
) const

Definition at line 180 of file scidbase.cpp.

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

Definition at line 95 of file scidbase.h.

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

Definition at line 177 of file scidbase.h.

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

Definition at line 154 of file scidbase.h.

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

Definition at line 111 of file scidbase.h.

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

Definition at line 117 of file scidbase.h.

errorT scidBaseT::getGame ( const IndexEntry ie,
std::vector< GamePos > &  dest 
)

scidBaseT::getGame() - returns all the positions of a game : a valid pointer to the IndexEntry of the desired game : a container of GamePos objects where the positions will be stored.

This function iterate all the positions of the game pointed by and stores the positions in . The container is NOT automatically cleared and the container should support push_back(). The order of positions and of Recursive Annotation Variations (RAV) follows the pgn standard: "The alternate move sequence given by an RAV is one that may be legally played by first unplaying the move that appears immediately prior to the RAV. Because the RAV is a recursive construct, it may be nested." Each position have a RAVdepth and a RAVnum that allows to follow a variation from any given position:

  • skip all the next positions with a bigger RAVdepth
  • the variation ends with:
    • a lower RAVdepth or
    • an equal RAVdepth but different RAVnum or
    • the end of

Return OK if successful.

Definition at line 270 of file scidbase.cpp.

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

Definition at line 101 of file scidbase.h.

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

Definition at line 104 of file scidbase.h.

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

Definition at line 180 of file scidbase.h.

const NameBase* scidBaseT::getNameBase ( ) const
inline

Definition at line 108 of file scidbase.h.

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

Definition at line 186 of file scidbase.h.

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

Statistics.

Definition at line 497 of file scidbase.cpp.

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

Definition at line 619 of file scidbase.cpp.

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

Definition at line 350 of file scidbase.cpp.

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

Definition at line 361 of file scidbase.cpp.

template<class T , class P >
errorT scidBaseT::importGames ( T &  codec,
const P &  progress,
uint nImported,
std::string &  errorMsg 
)
inline

Definition at line 338 of file scidbase.h.

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

Definition at line 366 of file scidbase.h.

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

Definition at line 370 of file scidbase.h.

bool scidBaseT::isReadOnly ( ) const
inline

Definition at line 96 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).

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 863 of file scidbase.cpp.

std::string scidBaseT::newFilter ( )

Filters : unique identifier of a Filter.

Filters.

A Filter is a selection of games, usually obtained searching the database. A new Filter is created calling the function newFilter() and must be released calling the function deleteFilter(). A composed Filter is a special contruct created combining two Filters and includes only the games contained in both Filters. A composed Filter should NOT be released.

Definition at line 414 of file scidbase.cpp.

gamenumT scidBaseT::numGames ( ) const
inline

Definition at line 97 of file scidbase.h.

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

Definition at line 89 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.

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 841 of file scidbase.cpp.

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 330 of file scidbase.cpp.

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

Definition at line 337 of file scidbase.cpp.

void scidBaseT::setDuplicates ( uint duplicates)
inline

Definition at line 253 of file scidbase.h.

errorT scidBaseT::setExtraInfo ( const std::string &  tagname,
const char *  new_value 
)

Definition at line 199 of file scidbase.cpp.

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

Definition at line 380 of file scidbase.h.

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

Definition at line 391 of file scidbase.h.

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 872 of file scidbase.cpp.

Member Data Documentation

ByteBuffer* scidBaseT::bbuf

Definition at line 285 of file scidbase.h.

Filter* scidBaseT::dbFilter

Definition at line 286 of file scidbase.h.

Game* scidBaseT::game

Definition at line 291 of file scidbase.h.

UndoRedo<Game, 100> scidBaseT::gameAlterations

Definition at line 294 of file scidbase.h.

bool scidBaseT::gameAltered

Definition at line 293 of file scidbase.h.

int scidBaseT::gameNumber

Definition at line 292 of file scidbase.h.

Index* scidBaseT::idx

Definition at line 280 of file scidbase.h.

bool scidBaseT::inUse

Definition at line 282 of file scidbase.h.

NameBase* scidBaseT::nb

Definition at line 281 of file scidbase.h.

treeT scidBaseT::tree

Definition at line 283 of file scidbase.h.

TreeCache scidBaseT::treeCache

Definition at line 284 of file scidbase.h.

Filter* scidBaseT::treeFilter

Definition at line 287 of file scidbase.h.


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