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

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

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

Member Enumeration Documentation

◆ Association

Enumerator
None 
Samples 
Lines 
Bands 

Constructor & Destructor Documentation

◆ Table() [1/7]

Isis::Table::Table ( )

◆ Table() [2/7]

Isis::Table::Table ( Blob blob)

◆ Table() [3/7]

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

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

◆ Table() [4/7]

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

References Isis::None.

◆ Table() [5/7]

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()

◆ Table() [6/7]

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()

References Isis::Blob::Read().

◆ Table() [7/7]

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

References p_assoc, p_label, p_name, p_recbufs, p_record, p_records, and p_swap.

◆ ~Table()

Isis::Table::~Table ( )

Destroys the Table object.

Member Function Documentation

◆ Clear()

void Isis::Table::Clear ( )

Clear the table of all records.

◆ Delete()

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

Deletes a TableRecord from the Table.

Parameters
indexIndex of TableRecord to be deleted

◆ 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.

References Isis::ByteOrderEnumeration(), Isis::Blob::getBuffer(), Isis::IsLsb(), Isis::IsMsb(), Isis::Blob::Label(), Isis::Lsb, Isis::Msb, and Isis::None.

◆ 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

◆ 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

◆ 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

◆ 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

Referenced by Isis::Cube::attachSpiceFromIsd(), Isis::SpiceRotation::CacheLabel(), Isis::SpicePosition::LoadCache(), and Isis::SpiceRotation::LoadCache().

◆ Name()

QString Isis::Table::Name ( ) const

The Table's name.

Returns
QString the name of the Table

Referenced by Isis::SpicePosition::LoadCache().

◆ operator+=()

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

Adds a TableRecord to the Table.

Parameters
recThe record to be added to the table

References _FILEINFO_, Isis::TableRecord::Pack(), Isis::TableRecord::RecordSize(), and Isis::toString().

◆ 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.

References p_assoc, p_label, p_name, p_recbufs, p_record, p_records, and p_swap.

◆ 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

References Isis::TableRecord::Unpack().

◆ RecordFields()

int Isis::Table::RecordFields ( ) const

Returns the number of fields per record.

Returns
int Number of fields

◆ Records()

◆ RecordSize()

int Isis::Table::RecordSize ( ) const

Returns the number of bytes per record.

Returns
int Number of bytes per record

◆ SetAssociation()

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

Sets the association to the input parameter.

Parameters
assocAssociation type

◆ toBlob()

Blob Isis::Table::toBlob ( ) const

◆ 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

References Records(), and Isis::toString().

◆ 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

References Isis::TableRecord::Pack().

◆ 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.

References Isis::Blob::Write().

Member Data Documentation

◆ p_assoc

Association Isis::Table::p_assoc
protected

Association Type of the table.

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

◆ p_label

PvlObject Isis::Table::p_label
protected

The label for storing additional information.

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

◆ p_name

QString Isis::Table::p_name
protected

The name of the Table.

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

◆ p_recbufs

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

Buffers containing record values.

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

◆ p_record

TableRecord Isis::Table::p_record
protected

The current table record.

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

◆ p_records

int Isis::Table::p_records
protected

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

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

◆ p_swap

bool Isis::Table::p_swap
protected

Only used for reading.

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


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