Isis 3 Programmer Reference
Isis::Table Class Reference

Class for storing Table blobs information. More...

#include <Table.h>

Collaboration diagram for Isis::Table:
Collaboration graph

Public Types

enum  Association { None , Samples , Lines , Bands }
 

Public Member Functions

 Table (Blob &blob)
 
 Table (const QString &tableName, TableRecord &rec)
 This constructor creates a new table using the given name and record.
 
 Table (const QString &tableName)
 This constructor creates an empty table from an existing table name to be read in when the Read() method is called.
 
 Table (const QString &tableName, const QString &file)
 This constructor reads an existing table using the given table name and file containing the table.
 
 Table (const QString &tableName, const QString &file, const Pvl &fileHeader)
 This constructor reads an existing table using the given table name and file containing the table and pvl labels.
 
 Table (const Table &other)
 Copy constructor for an Table object.
 
Tableoperator= (const Isis::Table &other)
 Sets the Table equal to the input Table object.
 
 ~Table ()
 Destroys the Table object.
 
void Write (const QString &file)
 Write the Table to a file.
 
QString Name () const
 The Table's name.
 
PvlObjectLabel ()
 The Table's label.
 
void SetAssociation (const Table::Association assoc)
 Sets the association to the input parameter.
 
bool IsSampleAssociated ()
 Checks to see if association is Samples.
 
bool IsLineAssociated ()
 Checks to see if association is Lines.
 
bool IsBandAssociated ()
 Checks to see if association is Bands.
 
int Records () const
 Returns the number of records.
 
int RecordFields () const
 Returns the number of fields per record.
 
int RecordSize () const
 Returns the number of bytes per record.
 
TableRecordoperator[] (const int index)
 Reads a TableRecord from the Table.
 
void operator+= (TableRecord &rec)
 Adds a TableRecord to the Table.
 
void Update (const TableRecord &rec, const int index)
 Updates a TableRecord.
 
void Delete (const int index)
 Deletes a TableRecord from the Table.
 
void Clear ()
 Clear the table of all records.
 
Blob toBlob () const
 Serialze the Table to a Blob that can be written to a file.
 

Static Public Member Functions

static QString toString (Table table, QString fieldDelimiter=",")
 Convert the data from a Table into a string.
 

Protected Member Functions

void initFromBlob (Blob &blob)
 Initialize a Table from a Blob that has been read from a file.
 

Protected Attributes

TableRecord p_record
 The current table record.
 
std::vector< char * > p_recbufs
 Buffers containing record values.
 
int p_records
 Holds record count read from labels, may differ from the size of p_recbufs.
 
Association p_assoc
 Association Type of the table.
 
bool p_swap
 Only used for reading.
 
QString p_name
 The name of the Table.
 
PvlObject p_label
 The label for storing additional information.
 

Detailed Description

Class for storing Table blobs information.

This class can create new Tables or read table blobs from files. In general, records correspond to rows and fields correspond to columns. Thus the TableRecord class corresponds to a vector of row entries and TableField class corresponds to a specific entry of the table for a given record. Isis Table objects are record based, N records in a table. Each record will have the same number of fields, F. The fields can be of different types including Integer, Double, Text, and Real. The class uses PVL to store the structure of the table N, F, and Field types and binary to store the table data.

See the classes TableRecord and TableField for more information.

If you would like to see Table being used in implementation, see histats.cpp

Author
2004-09-01 Jeff Anderson
History

2005-03-18 Elizabeth Ribelin - Added documentation to class

2006-09-19 Jeff Anderson - Added clear method

2006-09-19 Jeff Anderson - Fixed bug in ReadInit method which needed to cleanup pointers to records if a re-read occurred.

2009-02-18 Steven Lambright - Added copy constructor and assignment operator.

2011-05-25 Janet Barrett and Steven Lambright Added a Constructor that takes the pvl labels so they do not have to be re-read, which is a very expensive operation.

2012-10-04 Jeannie Backer Changed references to TableField methods to lower camel case. Ordered includes. Added documentation. Added error check to operator+=(TableRecord) if the Table's record size does not match the added TableRecord's size. Fixed header definition statement. Added forward declaration and includes. Fixed indentation of history entries. Moved method implementation to cpp file. Ordered includes in unitTest. Added RecordFields() accessor method. Improved test coverage in all categories. Added padding to control statements. References #1169.

2015-10-04 Jeannie Backer Improved coding standards. Uncommented error throw for operator+=(record) that verifies that the record sizes match. References #1178

2018-08-13 Summer Stapleton - Added a default constructor for logic relating to the overhaul of the mosaic tracking now being handled in a separate tracking cube.

Definition at line 61 of file Table.h.

Member Enumeration Documentation

◆ Association

enum Isis::Table::Association

Definition at line 66 of file Table.h.

Constructor & Destructor Documentation

◆ Table() [1/6]

Isis::Table::Table ( Blob & blob)

Definition at line 20 of file Table.cpp.

◆ Table() [2/6]

Isis::Table::Table ( const QString & tableName,
Isis::TableRecord & rec )

This constructor creates a new table using the given name and record.

Note that the record is not added to this table. It is used to read the TableField names and set the record size (i.e. the number of bytes per record). Thus any records added to this table will be required to match this size.

In this constructor, the Table::Association is set to None, the ByteOrder keyword in the labels is set to NULL, and the record information is added to the table.

This constructor also calls the parent constructor Blob(tableName, "Table").

Parameters
tableNameName of the Table to be read
recName of the TableRecord to be read into the Table

Definition at line 43 of file Table.cpp.

References Isis::PvlObject::addGroup(), p_assoc, p_label, p_name, and p_record.

◆ Table() [3/6]

Isis::Table::Table ( const QString & tableName)

This constructor creates an empty table from an existing table name to be read in when the Read() method is called.

It should not be used to construct a new table object whose data will be filled in later since the record size will be set to 0. This constructor sets the Table::Association to None.

This constructor also calls the parent constructor Blob(tableName, "Table").

Parameters
tableNameName of the Table to be read

Definition at line 67 of file Table.cpp.

References p_assoc, and p_name.

◆ Table() [4/6]

Isis::Table::Table ( const QString & tableName,
const QString & file )

This constructor reads an existing table using the given table name and file containing the table.

This constructor sets the Table::Association to the Association keyword value in the Blob Pvl read from the file, if the keyword exists.

This constructor also calls the parent constructor Blob(tableName, "Table").

Parameters
tableNameName of the Table to be read
fileName of the file to be read into the Table
See also
Blob::Read()

Definition at line 87 of file Table.cpp.

References initFromBlob().

◆ Table() [5/6]

Isis::Table::Table ( const QString & tableName,
const QString & file,
const Pvl & fileHeader )

This constructor reads an existing table using the given table name and file containing the table and pvl labels.

This constructor sets the Table::Association to the Association keyword value in the Blob Pvl read from the file, if the keyword exists.

This constructor also calls the parent constructor Blob(tableName, "Table").

Parameters
tableNameThe name of the Table to be read
fileThe name of the file to be read into the Table
fileHeaderPvl labels.
See also
Blob::Read()

Definition at line 108 of file Table.cpp.

References initFromBlob().

◆ Table() [6/6]

Isis::Table::Table ( const Table & other)

Copy constructor for an Table object.

This constructor copies TableRecords and the member variable values for record, records, assoc, and swap.

Parameters
otherThe table to copy from

Definition at line 121 of file Table.cpp.

References p_assoc, p_label, p_name, p_recbufs, p_record, p_records, p_swap, and RecordSize().

◆ ~Table()

Isis::Table::~Table ( )

Destroys the Table object.

Definition at line 224 of file Table.cpp.

References Clear().

Member Function Documentation

◆ Clear()

void Isis::Table::Clear ( )

Clear the table of all records.

Definition at line 403 of file Table.cpp.

References p_recbufs.

Referenced by initFromBlob(), operator=(), and ~Table().

◆ Delete()

void Isis::Table::Delete ( const int index)

Deletes a TableRecord from the Table.

Parameters
indexIndex of TableRecord to be deleted

Definition at line 392 of file Table.cpp.

References p_recbufs.

◆ initFromBlob()

void Isis::Table::initFromBlob ( Blob & blob)
protected

Initialize a Table from a Blob that has been read from a file.

Parameters
blobThe blob to extract the data for the Table from.

Definition at line 146 of file Table.cpp.

References Clear(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlObject::hasKeyword(), Isis::IsLsb(), Isis::IsMsb(), Isis::PvlContainer::isNamed(), p_assoc, p_label, p_name, p_recbufs, p_record, p_records, p_swap, RecordSize(), and Isis::TableRecord::Swap().

Referenced by Table(), and Table().

◆ IsBandAssociated()

bool Isis::Table::IsBandAssociated ( )

Checks to see if association is Bands.

Returns
bool Returns true if association is Bands, and false if it is not

Definition at line 303 of file Table.cpp.

References p_assoc.

◆ IsLineAssociated()

bool Isis::Table::IsLineAssociated ( )

Checks to see if association is Lines.

Returns
bool Returns true if association is Lines, and false if it is not

Definition at line 292 of file Table.cpp.

References p_assoc.

◆ IsSampleAssociated()

bool Isis::Table::IsSampleAssociated ( )

Checks to see if association is Samples.

Returns
bool Returns true if association is Samples, and false if it is not

Definition at line 281 of file Table.cpp.

References p_assoc.

◆ Label()

PvlObject & Isis::Table::Label ( )

The Table's label.

Additional information can be stored on the Table's label and will be serialized in the Blob's label when written out to a file.

Returns
PvlObject A reference to the label that can be modified

Definition at line 260 of file Table.cpp.

References p_label.

Referenced by Isis::SpicePosition::CacheLabel(), Isis::SpiceRotation::CacheLabel(), Isis::SpicePosition::LoadCache(), Isis::SpiceRotation::LoadCache(), and Isis::JigsawRunWidget::on_JigsawAcceptButton_clicked().

◆ Name()

QString Isis::Table::Name ( ) const

The Table's name.

Returns
QString the name of the Table

Definition at line 247 of file Table.cpp.

References p_name.

Referenced by Isis::ExportPdsTable::exportTable(), Isis::ExportPdsTable::formatPdsTableName(), Isis::SpicePosition::LoadCache(), Isis::ExportPdsTable::Pack(), and toBlob().

◆ operator+=()

void Isis::Table::operator+= ( Isis::TableRecord & rec)

Adds a TableRecord to the Table.

Parameters
recThe record to be added to the table

Definition at line 356 of file Table.cpp.

References p_name, p_recbufs, RecordSize(), Isis::toString(), and Isis::IException::Unknown.

◆ operator=()

Table & Isis::Table::operator= ( const Isis::Table & other)

Sets the Table equal to the input Table object.

This method copies TableRecords and the member variable values for record, records, assoc, and swap.

Parameters
otherThe table to copy from
Returns
Table The copied table.

Definition at line 200 of file Table.cpp.

References Clear(), p_assoc, p_label, p_name, p_recbufs, p_record, p_records, p_swap, and RecordSize().

◆ operator[]()

Isis::TableRecord & Isis::Table::operator[] ( const int index)

Reads a TableRecord from the Table.

Parameters
indexIndex where desired TableRecord is located
Returns
Returns the TableRecord at specific index

Definition at line 345 of file Table.cpp.

References p_recbufs, p_record, and Isis::TableRecord::Unpack().

◆ RecordFields()

int Isis::Table::RecordFields ( ) const

Returns the number of fields per record.

Returns
int Number of fields

Definition at line 323 of file Table.cpp.

References Isis::TableRecord::Fields(), and p_record.

Referenced by Isis::ExportPdsTable::fillMetaData().

◆ Records()

◆ RecordSize()

int Isis::Table::RecordSize ( ) const

Returns the number of bytes per record.

Returns
int Number of bytes per record

Definition at line 333 of file Table.cpp.

References p_record, and Isis::TableRecord::RecordSize().

Referenced by Isis::ExportPdsTable::ExportPdsTable(), initFromBlob(), operator+=(), operator=(), Table(), and toBlob().

◆ SetAssociation()

void Isis::Table::SetAssociation ( const Table::Association assoc)

Sets the association to the input parameter.

Parameters
assocAssociation type

Definition at line 270 of file Table.cpp.

References p_assoc.

◆ toBlob()

Blob Isis::Table::toBlob ( ) const

Serialze the Table to a Blob that can be written to a file.

Returns
Blob The Blob contaning the Table's data

Definition at line 414 of file Table.cpp.

References Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::IsLsb(), Isis::PvlContainer::keywords(), Isis::PvlContainer::name(), Name(), p_assoc, p_label, p_recbufs, Records(), RecordSize(), and Isis::toString().

Referenced by Write(), and Isis::Cube::write().

◆ toString()

QString Isis::Table::toString ( Table table,
QString fieldDelimiter = "," )
static

Convert the data from a Table into a string.

This method will convert all of the Table's records and fields into a string but will not serialze any label information. See TableRecord::toString for how the records are converted into a string.

Parameters
tableThe Table to serialize
fieldDelimiterThe delimiter to use between fields
Returns
QString The Table data as a string

Definition at line 480 of file Table.cpp.

References Records().

◆ Update()

void Isis::Table::Update ( const TableRecord & rec,
const int index )

Updates a TableRecord.

Parameters
recTableRecord to update old TableRecord with
indexIndex of TableRecord to be updated

Definition at line 382 of file Table.cpp.

References p_recbufs.

◆ Write()

void Isis::Table::Write ( const QString & file)

Write the Table to a file.

This uses a Blob to serialize the Table data, see Blob::Write.

Parameters
fileThe file to write the Table to.

Definition at line 236 of file Table.cpp.

References toBlob().

Member Data Documentation

◆ p_assoc

Association Isis::Table::p_assoc
protected

Association Type of the table.

Definition at line 131 of file Table.h.

Referenced by initFromBlob(), IsBandAssociated(), IsLineAssociated(), IsSampleAssociated(), operator=(), SetAssociation(), Table(), Table(), Table(), and toBlob().

◆ p_label

PvlObject Isis::Table::p_label
protected

The label for storing additional information.

Definition at line 135 of file Table.h.

Referenced by initFromBlob(), Label(), operator=(), Table(), Table(), and toBlob().

◆ p_name

QString Isis::Table::p_name
protected

The name of the Table.

Definition at line 134 of file Table.h.

Referenced by initFromBlob(), Name(), operator+=(), operator=(), Table(), Table(), and Table().

◆ p_recbufs

std::vector<char *> Isis::Table::p_recbufs
protected

Buffers containing record values.

Definition at line 126 of file Table.h.

Referenced by Clear(), Delete(), initFromBlob(), operator+=(), operator=(), operator[](), Records(), Table(), toBlob(), and Update().

◆ p_record

TableRecord Isis::Table::p_record
protected

The current table record.

Definition at line 125 of file Table.h.

Referenced by initFromBlob(), operator=(), operator[](), RecordFields(), RecordSize(), Table(), and Table().

◆ p_records

int Isis::Table::p_records
protected

Holds record count read from labels, may differ from the size of p_recbufs.

Definition at line 128 of file Table.h.

Referenced by initFromBlob(), operator=(), and Table().

◆ p_swap

bool Isis::Table::p_swap
protected

Only used for reading.

Definition at line 132 of file Table.h.

Referenced by initFromBlob(), operator=(), and Table().


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