Isis Developer Reference
|
Class for storing Table blobs information. More...
#include <Table.h>
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. | |
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. | |
Table & | operator= (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. | |
PvlObject & | Label () |
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. | |
TableRecord & | operator[] (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. | |
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
Isis::Table::Table | ( | ) |
Isis::Table::Table | ( | Blob & | blob | ) |
References initFromBlob().
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").
tableName | Name of the Table to be read |
rec | Name of the TableRecord to be read into the Table |
References Isis::PvlObject::addGroup(), None, p_assoc, p_label, p_name, and p_record.
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").
tableName | Name of the Table to be read |
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").
References initFromBlob().
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").
tableName | The name of the Table to be read |
file | The name of the file to be read into the Table |
fileHeader | Pvl labels. |
References initFromBlob().
Isis::Table::Table | ( | const Table & | other | ) |
void Isis::Table::Clear | ( | ) |
Clear the table of all records.
References p_recbufs.
Referenced by initFromBlob(), operator=(), and ~Table().
void Isis::Table::Delete | ( | const int | index | ) |
Deletes a TableRecord from the Table.
index | Index of TableRecord to be deleted |
References p_recbufs.
|
protected |
Initialize a Table from a Blob that has been read from a file.
blob | The blob to extract the data for the Table from. |
References Bands, Isis::ByteOrderEnumeration(), Clear(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlObject::hasKeyword(), Isis::IsLsb(), Isis::IsMsb(), Isis::PvlContainer::isNamed(), Lines, Isis::Lsb, Isis::Msb, None, p_assoc, p_label, p_name, p_recbufs, p_record, p_records, p_swap, RecordSize(), Samples, and Isis::TableRecord::Swap().
bool Isis::Table::IsBandAssociated | ( | ) |
bool Isis::Table::IsLineAssociated | ( | ) |
bool Isis::Table::IsSampleAssociated | ( | ) |
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.
References p_label.
Referenced by Isis::SpiceRotation::CacheLabel(), Isis::SpicePosition::LoadCache(), and Isis::SpiceRotation::LoadCache().
QString Isis::Table::Name | ( | ) | const |
The Table's name.
References p_name.
Referenced by Isis::ExportPdsTable::exportTable(), Isis::ExportPdsTable::formatPdsTableName(), Isis::SpicePosition::LoadCache(), and toBlob().
void Isis::Table::operator+= | ( | Isis::TableRecord & | rec | ) |
Adds a TableRecord to the Table.
rec | The record to be added to the table |
References _FILEINFO_, p_name, p_recbufs, RecordSize(), Isis::toString(), and Isis::IException::Unknown.
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.
other | The table to copy from |
References Clear(), p_assoc, p_label, p_name, p_recbufs, p_record, p_records, p_swap, and RecordSize().
Isis::TableRecord & Isis::Table::operator[] | ( | const int | index | ) |
Reads a TableRecord from the Table.
index | Index where desired TableRecord is located |
References p_recbufs, p_record, and Isis::TableRecord::Unpack().
int Isis::Table::RecordFields | ( | ) | const |
Returns the number of fields per record.
References Isis::TableRecord::Fields(), and p_record.
int Isis::Table::Records | ( | ) | const |
Returns the number of records.
References p_recbufs.
Referenced by Isis::ExportPdsTable::exportTable(), Isis::SpicePosition::LoadCache(), Isis::SpiceRotation::LoadCache(), toBlob(), toString(), and Isis::TrackingTable::TrackingTable().
int Isis::Table::RecordSize | ( | ) | const |
Returns the number of bytes per record.
References p_record, and Isis::TableRecord::RecordSize().
Referenced by Isis::ExportPdsTable::ExportPdsTable(), initFromBlob(), operator+=(), operator=(), Table(), and toBlob().
void Isis::Table::SetAssociation | ( | const Table::Association | assoc | ) |
Blob Isis::Table::toBlob | ( | ) | const |
Serialze the Table to a Blob that can be written to a file.
References Isis::PvlContainer::addComment(), Bands, Isis::ByteOrderName(), Isis::PvlContainer::comment(), Isis::PvlContainer::comments(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::IsLsb(), Isis::PvlContainer::keywords(), Lines, Isis::Lsb, Isis::Msb, Isis::PvlContainer::name(), Name(), p_assoc, p_label, p_recbufs, Records(), RecordSize(), Samples, and Isis::toString().
Referenced by Write(), and Isis::Cube::write().
|
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.
table | The Table to serialize |
fieldDelimiter | The delimiter to use between fields |
References Records(), and Isis::TableRecord::toString().
void Isis::Table::Update | ( | const TableRecord & | rec, |
const int | index ) |
Updates a TableRecord.
rec | TableRecord to update old TableRecord with |
index | Index of TableRecord to be updated |
References p_recbufs.
void Isis::Table::Write | ( | const QString & | file | ) |
|
protected |
Association Type of the table.
Referenced by initFromBlob(), IsBandAssociated(), IsLineAssociated(), IsSampleAssociated(), operator=(), SetAssociation(), Table(), Table(), Table(), and toBlob().
|
protected |
The label for storing additional information.
Referenced by initFromBlob(), Label(), operator=(), Table(), Table(), and toBlob().
|
protected |
The name of the Table.
Referenced by initFromBlob(), Name(), operator+=(), operator=(), Table(), Table(), and Table().
|
protected |
Buffers containing record values.
Referenced by Clear(), Delete(), initFromBlob(), operator+=(), operator=(), operator[](), Records(), Table(), toBlob(), and Update().
|
protected |
The current table record.
Referenced by initFromBlob(), operator=(), operator[](), RecordFields(), RecordSize(), Table(), and Table().
|
protected |
Holds record count read from labels, may differ from the size of p_recbufs.
Referenced by initFromBlob(), operator=(), and Table().
|
protected |
Only used for reading.
Referenced by initFromBlob(), operator=(), and Table().