USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::Table Class Reference
[Low Level Cube I/O]

#include <Table.h>

Inheritance diagram for Isis::Table:

Inheritance graph
[legend]
Collaboration diagram for Isis::Table:

Collaboration graph
[legend]
List of all members.

Detailed Description

Read table blobs.

This class reads table blobs from the cubes (or detached tables). It is 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, string, and double. See the classes TableRecord and TableField for more information. The class uses PVL to store the structure of the table N, F, and Field types and binary to store the table data.

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

Author:
2004-09-01 Jeff Anderson

For internal use only.

History:
2005-03-18 Elizabeth Ribelin - Added documentation to class
History:
2006-09-19 Jeff Anderson - Added clear method
History:
2006-09-19 Jeff Anderson - Fixed bug in ReadInit method which needed to cleanup pointers to records if a re-read occurred.
History:
2009-02-18 Steven Lambright - Added copy constructor and assignment operator.

Definition at line 57 of file Table.h.

Public Types

 None
 Samples
 Lines
 Bands
enum  Association { None, Samples, Lines, Bands }

Public Member Functions

 Table (const std::string &tableName)
 Constructor for reading a table.
 Table (const std::string &tableName, Isis::TableRecord &rec)
 Constructor for creating a table.
 Table (const std::string &tableName, const std::string &file)
 Constructor for reading a table.
 Table (const Table &other)
 Copy constructor for table.
 ~Table ()
 Destroys the Table object.
Isis::TableRecordoperator[] (const int index)
 Reads a TableRecord from the Table.
void operator+= (Isis::TableRecord &rec)
 Adds a TableRecord to the Table.
Tableoperator= (const Isis::Table &other)
void Update (const Isis::TableRecord &rec, const int index)
 Updates a TableRecord.
void Delete (const int index)
 Deletes a TableRecord from the Table.
int Records () const
 Returns the number of records.
int RecordSize () const
 Returns the number of bytes per record.
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.
void Clear ()
 Clear the table of all records.
void Read (const std::string &file)
 This reads Pvl values from a specified file.
virtual void Read (Isis::Pvl &pvl, std::fstream &is)
void Write (const std::string &file)
 Write the blob data out to a file.
void Write (Isis::Pvl &pvl, std::fstream &istm, const std::string &detachedFilename="")
 Write the blob data out to a Pvl object.
std::string Type () const
std::string Name () const
PvlObjectLabel ()

Protected Member Functions

void ReadInit ()
 Virtual function to validate PVL table information.
void ReadData (std::fstream &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 (Isis::Pvl &pvl)

Protected Attributes

Isis::TableRecord p_record
std::vector< char * > p_recbufs
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.
Isis::PvlObject p_blobPvl
 Pvl Blob object.
std::string 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).
std::string p_type
 Type of data stored in the buffer.
std::string p_detached
 Used for reading detached blobs.
std::string p_labelFile
 The file containing the labels.


Constructor & Destructor Documentation

Isis::Table::Table ( const std::string &  tableName  ) 

Constructor for reading a table.

Parameters:
tableName Name of the Table to be read

Definition at line 107 of file Table.cpp.

References p_assoc.

Isis::Table::Table ( const std::string &  tableName,
Isis::TableRecord rec 
)

Constructor for creating a table.

Parameters:
tableName Name of the Table to be read
rec Name of the TableRecord to be read into the Table

Definition at line 38 of file Table.cpp.

References Isis::PvlObject::AddGroup(), Isis::TableRecord::Fields(), p_assoc, Isis::Blob::p_blobPvl, and p_record.

Isis::Table::Table ( const std::string &  tableName,
const std::string &  file 
)

Constructor for reading a table.

Parameters:
tableName Name of the Table to be read
file Name of the file to be read into the Table

Definition at line 54 of file Table.cpp.

References p_assoc, and Isis::Blob::Read().

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

Copy constructor for table.

Parameters:
other The table to copy from

Definition at line 65 of file Table.cpp.

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

Isis::Table::~Table (  ) 

Destroys the Table object.

Definition at line 113 of file Table.cpp.

References Clear().


Member Function Documentation

void Isis::Table::Clear (  ) 

Clear the table of all records.

Definition at line 268 of file Table.cpp.

References p_recbufs.

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

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

Deletes a TableRecord from the Table.

Parameters:
index Index of TableRecord to be deleted

Definition at line 156 of file Table.cpp.

References p_recbufs.

bool Isis::Table::IsBandAssociated (  )  [inline]

Checks to see if association is Bands.

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

Definition at line 125 of file Table.h.

References p_assoc.

bool Isis::Table::IsLineAssociated (  )  [inline]

Checks to see if association is Lines.

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

Definition at line 118 of file Table.h.

References p_assoc.

bool Isis::Table::IsSampleAssociated (  )  [inline]

Checks to see if association is Samples.

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

Definition at line 111 of file Table.h.

References p_assoc.

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

Adds a TableRecord to the Table.

Parameters:
rec The record to be added to the table

Definition at line 134 of file Table.cpp.

References p_recbufs, Isis::TableRecord::Pack(), and RecordSize().

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

Reads a TableRecord from the Table.

Parameters:
index Index where desired TableRecord is located
Returns:
Returns the TableRecord at specific index

Definition at line 124 of file Table.cpp.

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

void Isis::Blob::Read ( const std::string &  file  )  [inherited]

This reads Pvl values from a specified file.

Parameters:
file The filename to read from.
Exceptions:
Isis::iException::Io - Unable to open file
Isis::iException::Pvl - Invalid label format

Definition at line 141 of file Blob.cpp.

References _FILEINFO_, e, Isis::Message::FileOpen(), in, Isis::iException::Message(), Isis::Blob::p_blobName, Isis::Blob::p_type, and pvl().

Referenced by Isis::Blob::Blob(), Isis::History::History(), Isis::OriginalLabel::OriginalLabel(), Isis::OriginalLabel::Read(), Isis::History::Read(), Isis::Cube::Read(), and Table().

void Isis::Table::ReadData ( std::fstream &  stream  )  [protected, virtual]

Virtual function to Read the data.

Parameters:
stream InputStream to read data in from
Exceptions:
Isis::iException::Io - Error reading or preparing to read a record

Reimplemented from Isis::Blob.

Definition at line 202 of file Table.cpp.

References _FILEINFO_, Isis::iException::Message(), Isis::Blob::p_blobName, p_recbufs, p_record, p_records, Isis::Blob::p_startByte, p_swap, RecordSize(), and Isis::TableRecord::Swap().

void Isis::Table::ReadInit (  )  [protected, virtual]

Virtual function to validate PVL table information.

Reimplemented from Isis::Blob.

Definition at line 164 of file Table.cpp.

References Isis::ByteOrderEnumeration(), Clear(), g, Isis::PvlObject::Group(), Isis::PvlObject::Groups(), Isis::PvlObject::HasKeyword(), Isis::IsLsb(), Isis::IsMsb(), Isis::PvlContainer::IsNamed(), p_assoc, Isis::Blob::p_blobPvl, p_record, p_records, and p_swap.

int Isis::Table::Records (  )  const [inline]

Returns the number of records.

Returns:
Number of records

Definition at line 86 of file Table.h.

References p_recbufs.

Referenced by Isis::SpicePosition::LoadCache(), Isis::Blobber::loadDouble(), Isis::Blobber::loadInteger(), Isis::Mex::HrscCamera::ReadLineRates(), WriteData(), and WriteInit().

int Isis::Table::RecordSize (  )  const [inline]

Returns the number of bytes per record.

Returns:
Number of bytes per record

Definition at line 93 of file Table.h.

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

Referenced by operator+=(), operator=(), ReadData(), Table(), WriteData(), and WriteInit().

void Isis::Table::SetAssociation ( const Table::Association  assoc  )  [inline]

Sets the association to the input parameter.

Parameters:
assoc Association type

Definition at line 102 of file Table.h.

References p_assoc.

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

Updates a TableRecord.

Parameters:
rec TableRecord to update old TableRecord with
index Index of TableRecord to be updated

Definition at line 147 of file Table.cpp.

References p_recbufs, and Isis::TableRecord::Pack().

void Isis::Blob::Write ( Isis::Pvl pvl,
std::fstream &  stm,
const std::string &  detachedFilename = "" 
) [inherited]

Write the blob data out to a Pvl object.

Parameters:
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

Definition at line 345 of file Blob.cpp.

References Isis::PvlContainer::DeleteKeyword(), Isis::PvlContainer::Name(), Isis::Blob::p_blobPvl, Isis::Blob::p_nbytes, Isis::Blob::p_type, pvl(), Isis::Blob::WriteData(), and Isis::Blob::WriteInit().

void Isis::Blob::Write ( const std::string &  file  )  [inherited]

Write the blob data out to a file.

Parameters:
file The filename to write to.
Exceptions:
Isis::iException::Io - Unable to open file
Isis::iException::Io - Error preparing to write data to file
Isis::iException::Io - Error creating file

Definition at line 296 of file Blob.cpp.

References _FILEINFO_, e, in, Isis::iException::Message(), Isis::Blob::p_blobName, Isis::Blob::p_blobPvl, Isis::Blob::p_nbytes, Isis::Blob::p_startByte, Isis::Blob::p_type, pvl(), Isis::Blob::WriteData(), and Isis::Blob::WriteInit().

Referenced by Isis::Cube::Write().

void Isis::Table::WriteData ( std::fstream &  os  )  [protected, virtual]

Virtual function to write the data.

Parameters:
os Outputstream to write the data to

Reimplemented from Isis::Blob.

Definition at line 259 of file Table.cpp.

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

void Isis::Table::WriteInit (  )  [protected, virtual]

Virtual Function to prepare labels for writing.

Reimplemented from Isis::Blob.

Definition at line 229 of file Table.cpp.

References Isis::ByteOrderName(), Isis::PvlContainer::DeleteKeyword(), Isis::PvlObject::HasKeyword(), Isis::IsLsb(), p_assoc, Isis::Blob::p_blobPvl, Isis::Blob::p_nbytes, Records(), and RecordSize().


Member Data Documentation

Association Isis::Table::p_assoc [protected]

Association Type of the table.

Definition at line 141 of file Table.h.

Referenced by IsBandAssociated(), IsLineAssociated(), IsSampleAssociated(), operator=(), ReadInit(), SetAssociation(), Table(), and WriteInit().

std::string Isis::Blob::p_blobName [protected, inherited]

Name of the Blob object.

Definition at line 72 of file Blob.h.

Referenced by Isis::Blob::Blob(), Isis::Blob::Find(), Isis::Blob::Name(), Isis::Blob::operator=(), Isis::Blob::Read(), ReadData(), Isis::ImagePolygon::ReadData(), Isis::Blob::ReadData(), Isis::Blob::Write(), and Isis::Blob::WriteData().

Isis::PvlObject Isis::Blob::p_blobPvl [protected, inherited]

Pvl Blob object.

Definition at line 71 of file Blob.h.

Referenced by Isis::Blob::Blob(), Isis::Blob::Find(), Isis::Blob::Label(), Isis::Blob::operator=(), ReadInit(), Table(), Isis::Blob::Write(), and WriteInit().

char* Isis::Blob::p_buffer [protected, inherited]

Buffer blob data is stored in.

Definition at line 74 of file Blob.h.

Referenced by Isis::Blob::Blob(), Isis::Blob::operator=(), Isis::Blob::ReadData(), Isis::History::ReturnHist(), Isis::OriginalLabel::ReturnLabels(), Isis::Blob::WriteData(), Isis::OriginalLabel::WriteInit(), Isis::History::WriteInit(), and Isis::Blob::~Blob().

std::string Isis::Blob::p_detached [protected, inherited]

Used for reading detached blobs.

Definition at line 78 of file Blob.h.

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

std::string Isis::Blob::p_labelFile [protected, inherited]

The file containing the labels.

Definition at line 79 of file Blob.h.

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

int Isis::Blob::p_nbytes [protected, inherited]

Size of blob data (in bytes).

Definition at line 76 of file Blob.h.

Referenced by Isis::Blob::Blob(), Isis::Blob::Find(), Isis::Blob::operator=(), Isis::ImagePolygon::ReadData(), Isis::Blob::ReadData(), Isis::History::ReturnHist(), Isis::OriginalLabel::ReturnLabels(), Isis::Blob::Write(), Isis::ImagePolygon::WriteData(), Isis::Blob::WriteData(), WriteInit(), Isis::OriginalLabel::WriteInit(), Isis::ImagePolygon::WriteInit(), and Isis::History::WriteInit().

int Isis::Table::p_records [protected]

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

Definition at line 138 of file Table.h.

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

BigInt Isis::Blob::p_startByte [protected, inherited]

Byte blob data starts at in buffer.

Definition at line 75 of file Blob.h.

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

bool Isis::Table::p_swap [protected]

Only used for reading.

Definition at line 142 of file Table.h.

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

std::string Isis::Blob::p_type [protected, inherited]

Type of data stored in the buffer.

Definition at line 77 of file Blob.h.

Referenced by Isis::Blob::Blob(), Isis::Blob::Find(), Isis::Blob::operator=(), Isis::Blob::Read(), Isis::ImagePolygon::ReadData(), Isis::Blob::ReadData(), Isis::Blob::Type(), Isis::Blob::Write(), and Isis::Blob::WriteData().


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