TableFile.h
Go to the documentation of this file.
//$$FILE$$
//$$VERSION$$
//$$DATE$$
//$$LICENSE$$
#ifndef TABLEFILE_H
#define TABLEFILE_H
#include <vector>
#include <set>
#include <rcsb/rcsb_types.h>
#include <rcsb/mapped_ptr_vector.h>
#include <rcsb/mapped_ptr_vector.C>
#include <rcsb/GenString.h>
#include <rcsb/ISTable.h>
#include <rcsb/Serializer.h>
class Block
{
public:
mapped_ptr_vector<ISTable, StringLess> _tables;
Block(const string& name, Serializer* serP,
const eFileMode fileMode = READ_MODE, const Char::eCompareType
caseSense = Char::eCASE_SENSITIVE);
~Block();
vector<pair<string, ISTable::eTableDiff> > operator==(Block& inBlock);
inline void SetName(const string& name);
inline const string& GetName() const;
ISTable& AddTable(const std::string& name = string(),
const Char::eCompareType colCaseSense = Char::eCASE_SENSITIVE);
void AddTable(const string& name, const int indexInFile = 0,
ISTable* isTableP = NULL);
void RenameTable(const string& oldName, const string& newName);
void GetTableNames(vector<string>& tableNames);
bool IsTablePresent(const string& tableName);
ISTable& GetTable(const string& tableName);
ISTable* GetTablePtr(const string& tableName);
void DeleteTable(const string& tableName);
void WriteTable(ISTable& isTable);
void WriteTable(ISTable* isTableP);
void Print();
private:
string _name;
eFileMode _fileMode;
Serializer* _ser;
Block(const Block& t);
Block& operator=(const Block& inBlock);
ISTable* _GetTablePtr(const unsigned int tableIndex);
};
class TableFile
{
public:
enum eStatusInd
{
eCLEAR_STATUS = 0x0000,
eDUPLICATE_BLOCKS = 0x0001,
eUNNAMED_BLOCKS = 0x0002
};
TableFile(const Char::eCompareType caseSense = Char::eCASE_SENSITIVE);
TableFile(const eFileMode fileMode, const string& fileName,
const Char::eCompareType caseSense = Char::eCASE_SENSITIVE);
virtual ~TableFile();
inline string GetFileName(void);
inline eFileMode GetFileMode(void);
inline Char::eCompareType GetCaseSensitivity(void);
inline unsigned int GetStatusInd(void);
inline 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);
inline string RenameFirstBlock(const string& newBlockName);
void Flush();
void Serialize(const string& fileName);
void Close();
protected:
string _fileName;
eFileMode _fileMode;
// Indicates case sensitivity of identifiers
Char::eCompareType _caseSense;
// Indicates the current status of the object
unsigned int _statusInd;
mapped_ptr_vector<Block, StringLess> _blocks;
Serializer* _f;
void _SetStatusInd(const string& blockName);
void _AddBlock(const string& blockName, Serializer* serP);
void _GetNumTablesInBlocks(vector<UInt32>& 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);
void _ReadFileIndex();
void _ReadFileIndexVersion0();
void _ReadFileIndexVersion1();
void _WriteFileIndex(Serializer* serP,
const vector<unsigned int>& tableLocs);
private:
static const string _version;
void Init();
void Open(const string& fileName, const eFileMode fileMode);
unsigned int GetBlockIndexFromTableId(const string& tableId);
string GetTableNameFromTableId(const string& tableId);
string MakeInternalBlockName(const string& blockName,
const unsigned int blockIndex);
void PrintHeaderInfo();
};
inline void Block::SetName(const string& name)
{
_name = name;
}
inline const string& Block::GetName() const
{
return _name;
}
inline string TableFile::GetFileName(void)
{
return _fileName;
}
inline eFileMode TableFile::GetFileMode(void)
{
return _fileMode;
}
inline Char::eCompareType TableFile::GetCaseSensitivity(void)
{
return(_caseSense);
}
inline unsigned int TableFile::GetStatusInd(void)
{
return _statusInd;
}
inline unsigned int TableFile::GetNumBlocks()
{
return _blocks.size();
}
inline string TableFile::RenameFirstBlock(const string& newBlockName)
{
return(RenameBlock(GetFirstBlockName(), newBlockName));
}
#endif // TABLEFILE_H
GenString.h
ISTable.h
Header file for ISTable class.
Serializer.h
eFileMode
eFileMode
Definition Serializer.h:34
READ_MODE
@ READ_MODE
Definition Serializer.h:36
Block
Public class that represents a data block, that contains tables.
Definition TableFile.h:41
Block::GetTable
ISTable & GetTable(const string &tableName)
Block::~Block
~Block()
Block::IsTablePresent
bool IsTablePresent(const string &tableName)
Block::SetName
void SetName(const string &name)
Definition TableFile.h:739
Block::Block
Block(const string &name, Serializer *serP, const eFileMode fileMode=READ_MODE, const Char::eCompareType caseSense=Char::eCASE_SENSITIVE)
Block::DeleteTable
void DeleteTable(const string &tableName)
Block::WriteTable
void WriteTable(ISTable *isTableP)
Block::GetTableNames
void GetTableNames(vector< string > &tableNames)
Block::AddTable
ISTable & AddTable(const std::string &name=string(), const Char::eCompareType colCaseSense=Char::eCASE_SENSITIVE)
Block::GetTablePtr
ISTable * GetTablePtr(const string &tableName)
Block::RenameTable
void RenameTable(const string &oldName, const string &newName)
Block::GetName
const string & GetName() const
Definition TableFile.h:745
Block::Print
void Print()
Block::WriteTable
void WriteTable(ISTable &isTable)
Block::AddTable
void AddTable(const string &name, const int indexInFile=0, ISTable *isTableP=NULL)
Block::_tables
mapped_ptr_vector< ISTable, StringLess > _tables
Definition TableFile.h:43
Block::operator==
vector< pair< string, ISTable::eTableDiff > > operator==(Block &inBlock)
Char::eCompareType
eCompareType
Definition GenString.h:27
Char::eCASE_SENSITIVE
@ eCASE_SENSITIVE
Definition GenString.h:28
ISTable
Public class that respresents a two-dimensional table of strings.
Definition ISTable.h:54
Serializer
Definition Serializer.h:44
TableFile
Public class that represents a file composed of blocks with tables.
Definition TableFile.h:362
TableFile::GetTotalNumTables
unsigned int GetTotalNumTables()
TableFile::_GetTablePtr
ISTable * _GetTablePtr(const unsigned int blockIndex, const unsigned int tableIndex)
TableFile::_blocks
mapped_ptr_vector< Block, StringLess > _blocks
Definition TableFile.h:701
TableFile::Close
void Close()
TableFile::~TableFile
virtual ~TableFile()
TableFile::_AddBlock
void _AddBlock(const string &blockName, Serializer *serP)
TableFile::IsBlockPresent
bool IsBlockPresent(const string &blockName)
TableFile::_fileName
string _fileName
Definition TableFile.h:691
TableFile::GetBlockNames
void GetBlockNames(vector< string > &blockNames)
TableFile::_f
Serializer * _f
Definition TableFile.h:703
TableFile::GetStatusInd
unsigned int GetStatusInd(void)
Definition TableFile.h:769
TableFile::_GetAllTables
void _GetAllTables()
TableFile::_SetStatusInd
void _SetStatusInd(const string &blockName)
TableFile::_ReadFileIndexVersion1
void _ReadFileIndexVersion1()
TableFile::GetFileMode
eFileMode GetFileMode(void)
Definition TableFile.h:757
TableFile::TableFile
TableFile(const Char::eCompareType caseSense=Char::eCASE_SENSITIVE)
TableFile::GetBlock
Block & GetBlock(const string &blockName)
TableFile::eStatusInd
eStatusInd
Definition TableFile.h:365
TableFile::eCLEAR_STATUS
@ eCLEAR_STATUS
Definition TableFile.h:366
TableFile::eDUPLICATE_BLOCKS
@ eDUPLICATE_BLOCKS
Definition TableFile.h:367
TableFile::eUNNAMED_BLOCKS
@ eUNNAMED_BLOCKS
Definition TableFile.h:368
TableFile::_ReadFileIndexVersion0
void _ReadFileIndexVersion0()
TableFile::_statusInd
unsigned int _statusInd
Definition TableFile.h:699
TableFile::GetSortedTablesIndices
void GetSortedTablesIndices(vector< unsigned int > &tablesIndices)
TableFile::AddBlock
string AddBlock(const string &blockName)
TableFile::GetTablesIndices
void GetTablesIndices(vector< unsigned int > &tablesIndices)
TableFile::GetFirstBlockName
string GetFirstBlockName()
TableFile::GetFileName
string GetFileName(void)
Definition TableFile.h:751
TableFile::TableFile
TableFile(const eFileMode fileMode, const string &fileName, const Char::eCompareType caseSense=Char::eCASE_SENSITIVE)
TableFile::RenameBlock
string RenameBlock(const string &oldBlockName, const string &newBlockName)
TableFile::RenameFirstBlock
string RenameFirstBlock(const string &newBlockName)
Definition TableFile.h:781
TableFile::GetCaseSensitivity
Char::eCompareType GetCaseSensitivity(void)
Definition TableFile.h:763
TableFile::_fileMode
eFileMode _fileMode
Definition TableFile.h:693
TableFile::GetTableNames
void GetTableNames(vector< string > &tableNames)
TableFile::_GetNumTablesInBlocks
void _GetNumTablesInBlocks(vector< UInt32 > &numTablesInBlocks)
TableFile::_ReadFileIndex
void _ReadFileIndex()
TableFile::Serialize
void Serialize(const string &fileName)
TableFile::_WriteFileIndex
void _WriteFileIndex(Serializer *serP, const vector< unsigned int > &tableLocs)
TableFile::_caseSense
Char::eCompareType _caseSense
Definition TableFile.h:696
TableFile::GetNumBlocks
unsigned int GetNumBlocks()
Definition TableFile.h:775
TableFile::Flush
void Flush()
mapped_ptr_vector
Definition mapped_ptr_vector.h:30
mapped_ptr_vector::size
unsigned int size() const
Definition mapped_ptr_vector.C:78
mapped_ptr_vector.C
mapped_ptr_vector.h
rcsb_types.h