GlobalObjects
Loading...
Searching...
No Matches
glo::TableInterface Class Referenceabstract

An object of this class or subclass accesses tables and reads or writes data records (Record) and binary files (eut::Blob). More...

#include <GloTableInterface.h>

Inheritance diagram for glo::TableInterface:

Classes

class  TableInterfaceTable
 A file (std::fstream) and its name. More...
 

Public Member Functions

 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
 
virtual int openTable (const std::string &sTableName)=0
 

Protected Member Functions

 TableInterface ()
 
int openFile (std::fstream *&prFStream, const std::string &sFullFileName, std::ios_base::openmode OpenMode)
 

Protected Attributes

std::map< std::string, TableInterfaceTable *, std::less< std::string > > m_OpenTableMap
 
RealIndexPoolm_pRealIndexPool
 
SchemaInterfacem_pSchema
 

Private Member Functions

 TableInterface (const TableInterface &)
 
void closeAllTables ()
 
TableInterface::TableInterfaceTablegetTable (const std::string &m_sTableName)
 
TableInterfaceoperator= (const TableInterface &)
 

Detailed Description

An object of this class or subclass accesses tables and reads or writes data records (Record) and binary files (eut::Blob).

An IndexPool is passed which has created the indexes (e.g. the ObjIDs) of all tables during instantiation. Accesses to the tables are realized via this IndexPool if possible.

If a table is closed or read, the index is not destroyed or read again. This requires that only a derived writer with the same RealIndexPool is allowed to write to the tables and maintain the indexes.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ TableInterface() [1/3]

glo::TableInterface::TableInterface ( )
protected

The default constructor is not available.

◆ TableInterface() [2/3]

glo::TableInterface::TableInterface ( 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.

◆ ~TableInterface()

virtual glo::TableInterface::~TableInterface ( )
virtual

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

◆ TableInterface() [3/3]

glo::TableInterface::TableInterface ( const TableInterface & )
private

The copy constructor is not available.

Member Function Documentation

◆ closeAllTables()

void glo::TableInterface::closeAllTables ( )
private

Schliesst und entfernt alle Tabellen-Dateien aus der Liste der geöffneten Tabellen-Dateien.

◆ closeTable()

virtual int glo::TableInterface::closeTable ( const std::string & sTable)
virtual

Closes a table file.

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

◆ getDataPath()

std::string glo::TableInterface::getDataPath ( ) const

Returns the full directory name where the data can be found. The data is always located in a subdirectory of the directory where the schema file is located.

Returns
The complete directory name, such as "C:/Path/Data/" under the Windows operating system.

◆ getObjIDRecordAttribute()

int glo::TableInterface::getObjIDRecordAttribute ( ObjIDRecordAttribute *& prRetVal,
const std::string & sTable,
const ObjID & rObjID )

Returns the object ID attribute with passed object ID from the table file with the passed name.

Parameters
[in,out]prRetValThe found object ID attribute.
[in]sTableThe table file name in which the object ID attribute is searched.
[in]rObjIDThe object ID of the searched object ID attribute.
Returns
A return value < 0 indicates an error.

◆ getSchemaInterface()

SchemaInterface & glo::TableInterface::getSchemaInterface ( )

Returns a pointer to m_pSchema.

Returns
See above.
Attention
The GloSchema interface lives only as long as the returning object of this class.

◆ getSchemaPath()

std::string glo::TableInterface::getSchemaPath ( ) const

Returns the file path where the schema file can be found.

Returns
Full pathname (e.g. under the operating system Windows "C:/Path/").

◆ getTable()

TableInterface::TableInterfaceTable * glo::TableInterface::getTable ( const std::string & m_sTableName)
private

Returns a table file in an object of type TableInterfaceTable with the passed name from the list of opened table files.

Parameters
[in]m_sTableNameThe file name.
Returns
The table file, if it exists with the given name; otherwise 0.
Attention
The returned object lives only as long as the returning instance.

◆ objIDInBase()

int glo::TableInterface::objIDInBase ( bool & rPresent,
const ObjID & rObjID ) const

Checks if an object with passed object ID is stored in the database.

Parameters
[in,out]rPresentIf true, there is an object with passed object ID in the database.
[in]rObjIDThe object ID to be checked.
Returns
A return value < 0 indicates an error.

◆ openFile()

int glo::TableInterface::openFile ( std::fstream *& prFStream,
const std::string & sFullFileName,
std::ios_base::openmode OpenMode )
protected

Opens and returns the opened file. It is first looked up in the list of opened table files and returns them if available.
. Otherwise, the program tries to open a file with the specified name and, if successful, to insert it into the list of opened table files and deliver it.
Is used by both subclasses with different 'OpenMode'.

Parameters
[in,out]prFStreamThe opened file (if successful).
[in]sFullFileNameThe file name.
[in]OpenModeThe mode in which the file is opened.
Returns
A return value < 0 indicates an error.
Note
If a prFStream was delivered, it is in m_OpenTableMap and is closed with closeTable (...) and removed from memory.

◆ openTable()

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

Opens a table file in subclasses 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.

Implemented in glo::TableReaderInterface, and glo::TableWriterInterface.

◆ operator=()

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

The assignment operator is not available.

Member Data Documentation

◆ m_OpenTableMap

std::map< std::string, TableInterfaceTable *, std::less<std::string> > glo::TableInterface::m_OpenTableMap
protected

The container opened table files.

◆ m_pRealIndexPool

RealIndexPool* glo::TableInterface::m_pRealIndexPool
protected

If available, the RealIndexPool is used to find a record faster.

◆ m_pSchema

SchemaInterface* glo::TableInterface::m_pSchema
protected

The underlying scheme.


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