Scid  4.6.5
Protected Member Functions | List of all members
CodecProxy< Derived > Class Template Reference

Base class for non-native databases. More...

#include <codec_proxy.h>

Inheritance diagram for CodecProxy< Derived >:
Inheritance graph
[legend]
Collaboration diagram for CodecProxy< Derived >:
Collaboration graph
[legend]

Protected Member Functions

errorT open (const char *filename, fileModeT fMode)
 Opens/creates a database encoded in a non-native format. More...
 
errorT parseNext (Game *)
 Reads the next game. More...
 
std::pair< size_t, size_t > parseProgress ()
 Returns info about the parsing progress. More...
 
const char * parseErrors ()
 Returns the list of errors produced by parseNext() calls. More...
 
errorT dyn_addGame (Game *)
 Adds a game into the database. More...
 
errorT dyn_saveGame (Game *, gamenumT)
 Replaces a game in the database. More...
 
- Protected Member Functions inherited from CodecMemory
virtual std::pair< errorT, uint32_t > dyn_addGameData (const byte *src, size_t length)
 Stores the data of the game into the database. More...
 

Additional Inherited Members

- Public Types inherited from ICodecDatabase
enum  Codec { MEMORY, SCID4, PGN }
 
- Public Member Functions inherited from CodecMemory
 CodecMemory ()
 
Codec getType () override
 Returns the Codec type. More...
 
std::vector< std::string > getFilenames () override
 Returns the full path of the files used by the database. More...
 
const bytegetGameData (uint32_t offset, uint32_t length) override
 Fetches the data of a game (excluding index info), encoded in native format. More...
 
errorT flush () override
 Writes all pending output to the files. More...
 
- Public Member Functions inherited from ICodecDatabase
virtual ~ICodecDatabase ()
 
- Static Public Member Functions inherited from ICodecDatabase
static ICodecDatabasemake (Codec codec, errorT *err, fileModeT fMode, const char *filename, const Progress &progress, Index *idx, NameBase *nb)
 Creates a new object and calls the virtual function dyn_open(). More...
 
- Protected Attributes inherited from CodecMemory
Indexidx_
 
NameBasenb_
 

Detailed Description

template<typename Derived>
class CodecProxy< Derived >

Base class for non-native databases.

Every class derived from ICodecDatabase must keep an Index object and the corresponding NameBase object fully updated in memory. This implies that the virtual function dyn_open() must load in memory the header's data of all the games; however a dependency between the codecs and the Index class is not desirable. This class provides an interface that encapsulates the codecs, requiring only the ability to exchange Game objects.

Definition at line 48 of file codec_proxy.h.

Member Function Documentation

template<typename Derived>
errorT CodecProxy< Derived >::dyn_addGame ( Game )
inlineprotected

Adds a game into the database.

Parameters
Game*valid pointer to a Game object with the new data.
Returns
OK in case of success, an errorT code otherwise.

Definition at line 93 of file codec_proxy.h.

template<typename Derived>
errorT CodecProxy< Derived >::dyn_saveGame ( Game ,
gamenumT   
)
inlineprotected

Replaces a game in the database.

Parameters
Game*valid pointer to a Game object with the new data.
gamenumTvalid gamenumT of the game to be replaced.
Returns
OK in case of success, an errorT code otherwise.

Definition at line 103 of file codec_proxy.h.

template<typename Derived>
errorT CodecProxy< Derived >::open ( const char *  filename,
fileModeT  fMode 
)
protected

Opens/creates a database encoded in a non-native format.

Parameters
filenamefull path of the database to be opened.
fModevalid file access mode.
Returns
OK in case of success, an errorT code otherwise.
template<typename Derived>
const char* CodecProxy< Derived >::parseErrors ( )
inlineprotected

Returns the list of errors produced by parseNext() calls.

Definition at line 84 of file codec_proxy.h.

template<typename Derived>
errorT CodecProxy< Derived >::parseNext ( Game )
inlineprotected

Reads the next game.

A derived class implements this function to sequentially read the games contained into the database.

Parameters
Game*valid pointer to the Game object where the data will be stored.
Returns
  • OK on success.
  • ERROR_NotFound if there are no more games to be read.
  • ERROR code if the game cannot be read and was skipped.

Definition at line 68 of file codec_proxy.h.

template<typename Derived>
std::pair<size_t, size_t> CodecProxy< Derived >::parseProgress ( )
inlineprotected

Returns info about the parsing progress.

Returns
a pair<size_t, size_t> where first element is the quantity of data parsed and second one is the total amount of data of the database.

Definition at line 77 of file codec_proxy.h.


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