#include <TableFile.h>
Public Types | |
enum | eStatusInd { eCLEAR_STATUS = 0x0000, eDUPLICATE_BLOCKS = 0x0001, eUNNAMED_BLOCKS = 0x0002 } |
Public Member Functions | |
TableFile (const StringCompare::eCompareType caseSense=StringCompare::eCASE_SENSITIVE) | |
TableFile (const eFileMode fileMode, const string &fileName, const StringCompare::eCompareType caseSense=StringCompare::eCASE_SENSITIVE) | |
virtual | ~TableFile () |
string | GetFileName (void) |
eFileMode | GetFileMode (void) |
StringCompare::eCompareType | GetCaseSensitivity (void) |
unsigned int | GetStatusInd (void) |
unsigned int | GetNumBlocks () |
void | GetBlockNames (vector< string > &blockNames) |
string | GetFirstBlockName () |
bool | IsBlockPresent (const string &blockName) |
string | AddBlock (const string &blockName) |
Block & | GetBlock (const string &blockName) |
string | RenameBlock (const string &oldBlockName, const string &newBlockName) |
string | RenameFirstBlock (const string &newBlockName) |
void | Flush () |
void | Serialize (const string &fileName) |
void | Close () |
Protected Member Functions | |
void | _SetStatusInd (const string &blockName) |
void | _AddBlock (const string &blockName, FileNavigator *fileNav) |
void | _GetNumTablesInBlocks (vector< Word > &numTablesInBlocks) |
ISTable * | _GetTablePtr (const unsigned int blockIndex, const unsigned int tableIndex) |
void | _GetAllTables () |
unsigned int | GetTotalNumTables () |
void | GetTableNames (vector< string > &tableNames) |
void | GetTablesIndices (vector< unsigned int > &tablesIndices) |
void | GetSortedTablesIndices (vector< unsigned int > &tablesIndices) |
int | _ReadFileIndex () |
int | _ReadFileIndexVersion0 () |
int | _ReadFileIndexVersion1 () |
int | _WriteFileIndex (FileNavigator *fileNav, const vector< int > &tableLocs) |
Protected Attributes | |
string | _fileName |
eFileMode | _fileMode |
StringCompare::eCompareType | _caseSense |
unsigned int | _statusInd |
mapped_ptr_vector< Block, StringCompare > | _blocks |
FileNavigator * | _f |
Private Member Functions | |
void | Init () |
int | Open (const string &fileName, const eFileMode fileMode) |
unsigned int | GetBlockIndexFromTableId (const string &tableId) |
string | GetTableNameFromTableId (const string &tableId) |
string | MakeInternalBlockName (const string &blockName) |
void | PrintHeaderInfo () |
void | DumpFile (void) |
void | PrintIndex (void) |
void | PrintIndexPosition (int position) |
Static Private Attributes | |
static const string | _version |
This class represents an ordered container of data blocks. Data blocks can come from DDL, dictionary or CIF files, where each data block is a container of tables. This class provides methods for construction and destruction, data blocks manipulation (addition, retrieval, renaming.). The class does in-memory management of data blocks, as well as serialization and de-serialization to and from a file. The class supports the following file modes: read-only, create, update and virtual. In read-only mode, blocks and tables can only be read (from an existing table file that has been previously serialized to a file) and cannot be modified. Create mode is used to create a table file from scratch and add/update blocks and tables in it and serialize it to a file. Update mode is used to update an existing table file (that has been previously serialized to a file). Virtual mode only provides in-memory management of data blocks and is used when object persistency is not needed. Hence, all modes except virtual mode provide association between in-memory data blocks and persistent data blocks stored in a file.
TableFile::TableFile | ( | const StringCompare::eCompareType | caseSense = StringCompare::eCASE_SENSITIVE |
) |
Constructs a table file.
[in] | caseSense | - optional parameter that indicates case sensitivity of table names in blocks. Possible values are case sensitive and case in-sensitive. If not specified, case sensitive table names are assumed. |
None |
TableFile::TableFile | ( | const eFileMode | fileMode, | |
const string & | fileName, | |||
const StringCompare::eCompareType | caseSense = StringCompare::eCASE_SENSITIVE | |||
) |
Constructs a table file.
[in] | fileMode | - table file mode. Possible values are read-only, create, update and virtual. |
[in] | fileName | - relative or absolute name of the file where object persistency is maintained. If fileMode specifies virtual mode, this parameter is ignored. |
[in] | caseSense | - optional parameter that indicates case sensitivity of table names in blocks. Possible values are case sensitive and case in-sensitive. If not specified, case sensitive table names are assumed. |
None |
TableFile::~TableFile | ( | ) | [virtual] |
Destructs a table file, by first flushing all the modified tables in data blocks (for create mode or update mode) and then releasing all in-memory objects.
Not applicable |
None |
string TableFile::GetFileName | ( | void | ) | [inline] |
Retrieves the name of the file that persistently holds data blocks and their tables.
None |
None |
eFileMode TableFile::GetFileMode | ( | void | ) | [inline] |
Retrieves table file mode.
None |
CREATE_MODE - if create mode
UPDATE_MODE - if update mode
VIRTUAL_MODE - if virtual mode
None |
StringCompare::eCompareType TableFile::GetCaseSensitivity | ( | void | ) | [inline] |
Retrieves case sensitivity of table names in blocks.
None |
eCASE_INSENSITIVE - if case in-sensitive
None |
unsigned int TableFile::GetStatusInd | ( | void | ) | [inline] |
Retrieves table file status in form of one or more flags.
None |
None |
unsigned int TableFile::GetNumBlocks | ( | ) | [inline] |
Retrieves the number of data blocks in the table file.
None |
None |
void TableFile::GetBlockNames | ( | vector< string > & | blockNames | ) |
Retrieves data block names.
[out] | blockNames | - retrieved data block names |
None |
string TableFile::GetFirstBlockName | ( | ) |
Retrieves the name of the first data block.
None |
None |
bool TableFile::IsBlockPresent | ( | const string & | blockName | ) |
Checks for data block existence.
[in] | blockName | - the name of the data block |
false - if data block does not exist
None |
string TableFile::AddBlock | ( | const string & | blockName | ) |
Adds a block to the table file. If a block with the specified name already exists, table file stores it under different internal name, that is obtained by appending a "#" symbol and the current block count. After writing blocks, with these kinds of block names, to an ASCII file, "#" symbol becomes a comment and the text after it is ignored. This enables the preservation of all duplicate blocks in the written file.
[in] | blockName | - the name of the data block |
None |
Block & TableFile::GetBlock | ( | const string & | blockName | ) |
Retrieves a reference to the data block in the table file.
[in] | blockName | - the name of the data block |
NotFoundException | - if data block with name blockName does not exist |
string TableFile::RenameBlock | ( | const string & | oldBlockName, | |
const string & | newBlockName | |||
) |
Changes the data block name.
[in] | oldBlockName | - the name of the data block which is to be renamed |
[in] | newBlockName | - the new data block name |
Data block with name oldBlockName must be present
EmptyContainerException | - if table file has no data blocks | |
NotFoundException | - if data block with name oldBlockName does not exist |
string TableFile::RenameFirstBlock | ( | const string & | newBlockName | ) | [inline] |
Changes the name of the first data block in table file.
[in] | newBlockName | - the new data block name |
EmptyContainerException | - if table file has no data blocks |
void TableFile::Flush | ( | ) |
Writes only the new or modified tables in data blocks to the associated persistent storage file (specified at table file construction time).
None |
FileModeException | - if table file is not in create or update mode |
void TableFile::Serialize | ( | const string & | fileName | ) |
Writes all the data blocks and their tables in the specified file. The inteded purpose of this method is to write to a file different than the one specified at construction time.
[in] | fileName | - relative or absolute name of the file |
None |
void TableFile::Close | ( | ) |
Flushes the table file (if in create or update mode) and closes the associated persistent storage file.
None |
None |
void TableFile::_SetStatusInd | ( | const string & | blockName | ) | [protected] |
void TableFile::_AddBlock | ( | const string & | blockName, | |
FileNavigator * | fileNav | |||
) | [protected] |
void TableFile::_GetNumTablesInBlocks | ( | vector< Word > & | numTablesInBlocks | ) | [protected] |
ISTable * TableFile::_GetTablePtr | ( | const unsigned int | blockIndex, | |
const unsigned int | tableIndex | |||
) | [protected] |
void TableFile::_GetAllTables | ( | ) | [protected] |
unsigned int TableFile::GetTotalNumTables | ( | ) | [protected] |
void TableFile::GetTableNames | ( | vector< string > & | tableNames | ) | [protected] |
void TableFile::GetTablesIndices | ( | vector< unsigned int > & | tablesIndices | ) | [protected] |
void TableFile::GetSortedTablesIndices | ( | vector< unsigned int > & | tablesIndices | ) | [protected] |
int TableFile::_ReadFileIndex | ( | ) | [protected] |
int TableFile::_ReadFileIndexVersion0 | ( | ) | [protected] |
int TableFile::_ReadFileIndexVersion1 | ( | ) | [protected] |
int TableFile::_WriteFileIndex | ( | FileNavigator * | fileNav, | |
const vector< int > & | tableLocs | |||
) | [protected] |
void TableFile::Init | ( | ) | [private] |
int TableFile::Open | ( | const string & | fileName, | |
const eFileMode | fileMode | |||
) | [private] |
unsigned int TableFile::GetBlockIndexFromTableId | ( | const string & | tableId | ) | [private] |
string TableFile::GetTableNameFromTableId | ( | const string & | tableId | ) | [private] |
string TableFile::MakeInternalBlockName | ( | const string & | blockName | ) | [private] |
void TableFile::PrintHeaderInfo | ( | ) | [private] |
void TableFile::DumpFile | ( | void | ) | [inline, private] |
void TableFile::PrintIndex | ( | void | ) | [inline, private] |
void TableFile::PrintIndexPosition | ( | int | position | ) | [inline, private] |
string TableFile::_fileName [protected] |
eFileMode TableFile::_fileMode [protected] |
StringCompare::eCompareType TableFile::_caseSense [protected] |
unsigned int TableFile::_statusInd [protected] |
mapped_ptr_vector<Block, StringCompare> TableFile::_blocks [protected] |
FileNavigator* TableFile::_f [protected] |
const string TableFile::_version [static, private] |