USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::Table Class Reference

Class for storing Table blobs information. More...

#include <Table.h>

Inherits Isis::Blob.

Public Types

enum  Association { None, Samples, Lines, Bands }
 

Public Member Functions

 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 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.
 
QString Type () const
 Accessor method that returns a string containing the Blob type.
 
QString Name () const
 Accessor method that returns a string containing the Blob name.
 
int Size () const
 Accessor method that returns the number of bytes in the blob data.
 
PvlObjectLabel ()
 Accessor method that returns a PvlObject containing the Blob label.
 
void Read (const QString &file)
 This method reads Pvl values from a specified file.
 
void Read (const QString &file, const Pvl &pvlLabels)
 This method reads the given a file and labels.
 
virtual void Read (const Pvl &pvl, std::istream &is)
 This method reads the Blob data from an open input file stream.
 
void Write (const QString &file)
 Write the blob data out to a file.
 
void Write (Pvl &pvl, std::fstream &stm, const QString &detachedFileName="")
 Write the blob data out to a Pvl object.
 

Protected Member Functions

void ReadInit ()
 Virtual function to validate PVL table information.
 
void ReadData (std::istream &stream)
 Virtual function to Read the data.
 
void WriteInit ()
 Virtual Function to prepare labels for writing.
 
void WriteData (std::fstream &os)
 Virtual function to write the data.
 
void Find (const Pvl &pvl)
 This method searches the given Pvl for the Blob by the Blob's type and name.
 

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.
 
PvlObject p_blobPvl
 Pvl Blob object.
 
QString p_blobName
 Name of the Blob object.
 
char * p_buffer
 Buffer blob data is stored in.
 
BigInt p_startByte
 Byte blob data starts at in buffer.
 
int p_nbytes
 Size of blob data (in bytes)
 
QString p_type
 Type of data stored in the buffer.
 
QString p_detached
 Used for reading detached blobs.
 
QString p_labelFile
 The file containing the labels.
 

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

Author
2004-09-01 Jeff Anderson

Member Enumeration Documentation

Enumerator
None 
Samples 
Lines 
Bands 

Constructor & Destructor Documentation

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

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

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::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").

Parameters
tableNameName of the Table to be read

References None, and p_assoc.

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

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").

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 None, p_assoc, and Isis::Blob::Read().

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_recbufs, p_record, p_records, p_swap, and RecordSize().

Isis::Table::~Table ( )

Destroys the Table object.

References Clear().

Member Function Documentation

void Isis::Table::Clear ( )

Clear the table of all records.

References p_recbufs.

Referenced by ReadInit(), and ~Table().

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

Deletes a TableRecord from the Table.

Parameters
indexIndex of TableRecord to be deleted

References p_recbufs.

void Isis::Blob::Find ( const Pvl pvl)
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.

Parameters
pvlThe Pvl to be searched

References _FILEINFO_, Isis::PvlContainer::isNamed(), Isis::PvlObject::object(), Isis::PvlObject::objects(), and Isis::FileName::path().

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

References Bands, and p_assoc.

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

References Lines, and p_assoc.

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

References p_assoc, and Samples.

PvlObject & Isis::Blob::Label ( )
inherited

Accessor method that returns a PvlObject containing the Blob label.

Returns
PvlObject The label of the blob.

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

QString Isis::Blob::Name ( ) const
inherited

Accessor method that returns a string containing the Blob name.

Returns
string The name of the blob.

Referenced by Isis::Image::isFootprintable(), Isis::SpicePosition::LoadCache(), and Isis::Cube::write().

void Isis::Table::operator+= ( Isis::TableRecord rec)
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_recbufs, p_record, p_records, p_swap, and RecordSize().

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 p_recbufs, p_record, and Isis::TableRecord::Unpack().

void Isis::Blob::Read ( const QString &  file)
inherited

This method reads Pvl values from a specified file.

Parameters
fileThe filename to read from.
Exceptions
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::History::Read(), Isis::Cube::read(), and Table().

void Isis::Blob::Read ( const QString &  file,
const Pvl pvlLabels 
)
inherited

This method reads the given a file and labels.

Parameters
fileThe filename to read from.
pvlLabelsA Pvl containing the label information.
Exceptions
iException::Io- Unable to open file

References _FILEINFO_, and Isis::Message::FileOpen().

void Isis::Blob::Read ( const Pvl pvl,
std::istream &  istm 
)
virtualinherited

This method reads the Blob data from an open input file stream.

Parameters
pvlA Pvl containing the label information.
istmThe input file stream containing the blob data to be read.
Exceptions
iException::Io- Unable to open file

Reimplemented in Isis::History.

References _FILEINFO_, and Isis::Message::FileOpen().

void Isis::Table::ReadData ( std::istream &  stream)
protectedvirtual

Virtual function to Read the data.

Parameters
streamInputStream to read data in from
Exceptions
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().

int Isis::Table::RecordFields ( ) const

Returns the number of fields per record.

Returns
int Number of fields

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

int Isis::Table::RecordSize ( ) const

Returns the number of bytes per record.

Returns
int 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)

Sets the association to the input parameter.

Parameters
assocAssociation type

References p_assoc.

int Isis::Blob::Size ( ) const
inherited

Accessor method that returns the number of bytes in the blob data.

Returns
int Number of bytes in the blob data.

Referenced by Isis::BundleAdjust::Observations().

QString Isis::Blob::Type ( ) const
inherited

Accessor method that returns a string containing the Blob type.

Returns
string Type of blob.

Referenced by Isis::Image::isFootprintable(), and Isis::Cube::write().

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 p_recbufs, and Isis::TableRecord::Pack().

void Isis::Blob::Write ( const QString &  file)
inherited

Write the blob data out to a file.

Parameters
fileThe filename to write to.
Exceptions
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().

void Isis::Blob::Write ( Pvl pvl,
std::fstream &  stm,
const QString &  detachedFileName = "" 
)
inherited

Write the blob data out to a Pvl object.

Parameters
pvlThe pvl object to update
stmstream to write data to
detachedFileNameIf 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().

void Isis::Table::WriteData ( std::fstream &  os)
protectedvirtual

Virtual function to write the data.

Parameters
osOutputstream to write the data to

Reimplemented from Isis::Blob.

References p_recbufs, Records(), and RecordSize().

void Isis::Table::WriteInit ( )
protectedvirtual

Member Data Documentation

Association Isis::Table::p_assoc
protected
QString Isis::Blob::p_blobName
protectedinherited
PvlObject Isis::Blob::p_blobPvl
protectedinherited
QString Isis::Blob::p_detached
protectedinherited

Used for reading detached blobs.

Referenced by Isis::Blob::Blob(), and Isis::Blob::operator=().

QString Isis::Blob::p_labelFile
protectedinherited

The file containing the labels.

Referenced by Isis::Blob::Blob(), and Isis::Blob::operator=().

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

Buffers containing record values.

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

TableRecord Isis::Table::p_record
protected

The current table record.

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

int Isis::Table::p_records
protected

  Holds record count read from labels, may differ from

the size of p_recbufs.

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

BigInt Isis::Blob::p_startByte
protectedinherited

Byte blob data starts at in buffer.

Referenced by Isis::Blob::Blob(), Isis::Blob::operator=(), ReadData(), and Isis::ImagePolygon::ReadData().

bool Isis::Table::p_swap
protected

Only used for reading.

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

QString Isis::Blob::p_type
protectedinherited

Type of data stored in the buffer.

Referenced by Isis::Blob::Blob(), Isis::Blob::operator=(), and Isis::ImagePolygon::ReadData().


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