TTable.h
Go to the documentation of this file.
//$$FILE$$
//$$VERSION$$
//$$DATE$$
//$$LICENSE$$
#ifndef TTABLE_H
#define TTABLE_H
#include <string>
#include <vector>
#include <rcsb/TableError.h>
#include <rcsb/Serializer.h>
#define TTABLE_COLUMN_DELETE_AS_REMOVE
class TTable
{
public:
TTable();
TTable(const TTable& inTable);
virtual ~TTable();
TTable& operator=(const TTable& inTable);
void Clear();
inline unsigned int GetNumTuples() const;
/* \todo Re-use much of the comment of InsertTuple() */
unsigned int AddTuple(const std::vector<std::string>& tuple =
std::vector<std::string>());
void InsertTuple(const unsigned int tupleIndex,
const std::vector<std::string>& tuple = std::vector<std::string>());
void InsertTuple(const unsigned int tupleIndex,
std::vector<std::string>::const_iterator tupleBeg,
std::vector<std::string>::const_iterator tupleEnd);
void FillTuple(const unsigned int tupleIndex,
const std::vector<std::string>& tuple,
const unsigned int fromColIndex = 0);
void GetTuple(std::vector<std::string>& tuple,
const unsigned int tupleIndex,
const unsigned int fromColIndex, unsigned int toColIndex);
const std::vector<std::string>& GetTuple(const unsigned int tupleIndex);
void ClearTuple(const unsigned int tupleIndex);
void DeleteTuple(const unsigned int tupleIndex);
inline unsigned int GetNumColumns() const;
unsigned int AddColumn(const std::vector<std::string>& col =
std::vector<std::string>());
unsigned int InsertColumn(const unsigned int atColIndex,
const std::vector<std::string>& col = std::vector<std::string>());
void InsertColumn(const unsigned int atColIndex,
std::vector<std::string>::const_iterator colBeg,
std::vector<std::string>::const_iterator colEnd);
void FillColumn(const unsigned int colIndex,
const std::vector<std::string>& col,
const unsigned int fromTupleIndex = 0);
void FillColumn(const unsigned int colIndex,
std::vector<std::string>::const_iterator colBeg,
std::vector<std::string>::const_iterator colEnd,
const unsigned int fromTupleIndex = 0);
void GetColumn(std::vector<std::string>& col, const unsigned int colIndex,
const unsigned int fromTupleIndex, unsigned int toTupleIndex);
void ClearColumn(const unsigned int colIndex);
void DeleteColumn(const unsigned int colIndex);
std::string& operator()(const unsigned int tupleIndex,
const unsigned int colIndex);
const std::string& operator()(const unsigned int tupleIndex,
const unsigned int colIndex) const;
int Write(Serializer* ser, unsigned int& size);
int Read(UInt32 index, Serializer* ser);
private:
unsigned int _numCols;
std::vector<std::vector<std::string>*> _tuples;
inline unsigned int IntColIndex(const unsigned int colIndex) const;
#ifndef TTABLE_COLUMN_DELETE_AS_REMOVE
unsigned int _numDelCols;
std::vector<unsigned int> _delColMap;
void EnlargeColMap(const unsigned int numCols);
void ReduceColMap(const unsigned int numCols);
void MarkColDeleted(const unsigned int colIndex);
void UnMarkColDeleted(const unsigned int colIndex);
#endif
};
std::ostream& operator<<(std::ostream& out, const TTable& sTable);
inline unsigned int TTable::GetNumTuples() const
{
return(_tuples.size());
}
inline unsigned int TTable::GetNumColumns() const
{
#ifndef TTABLE_COLUMN_DELETE_AS_REMOVE
return(_numCols - _numDelCols);
#else
return(_numCols);
#endif
}
inline unsigned int TTable::IntColIndex(const unsigned int colIndex) const
{
// Returns the TTable internal column index
#ifndef TTABLE_COLUMN_DELETE_AS_REMOVE
return(_delColMap[colIndex]);
#else
return(colIndex);
#endif
}
#endif // TTABLE_H
TTable::ClearColumn
void ClearColumn(const unsigned int colIndex)
TTable::InsertTuple
void InsertTuple(const unsigned int tupleIndex, const std::vector< std::string > &tuple=std::vector< std::string >())
UInt32
unsigned int UInt32
Definition: rcsb_types.h:15
TTable::Read
int Read(UInt32 index, Serializer *ser)
TTable::ClearTuple
void ClearTuple(const unsigned int tupleIndex)
TTable::Clear
void Clear()
TTable::GetNumColumns
unsigned int GetNumColumns() const
Definition: TTable.h:550
TTable::TTable
TTable()
TTable::Write
int Write(Serializer *ser, unsigned int &size)
TTable::operator=
TTable & operator=(const TTable &inTable)
TTable::InsertColumn
unsigned int InsertColumn(const unsigned int atColIndex, const std::vector< std::string > &col=std::vector< std::string >())
TTable::GetTuple
void GetTuple(std::vector< std::string > &tuple, const unsigned int tupleIndex, const unsigned int fromColIndex, unsigned int toColIndex)
TTable::DeleteTuple
void DeleteTuple(const unsigned int tupleIndex)
TTable::operator()
std::string & operator()(const unsigned int tupleIndex, const unsigned int colIndex)
TTable::AddColumn
unsigned int AddColumn(const std::vector< std::string > &col=std::vector< std::string >())
TTable::GetColumn
void GetColumn(std::vector< std::string > &col, const unsigned int colIndex, const unsigned int fromTupleIndex, unsigned int toTupleIndex)
Serializer
Definition: Serializer.h:43
TTable::DeleteColumn
void DeleteColumn(const unsigned int colIndex)
TTable::FillTuple
void FillTuple(const unsigned int tupleIndex, const std::vector< std::string > &tuple, const unsigned int fromColIndex=0)
TTable::GetNumTuples
unsigned int GetNumTuples() const
Definition: TTable.h:544
TTable::AddTuple
unsigned int AddTuple(const std::vector< std::string > &tuple=std::vector< std::string >())
Serializer.h
operator<<
std::ostream & operator<<(std::ostream &out, const TTable &sTable)
TableError.h
Utility file that is to be removed soon.
TTable
Private class that represents a table of tuples.
Definition: TTable.h:41
TTable::FillColumn
void FillColumn(const unsigned int colIndex, const std::vector< std::string > &col, const unsigned int fromTupleIndex=0)
TTable::~TTable
virtual ~TTable()