Scid  4.6.5
Classes | Public Member Functions | Static Public Member Functions | List of all members
SortCache Class Reference

This class sorts games contained into an Index. More...

#include <sortcache.h>

Public Member Functions

 ~SortCache ()
 
void checkForChanges (gamenumT gameId)
 Notify the object that a game's header data has changed. More...
 
void prepareForChanges ()
 Interrupt any asynchronous operation. More...
 
size_t select (size_t row_offset, size_t row_count, const HFilter &filter, gamenumT *result) const
 Retrieve the sorted list of games' ids. More...
 
size_t sortedPosition (gamenumT gameId, const HFilter &filter) const
 Get the sorted position of a game. More...
 
int incrRef (int incr)
 

Static Public Member Functions

static SortCachecreate (const Index *idx, const NameBase *nb, const char *criteria)
 Create a new SortCache object, builds the hash table, and asynchronously sorts all the games. More...
 

Detailed Description

This class sorts games contained into an Index.

Multiple SortCache objects can be created for a single Index, allowing to simultaneously sort the games by multiple criteria in an independent way.

Definition at line 50 of file sortcache.h.

Constructor & Destructor Documentation

SortCache::~SortCache ( )

Definition at line 110 of file sortcache.cpp.

Member Function Documentation

void SortCache::checkForChanges ( gamenumT  gameId)

Notify the object that a game's header data has changed.

Parameters
gameIdthe id of the game whose data has been changed.

Definition at line 238 of file sortcache.cpp.

SortCache * SortCache::create ( const Index idx,
const NameBase nb,
const char *  criteria 
)
static

Create a new SortCache object, builds the hash table, and asynchronously sorts all the games.

Parameters
idxvalid pointer to an Index object, witch contains the header data of the games to be sorted.
nbvalid pointer to the NameBase corresponding to idx.
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.
fullSortstart a background thread to asynchronously sort all games, making subsequent uses of this object faster.
Returns
a pointer to the new object in case of success, NULL otherwise.

Definition at line 116 of file sortcache.cpp.

int SortCache::incrRef ( int  incr)
inline

Definition at line 150 of file sortcache.h.

void SortCache::prepareForChanges ( )
inline

Interrupt any asynchronous operation.

This function must be called before modifying the Index or the NameBase associated with the SortCache.

Definition at line 120 of file sortcache.h.

size_t SortCache::select ( size_t  row_offset,
size_t  row_count,
const HFilter filter,
gamenumT result 
) const

Retrieve the sorted list of games' ids.

The behavior of this function is similar to the mySQL statement: SELECT gameId FROM idx WHERE filter(gameId) != 0 ORDER BY criteria LIMIT offset, row_count

Parameters
row_offsetthe offset of the first row to return. The offset of the initial row is 0.
row_countmaximum number of rows to return.
filtera reference to a valid (!= NULL) HFilter object. Games not included into the filter will be ignored.
[out]resultvalid pointer to an array where the sorted list of games will be stored (should be able to contain at least row_count elements).
Returns
the number of games' ids stored into result.

Definition at line 160 of file sortcache.cpp.

size_t SortCache::sortedPosition ( gamenumT  gameId,
const HFilter filter 
) const

Get the sorted position of a game.

Parameters
gameIdthe id of the game.
filtera reference to a valid (!= NULL) HFilter object. Games not included into the filter will be ignored, and gameId must be included into the filter.
Returns
the sorted position of gameId.

Definition at line 213 of file sortcache.cpp.


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