Isis 3 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 (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... | |
Table & | operator= (const Isis::Table &other) |
Sets the Table equal to the input Table object. More... | |
~Table () | |
Destroys the Table object. 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... | |
TableRecord & | operator[] (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... | |
QString | Type () const |
Accessor method that returns a string containing the Blob type. More... | |
QString | Name () const |
Accessor method that returns a string containing the Blob name. More... | |
int | Size () const |
Accessor method that returns the number of bytes in the blob data. More... | |
PvlObject & | Label () |
Accessor method that returns a PvlObject containing the Blob label. More... | |
void | Read (const QString &file) |
This method reads Pvl values from a specified file. More... | |
void | Read (const QString &file, const Pvl &pvlLabels) |
This method reads the given a file and labels. More... | |
virtual void | Read (const Pvl &pvl, std::istream &is) |
This method reads the Blob data from an open input file stream. More... | |
void | Write (const QString &file) |
Write the blob data out to a file. More... | |
void | Write (Pvl &pvl, std::fstream &stm, const QString &detachedFileName="") |
Write the blob data out to a Pvl object. More... | |
Static Public Member Functions | |
static QString | toString (Table table, QString fieldDelimiter=",") |
Protected Member Functions | |
void | ReadInit () |
Virtual function to validate PVL table information. More... | |
void | ReadData (std::istream &stream) |
Virtual function to Read the data. More... | |
void | WriteInit () |
Virtual Function to prepare labels for writing. More... | |
void | WriteData (std::fstream &os) |
Virtual function to write the data. More... | |
void | Find (const Pvl &pvl) |
This method searches the given Pvl for the Blob by the Blob's type and name. 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... | |
PvlObject | p_blobPvl |
Pvl Blob object. More... | |
QString | p_blobName |
Name of the Blob object. More... | |
char * | p_buffer |
Buffer blob data is stored in. More... | |
BigInt | p_startByte |
Byte blob data starts at in buffer. More... | |
int | p_nbytes |
Size of blob data (in bytes) More... | |
QString | p_type |
Type of data stored in the buffer. More... | |
QString | p_detached |
Used for reading detached blobs. More... | |
QString | p_labelFile |
The file containing the labels. More... | |
Friends | |
std::istream & | operator>> (std::istream &is, Table &table) |
std::ostream & | operator<< (std::ostream &os, Table &table) |
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. Isis3 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 | ( | 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(), Isis::TableRecord::Fields(), None, p_assoc, Isis::Blob::p_blobPvl, 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 None, p_assoc, and Isis::Blob::Read().
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 None, p_assoc, and Isis::Blob::Read().
Isis::Table::Table | ( | const Table & | other | ) |
void Isis::Table::Clear | ( | ) |
Clear the table of all records.
References p_recbufs.
Referenced by operator=(), ReadInit(), 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.
|
protectedinherited |
This method searches the given Pvl for the Blob by the Blob's type and name.
If found, the start byte, number of bytes are read from the Pvl. Also, if a keyword label pointer is found, the filename for the detached blob is stored and the pointer is removed from the blob pvl.
pvl | The Pvl to be searched |
References _FILEINFO_, Isis::PvlContainer::isNamed(), Isis::PvlObject::object(), Isis::PvlObject::objects(), and Isis::FileName::path().
bool Isis::Table::IsBandAssociated | ( | ) |
bool Isis::Table::IsLineAssociated | ( | ) |
bool Isis::Table::IsSampleAssociated | ( | ) |
|
inherited |
Accessor method that returns a PvlObject containing the Blob label.
Referenced by Isis::SpiceRotation::CacheLabel(), Isis::SpicePosition::LoadCache(), and Isis::SpiceRotation::LoadCache().
|
inherited |
Accessor method that returns a string containing the Blob name.
Referenced by Isis::Shape::isFootprintable(), Isis::Image::isFootprintable(), Isis::SpicePosition::LoadCache(), and Isis::Cube::write().
void Isis::Table::operator+= | ( | Isis::TableRecord & | rec | ) |
Adds a TableRecord to the Table.
rec | The record to be added to the table |
References _FILEINFO_, Isis::Blob::p_blobName, p_recbufs, Isis::TableRecord::Pack(), Isis::TableRecord::RecordSize(), 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_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().
|
inherited |
This method reads Pvl values from a specified file.
file | The filename to read from. |
iException::Io | - Unable to open file |
iException::Pvl | - Invalid label format |
References _FILEINFO_, and Isis::Pvl::read().
Referenced by Isis::History::History(), Isis::OriginalLabel::OriginalLabel(), Isis::OriginalXmlLabel::OriginalXmlLabel(), Isis::History::Read(), Isis::Cube::read(), and Table().
|
inherited |
This method reads the given a file and labels.
file | The filename to read from. |
pvlLabels | A Pvl containing the label information. |
iException::Io | - Unable to open file |
References _FILEINFO_, and Isis::Message::FileOpen().
|
virtualinherited |
This method reads the Blob data from an open input file stream.
pvl | A Pvl containing the label information. |
istm | The input file stream containing the blob data to be read. |
iException::Io | - Unable to open file |
Reimplemented in Isis::History.
References _FILEINFO_, and Isis::Message::FileOpen().
|
protectedvirtual |
Virtual function to Read the data.
stream | InputStream to read data in from |
Isis::IException::Io | - Error reading or preparing to read a record |
Reimplemented from Isis::Blob.
References _FILEINFO_, Isis::IException::Io, Isis::Blob::p_blobName, p_recbufs, p_record, p_records, Isis::Blob::p_startByte, p_swap, RecordSize(), Isis::TableRecord::Swap(), and Isis::toString().
|
protectedvirtual |
Virtual function to validate PVL table information.
Reimplemented from Isis::Blob.
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, p_assoc, Isis::Blob::p_blobPvl, p_record, p_records, p_swap, and Samples.
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::DawnVirCamera::DawnVirCamera(), Isis::ExportPdsTable::ExportPdsTable(), Isis::ProcessExportPds::ExportTable(), Isis::SpicePosition::LoadCache(), Isis::SpiceRotation::LoadCache(), Isis::RosettaVirtisCamera::RosettaVirtisCamera(), toString(), Isis::TrackingTable::TrackingTable(), WriteData(), and WriteInit().
int Isis::Table::RecordSize | ( | ) | const |
Returns the number of bytes per record.
References p_record, and Isis::TableRecord::RecordSize().
Referenced by operator+=(), operator=(), ReadData(), Table(), WriteData(), and WriteInit().
void Isis::Table::SetAssociation | ( | const Table::Association | assoc | ) |
|
inherited |
Accessor method that returns the number of bytes in the blob data.
|
static |
References Records(), and Isis::TableRecord::toString().
|
inherited |
Accessor method that returns a string containing the Blob type.
Referenced by Isis::Shape::isFootprintable(), Isis::Image::isFootprintable(), and Isis::Cube::write().
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, and Isis::TableRecord::Pack().
|
inherited |
Write the blob data out to a file.
file | The filename to write to. |
IException::Io | - Unable to open file |
IException::Io | - Error preparing to write data to file |
IException::Io | - Error creating file |
References _FILEINFO_, Isis::PvlObject::addObject(), Isis::PvlObject::findObject(), Isis::toString(), and Isis::Pvl::write().
Referenced by Isis::Cube::write().
|
inherited |
Write the blob data out to a Pvl object.
pvl | The pvl object to update |
stm | stream to write data to |
detachedFileName | If the stream is detached from the labels give the name of the file |
References Isis::PvlObject::addObject(), Isis::PvlContainer::name(), Isis::PvlObject::object(), Isis::PvlObject::objects(), and Isis::toString().
|
protectedvirtual |
Virtual function to write the data.
os | Outputstream to write the data to |
Reimplemented from Isis::Blob.
References p_recbufs, Records(), and RecordSize().
|
protectedvirtual |
Virtual Function to prepare labels for writing.
Reimplemented from Isis::Blob.
References Bands, Isis::ByteOrderName(), Isis::PvlContainer::deleteKeyword(), Isis::PvlObject::hasKeyword(), Isis::IsLsb(), Lines, Isis::Lsb, Isis::Msb, p_assoc, Isis::Blob::p_blobPvl, Isis::Blob::p_nbytes, Records(), RecordSize(), Samples, and Isis::toString().
|
friend |
|
friend |
|
protected |
Association Type of the table.
Referenced by IsBandAssociated(), IsLineAssociated(), IsSampleAssociated(), operator=(), ReadInit(), SetAssociation(), Table(), and WriteInit().
|
protectedinherited |
Name of the Blob object.
Referenced by Isis::Blob::Blob(), operator+=(), Isis::Blob::operator=(), ReadData(), and Isis::ImagePolygon::ReadData().
|
protectedinherited |
|
protectedinherited |
Buffer blob data is stored in.
Referenced by Isis::Blob::Blob(), Isis::GisBlob::GisBlob(), Isis::Blob::operator=(), Isis::OriginalXmlLabel::ReadData(), Isis::History::ReturnHist(), Isis::OriginalLabel::ReturnLabels(), Isis::GisBlob::setPolygon(), Isis::History::WriteInit(), and Isis::OriginalLabel::WriteInit().
|
protectedinherited |
Used for reading detached blobs.
Referenced by Isis::Blob::Blob(), and Isis::Blob::operator=().
|
protectedinherited |
The file containing the labels.
Referenced by Isis::Blob::Blob(), and Isis::Blob::operator=().
|
protectedinherited |
Size of blob data (in bytes)
Referenced by Isis::Blob::Blob(), Isis::GisBlob::GisBlob(), Isis::Blob::operator=(), Isis::OriginalXmlLabel::ReadData(), Isis::ImagePolygon::ReadData(), Isis::History::ReturnHist(), Isis::OriginalLabel::ReturnLabels(), Isis::GisBlob::setPolygon(), Isis::ImagePolygon::WriteData(), Isis::OriginalXmlLabel::WriteInit(), Isis::History::WriteInit(), Isis::OriginalLabel::WriteInit(), WriteInit(), and Isis::ImagePolygon::WriteInit().
|
protected |
Buffers containing record values.
Referenced by Clear(), Delete(), operator+=(), operator=(), operator[](), ReadData(), Records(), Table(), Update(), and WriteData().
|
protected |
The current table record.
Referenced by operator=(), operator[](), ReadData(), ReadInit(), RecordFields(), RecordSize(), and Table().
|
protected |
Holds record count read from labels, may differ from the size of p_recbufs.
Referenced by operator=(), ReadData(), ReadInit(), and Table().
|
protectedinherited |
Byte blob data starts at in buffer.
Referenced by Isis::Blob::Blob(), Isis::Blob::operator=(), ReadData(), and Isis::ImagePolygon::ReadData().
|
protected |
Only used for reading.
Referenced by operator=(), ReadData(), ReadInit(), and Table().
|
protectedinherited |
Type of data stored in the buffer.
Referenced by Isis::Blob::Blob(), Isis::Blob::operator=(), and Isis::ImagePolygon::ReadData().