GlobalObjects
Loading...
Searching...
No Matches
glo::TableWriterInterface Class Reference

An object of this class accesses tables and writes data records (Record) and binary files (eut::Blob) into text tables resp. the file system. More...

#include <GloTableWriterInterface.h>

Inheritance diagram for glo::TableWriterInterface:

Public Member Functions

 TableWriterInterface (const SchemaInterface &rScheme, RealIndexPool *pRealIndexPool)
 
virtual ~TableWriterInterface ()
 
int deleteObjectData (Record *pRecord, std::vector< TransactionIndexPool * > *pTransactionIndexPoolVector=0)
 
int getNewObjID (ObjID &rObjID)
 
virtual int openTable (const std::string &sTableName)
 
int storeObjectData (Record *pRecord, std::vector< TransactionIndexPool * > *pTransactionIndexPoolVector=0)
 
- Public Member Functions inherited from glo::TableInterface
 TableInterface (const SchemaInterface &rScheme, RealIndexPool *pRealIndexPool)
 
virtual ~TableInterface ()
 
virtual int closeTable (const std::string &sTable)
 
std::string getDataPath () const
 
int getObjIDRecordAttribute (ObjIDRecordAttribute *&prRetVal, const std::string &sTable, const ObjID &rObjID)
 
SchemaInterfacegetSchemaInterface ()
 
std::string getSchemaPath () const
 
int objIDInBase (bool &rPresent, const ObjID &rObjID) const
 

Protected Member Functions

 TableWriterInterface ()
 
int appendOnTable (std::streampos &rspFileIndexPosition, const std::string &rsTableName, unsigned long ulClassID, const std::string &rsDataRow)
 
int getFirstDeletedRecordItem (std::streampos &rspFileIndexPosition, const std::string &rsFullTableName)
 
int getFirstDeletedRecordItem (std::streampos &rspFileIndexPosition, unsigned long ulClassID)
 
int readLastMagicNumber (eut::UnsignedMagicNumber &rRetVal, const std::string &rsFileName)
 
int readLastObjCounter (unsigned long &rulObjCounter)
 
int readLastUL (unsigned long &rulRetVal, const std::string &rsFileName)
 
void removeForbiddenCharacters (std::string &rsField) const
 
int updateExternFiles (BaseRecordAttribute *pRecordAttribute, DATA_REFERENCE_INFO MethodInfo)
 
int updateInsert (Record *pInputUpdateRecord, EnInUd eInUd)
 
int updateObjectDataAttribute (BaseRecordAttribute *pRecordAttribute, ObjID ObjID)
 
int writeInTable (const std::string &rsTableName, const std::string &rsContents, const std::streampos spFileIndexPosition)
 
int writeLastMagicNumber (const eut::UnsignedMagicNumber &rVal, const std::string &rsFileName, bool bNew)
 
int writeLastObjCounter (const unsigned long &rulObjCounter, bool bNew)
 
int writeLastUL (const unsigned long &rulVal, const std::string &rsFileName, bool bNew)
 
- Protected Member Functions inherited from glo::TableInterface
 TableInterface ()
 
int openFile (std::fstream *&prFStream, const std::string &sFullFileName, std::ios_base::openmode OpenMode)
 

Private Types

enum  EnInUd { eINSERT , eUPDATE }
 

Private Member Functions

 TableWriterInterface (const TableWriterInterface &)
 
TableInterfaceoperator= (const TableInterface &)
 

Private Attributes

std::vector< TransactionIndexPool * > * m_pTransactionIndexPoolVector
 

Additional Inherited Members

- Protected Attributes inherited from glo::TableInterface
std::map< std::string, TableInterfaceTable *, std::less< std::string > > m_OpenTableMap
 
RealIndexPoolm_pRealIndexPool
 
SchemaInterfacem_pSchema
 

Detailed Description

An object of this class accesses tables and writes data records (Record) and binary files (eut::Blob) into text tables resp. the file system.

Author
Helmut Jakoby

Member Enumeration Documentation

◆ EnInUd

An enumeration to indicate whether a record in a table file should be newly inserted or overwritten.

Enumerator
eINSERT 

Der Datensatz soll in die Tabellen-Datei neu eingefügt werden

eUPDATE 

The record is to be overwritten in the table file

Constructor & Destructor Documentation

◆ TableWriterInterface() [1/3]

glo::TableWriterInterface::TableWriterInterface ( )
protected

The default constructor is not available.

◆ TableWriterInterface() [2/3]

glo::TableWriterInterface::TableWriterInterface ( const SchemaInterface & rScheme,
RealIndexPool * pRealIndexPool )

Constructor with parameter passing.

Parameters
[in]rSchemeCannot be used without schema, will be copied.
[in]pRealIndexPoolAccelerates the access to records.
Exceptions
eut::ErrorNExceptionAn exception is thrown if an error occurs.

◆ ~TableWriterInterface()

virtual glo::TableWriterInterface::~TableWriterInterface ( )
virtual

Destructor, all open table files are closed and the memory is cleaned up.

◆ TableWriterInterface() [3/3]

glo::TableWriterInterface::TableWriterInterface ( const TableWriterInterface & )
private

The copy constructor is not available.

Member Function Documentation

◆ appendOnTable()

int glo::TableWriterInterface::appendOnTable ( std::streampos & rspFileIndexPosition,
const std::string & rsTableName,
unsigned long ulClassID,
const std::string & rsDataRow )
protected

Writes a new record either at the end of the table or, if a deleted record exists, in its place.

Parameters
[in,out]rspFileIndexPositionThe position in the table file where the record was written (is the position of the object ID needed for the index).
[in]rsTableNameThe complete name of the table file.
[in]ulClassIDThe class ID, needed to determine the position of a possibly deleted data set from the TableInterface::m_pRealIndexPool.
[in]rsDataRowThe row with the data set attributes to be written to the table file.
Returns
A return value < 0 indicates an error.

◆ deleteObjectData()

int glo::TableWriterInterface::deleteObjectData ( Record * pRecord,
std::vector< TransactionIndexPool * > * pTransactionIndexPoolVector = 0 )

Marks the passed record in the tables as deleted (ObjID == 0). External files are deleted if they exist.
Indexes are adjusted in the RealIndexPool

Parameters
[in]pRecordThe record to be deleted.
[in]pTransactionIndexPoolVectorIf passed, then not only in the RealIndexPool but also in this TransactionIndexPools the indexes are updated
Returns
A return value < 0 indicates an error.

◆ getFirstDeletedRecordItem() [1/2]

int glo::TableWriterInterface::getFirstDeletedRecordItem ( std::streampos & rspFileIndexPosition,
const std::string & rsFullTableName )
protected

Determines the position of a record in a table file.

Parameters
[in,out]rspFileIndexPositionThe position in the table file where a record was deleted.
[in]rsFullTableNameThe complete name of the table file.

◆ getFirstDeletedRecordItem() [2/2]

int glo::TableWriterInterface::getFirstDeletedRecordItem ( std::streampos & rspFileIndexPosition,
unsigned long ulClassID )
protected

Returns the position of a record in a table file of the class of the passed class ID, which has been deleted (from the TableInterface::m_pRealIndexPool).

Parameters
[in,out]rspFileIndexPositionThe position in the table file where a record was deleted.
[in]ulClassIDThe class ID is needed to determine the position of a possibly deleted data set from the TableInterface::m_pRealIndexPool.

◆ getNewObjID()

int glo::TableWriterInterface::getNewObjID ( ObjID & rObjID)

Returns in passed ObjID a new unique object ID, without class ID.

Parameters
[in,out]rObjIDThe object ID is set.
Returns
A return value < 0 indicates an error.

◆ openTable()

virtual int glo::TableWriterInterface::openTable ( const std::string & sTableName)
virtual

Opens a table file and adds it to the list of opened table files if successful.

Parameters
[in]sTableNameThe table file name.
Returns
A return value < 0 indicates an error.

Implements glo::TableInterface.

◆ operator=()

TableInterface & glo::TableWriterInterface::operator= ( const TableInterface & )
private

The assignment operator is not available.

◆ readLastMagicNumber()

int glo::TableWriterInterface::readLastMagicNumber ( eut::UnsignedMagicNumber & rRetVal,
const std::string & rsFileName )
protected

Reads an eut::UnsignedMagicNumber from a file with the passed name (the file with the passed name is expected in the data directory) .

Parameters
[in,out]rRetValThe eut::UnsignedMagicNumber is set.
[in,out]rsFileNameThe file from which rRetVal is read.
Returns
A return value < 0 indicates an error.

◆ readLastObjCounter()

int glo::TableWriterInterface::readLastObjCounter ( unsigned long & rulObjCounter)
protected

Reads an object counter (for ObjID::m_ulObjCounter) from the file "LastObjID" (the file "LastObjID" is located in the data directory).
Used by TableWriterInterface::getNewObjID(ObjID&)

Parameters
[in,out]rulObjCounterThe object counter.
Returns
A return value < 0 indicates an error.

◆ readLastUL()

int glo::TableWriterInterface::readLastUL ( unsigned long & rulRetVal,
const std::string & rsFileName )
protected

Reads an unsigned long from a file with the passed name (the file with the passed name is expected in the data directory) .

Parameters
[in,out]rulRetValThe value is set.
[in,out]rsFileNameThe file from which rulRetVal is read.
Returns
A return value < 0 indicates an error.

◆ removeForbiddenCharacters()

void glo::TableWriterInterface::removeForbiddenCharacters ( std::string & rsField) const
protected

Removes forbidden characters from passed string.
Two characters are always replaced with substitute characters.
The TableInterface::TableColumnDelimiter is reserved as separator for the individual table fields and is changed to a '^'.
A '\n' would destroy the text table due to the line break and is changed to a '_'.

Parameters
[in]rsFieldThe string which is checked.

◆ storeObjectData()

int glo::TableWriterInterface::storeObjectData ( Record * pRecord,
std::vector< TransactionIndexPool * > * pTransactionIndexPoolVector = 0 )

Inserts or appends the record to/from the tables. External files are written if necessary.

Parameters
[in]pRecordThe data set to be written.
[in]pTransactionIndexPoolVectorIf passed, not only in the RealIndexPool but also in this TransactionIndexPools the indexes are updated
Returns
return == 1 Newly inserted in database
Return == 0 Changed in database
A return value < 0 indicates an error.

◆ updateExternFiles()

int glo::TableWriterInterface::updateExternFiles ( BaseRecordAttribute * pRecordAttribute,
DATA_REFERENCE_INFO MethodInfo )
protected

Deletes resp. rewrites or writes new an external file depending on the passed DATA_REFERENCE_INFO.

Parameters
[in]pRecordAttributePointer to the record attribute whose data is to be written to an external file or whose external file is to be deleted.
[in]MethodInfoThe information how to handle the external file.
Returns
A return value < 0 indicates an error.

◆ updateInsert()

int glo::TableWriterInterface::updateInsert ( Record * pInputUpdateRecord,
EnInUd eInUd )
protected

Inserts or appends the record to/from the tables. External files are written if necessary.

Parameters
[in]pInputUpdateRecordThe data set to be written.
[in]eInUdIf eINSERT a record is rewritten, if eUPDATE the existing record is overwritten.
Returns
A return value < 0 indicates an error.

◆ updateObjectDataAttribute()

int glo::TableWriterInterface::updateObjectDataAttribute ( BaseRecordAttribute * pRecordAttribute,
ObjID ObjID )
protected

Writes a single record attribute to a table file.

Parameters
[in]pRecordAttributePointer to the record attribute to be written.
[in]ObjIDIf a file name must be created, it will be generated from this object ID.
Returns
A return value < 0 indicates an error.

◆ writeInTable()

int glo::TableWriterInterface::writeInTable ( const std::string & rsTableName,
const std::string & rsContents,
const std::streampos spFileIndexPosition )
protected

Writes the passed table field (rsContents) into the table with the passed name (rsTableName) at the passed position (spFileIndexPosition).
This method is used to write a data set (see call of this method in TableWriterInterface::updateInsert (...) ) or to write a BaseRecordAttribute in a table row (see call in TableWriterInterface::updateObjectDataAttribute (...) ).

Parameters
[in]rsTableNameThe complete name of the table file.
[in]rsContentsThe formatted table field (it is assumed that the content has the correct length and all forbidden characters have been removed or replaced).
[in]spFileIndexPositionThe position of the table field in the table file.
Returns
A return value < 0 indicates an error.

◆ writeLastMagicNumber()

int glo::TableWriterInterface::writeLastMagicNumber ( const eut::UnsignedMagicNumber & rVal,
const std::string & rsFileName,
bool bNew )
protected

Writes an eut::UnsignedMagicNumber to a file with the passed name (the file with the passed name is expected in the data directory).

Parameters
[in]rValThe value is written.
[in,out]rsFileNameThe file in which rVal is written.
[in]bNewIf true, the file will be recreated, otherwise rVal will be overwritten in the file.
Returns
A return value < 0 indicates an error.

◆ writeLastObjCounter()

int glo::TableWriterInterface::writeLastObjCounter ( const unsigned long & rulObjCounter,
bool bNew )
protected

Writes an object counter (for ObjID::m_ulObjCounter) to the file "LastObjID" (the file "LastObjID" is located in the data directory).
Used by TableWriterInterface::getNewObjID(ObjID&)

Parameters
[in]rulObjCounterThe object counter.
[in]bNewIf true, the file will be recreated, otherwise the object counter in the file "LastObjID" will be overwritten.
Returns
A return value < 0 indicates an error.

◆ writeLastUL()

int glo::TableWriterInterface::writeLastUL ( const unsigned long & rulVal,
const std::string & rsFileName,
bool bNew )
protected

Writes an unsigned long to a file with the passed name (the file with the passed name is expected in the data directory).

Parameters
[in]rulValThe value is written.
[in,out]rsFileNameThe file in which rulVal is written.
[in]bNewIf true, the file will be recreated, otherwise rulVal will be overwritten in the file.
Returns
A return value < 0 indicates an error.

Member Data Documentation

◆ m_pTransactionIndexPoolVector

std::vector<TransactionIndexPool *>* glo::TableWriterInterface::m_pTransactionIndexPoolVector
private

A list of TransactionIndexPools, which have to be updated when a persistent object is added or deleted.

Is passed via TableWriterInterface::storeObjectData (...) and TableWriterInterface::deleteObjectData (...) and is only temporary for this purpose.


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