USGS

Isis 3.0 Object Programmers' Reference

Home

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

#include <Blobber.h>

Collaboration diagram for Isis::Blobber:

Collaboration graph
[legend]
List of all members.

Detailed Description

Base class for accessing ISIS blobs.

This class will read any ISIS BLOB and provide generalized access to its data. Developers can derive new classes that define access information in the form of names of the Isis Object and field name.

The entire contents of the field are read in and internally stored as double floating point values. All recognized ISIS special pixels are converted when read.

Note that this provides read access only. Currently, no output is performed in this implementation although it could be acheived in derived classes.

This class does not maintain persistant access to the BLOB. This means that the entire contents of the BLOB are read and stored and the interface to the ISIS BLOB is then terminated.

Below is an example using this class to access a HiRISE BLOB. It loads the BLOB, reports the number of lines and samples and then computes the mean and standard deviation using the Statistics class:

   Cube cube("hirise.cub");
   Blobber hiblob(cube, "HiRISE Calibration Image", "Calibration", 
                     "CalibrationImage");
   std::cout << "Number of lines:   " << hiblob.Lines() << std::endl;
   std::cout << "Number of samples: " << hiblob.Samples() << std::endl;
 
   Statistics stats;
   for (int line = 0 ; line < hiblob.Lines() ; line++) {
     stats.AddData(hiblob[line], hiblob.Samples());
   }
   
   std::cout << "Average: " << stats.Average() << std::endl;
   std::cout << "StdDev:  " << stats.StandardDeviation() << std::endl;

In the above example, the name of the ISIS Table (BLOB) is "HiRISE Calibration Image" and the field of interest in that table is "Calibration". Upon instantiation, the BLOB contents are read and converted to double precision floating point values.

Note that this class is reuseable and reentrant. This provides the user to specify a different cube to load the data from.

One special thing to note that assigning these objects to other object variables results in a reference to the data...it is not copied. The following illustrates this concept:

   Cube cube('hirise.cub');
   Blobber hiblob(cube, "HiRISE Calibration Image", "Calibration", 
                     "CalibrationImage");
 
   Blobber myblob(hiblob);
   Blobber blob2 = myblob;
In this example, hiblob, myblob and blob2 refer to the same blob data. Changing a pixel element in one blob results in the change in all instances of the blob. To get a completely independant copy of the data, use the deepcopy() method.

Author:
2005-12-16 Kris Becker

For internal use only.

History:
2008-05-12 Steven Lambright - Removed references to CubeInfo
History:
2008-06-18 Christopher Austin - Fixed documentation errors

Definition at line 106 of file Blobber.h.

Public Member Functions

 Blobber ()
 Default basic constructor that is mostly not useful.
 Blobber (const std::string &blobname, const std::string &fieldname, const std::string &name="Blob")
 Name-only based constructor.
 Blobber (Cube &cube, const std::string &blobname, const std::string &fieldname, const std::string &name="Blob")
 Constructor using an ISIS cube class.
virtual ~Blobber ()
 Destructor of this object.
Blobber deepcopy () const
 Create a unique copy of this blob.
void setName (const std::string &name)
 Specifies the name of this class instantiation.
void setBlobName (const std::string &bname)
 Sets the name of the ISIS BLOB object that contains the data.
void setFieldName (const std::string &fname)
 Sets field name in the ISIS BLOB object that contains data.
int size () const
 Returns the total number of elements (rows * columns) in blob.
int Lines () const
 Number of rows or lines in the BLOB.
int Samples () const
 Number of columns or samples in the BLOB.
std::string getName () const
 Returns the name of the BLOB given to refer to this instantiation.
std::string getBlobName () const
 Retrieves the name of the Table object.
std::string getFieldName () const
 Retreive the name of the field in the Tabel object BLOB.
double * operator[] (int i)
 Returns the ith row/line in the BLOB that can be further referenced into samples.
double const * operator[] (int i) const
 Returns the ith row/line in the BLOB that can be further referenced into samples.
void load (const std::string &filename)
 Loads the contents of a BLOB from a cube file.
void load (Cube &cube)
 Loads the contents of a BLOB from a Cube object.

Protected Types

typedef TNT::Array2D< double > BlobBuf
 Internal buffer uses TNT.

Protected Member Functions

const BlobBufref () const
 Returns a const reference to the internal buffer for ease of use to derived objects.

Private Member Functions

void loadDouble (Table &tbl)
 Provides direct reading in of the field data from the BLOB.
void loadInteger (Table &tbl)
 Provides direct reading in of the field data from the BLOB.
double int2ToDouble (int value) const
 Converts integer data to double precision.

Private Attributes

std::string _blobname
 Name of BLOB to read.
std::string _fieldname
 Name of field in BLOB to read.
std::string _name
 Name of this data set.
BlobBuf _buf
 Buffer holding data.


Member Typedef Documentation

typedef TNT::Array2D<double> Isis::Blobber::BlobBuf [protected]

Internal buffer uses TNT.

Definition at line 217 of file Blobber.h.


Constructor & Destructor Documentation

Blobber::Blobber (  ) 

Default basic constructor that is mostly not useful.

This basic constructor may only be required so that Blobbers can be used in STL constructs (as they require a default constructor)

Definition at line 42 of file Blobber.cpp.

Blobber::Blobber ( const std::string &  blobname,
const std::string &  fieldname,
const std::string &  name = "Blob" 
)

Name-only based constructor.

This constructor does not require an accompanying cube and allows the user to simply define the Table object and field names to establish these for multiple reads from different cubes.

Parameters:
[in] blobname (const std::string&) specifies the name of the ISIS BLOB that contains the field to read the data from
[in] fieldname (const std::string&) specifies the name of the field in blobname to read and convert to double precision floating point data
[in] name (const std::string&) Associates a name of the implementors choosing that identifies an instantiation of this class

Definition at line 62 of file Blobber.cpp.

Blobber::Blobber ( Cube cube,
const std::string &  blobname,
const std::string &  fieldname,
const std::string &  name = "Blob" 
)

Constructor using an ISIS cube class.

Reads the contents of the specified field (fieldname) from an ISIS table BLOB (blobname). Upon instatiation of this class, the BLOB data is read in and converted to double precision floating point data. Upon successful return from this construtor, the data is accessble through various methods.

Parameters:
[in] cube (Cube&) Reference to an ISIS cube file that has been opened or created in the Cube object. This file is expected to contain a Table object that is named blobname and must contain a field called fieldname.
[in] blobname (const std::string&) specifies the name of the ISIS BLOB that contains the field to read the data from
[in] fieldname (const std::string&) specifies the name of the field in blobname to read and convert to double precision floating point data
[in] name (const std::string&) Associates a name of the implementors choosing that identifies an instantiation of this class

Definition at line 91 of file Blobber.cpp.

References cube, and load().

virtual Isis::Blobber::~Blobber (  )  [inline, virtual]

Destructor of this object.

Definition at line 114 of file Blobber.h.


Member Function Documentation

Blobber Blobber::deepcopy (  )  const

Create a unique copy of this blob.

This method creates a fully new copy of this object. The default copy constructors/methods create a reference to the data read from the Table object. For example, the following code fragment will result in two Blobbers that refer to the same memory location that stores the BLOB data:

   Blobber myblob = yourblob;

To ensure you have two unique storage areas of the BLOB data so they can change independantly, use:

   Blobber myblob = yourblob.deepcopy();

Returns:
(Blobber) Returns a completely new copy, including data, to caller.

Definition at line 122 of file Blobber.cpp.

References _buf.

std::string Isis::Blobber::getBlobName (  )  const [inline]

Retrieves the name of the Table object.

Returns:
(string) Name of the Table

Definition at line 177 of file Blobber.h.

References _blobname.

std::string Isis::Blobber::getFieldName (  )  const [inline]

Retreive the name of the field in the Tabel object BLOB.

Returns:
(string) Name of the BLOB field

Definition at line 183 of file Blobber.h.

References _fieldname.

std::string Isis::Blobber::getName (  )  const [inline]

Returns the name of the BLOB given to refer to this instantiation.

Returns:
Name of BLOB instance

Definition at line 171 of file Blobber.h.

References _name.

double Blobber::int2ToDouble ( int  value  )  const [private]

Converts integer data to double precision.

This method lives to properly handle the conversion of integer BLOB data to double precision. We must properly convert integer special pixel data that may exist in the BLOB to its appropriate double precision value.

Parameters:
[in] value (int) Integer value to convert

Definition at line 229 of file Blobber.cpp.

References Isis::HIGH_INSTR_SAT2, Isis::HIGH_INSTR_SAT8, Isis::HIGH_REPR_SAT2, Isis::HIGH_REPR_SAT8, Isis::LOW_INSTR_SAT2, Isis::LOW_INSTR_SAT8, Isis::LOW_REPR_SAT2, Isis::LOW_REPR_SAT8, Isis::NULL2, and Isis::NULL8.

int Isis::Blobber::Lines (  )  const [inline]

Number of rows or lines in the BLOB.

Returns:
The lines or rows

Definition at line 160 of file Blobber.h.

References _buf.

Referenced by size().

void Blobber::load ( Cube cube  ) 

Loads the contents of a BLOB from a Cube object.

Provides the I/O interface for the Cube object. One thing to note here is that it creates a CubeInfo object from the Cube object and then calls the CubeInfo load method. Hence, this method is required as an intermediary method that cascades to the actual method that does the real work.

Parameters:
[in] cube (Cube&) Reference to an ISIS cube file that has been opened or created in the Cube object.

Definition at line 153 of file Blobber.cpp.

References _FILEINFO_, cube, Isis::TableField::IsDouble(), Isis::TableField::IsInteger(), and Isis::Cube::Read().

void Blobber::load ( const std::string &  filename  ) 

Loads the contents of a BLOB from a cube file.

Provides the I/O interface for ISIS cube files.

Parameters:
[in] filename (string&) Name of ISIS cube file to read

Definition at line 135 of file Blobber.cpp.

References cube, and Isis::Cube::Open().

Referenced by Blobber().

void Blobber::loadDouble ( Table tbl  )  [private]

Provides direct reading in of the field data from the BLOB.

This method is called when the data stored in the BLOB is double precision. It determines the number of rows (lines) and columns (samples) in the BLOB and allocates the internal buffer required to store it

Parameters:
[in] tbl (Table&) Reference to an ISIS Table object that contains the field from which to extract the data.

Definition at line 181 of file Blobber.cpp.

References d, and Isis::Table::Records().

void Blobber::loadInteger ( Table tbl  )  [private]

Provides direct reading in of the field data from the BLOB.

This method is called when the data stored in the BLOB is integer data. It determines the number of rows (lines) and columns (samples) in the BLOB and allocates the internal buffer required to store it. This differs from the double precision version only in the care taken when casting the data to double precision. We must properly convert special pixels from integer to double precision.

Parameters:
[in] tbl (Table&) Reference to an ISIS Table object that contains the field from which to extract the data.

Definition at line 207 of file Blobber.cpp.

References d, int2ToDouble(), and Isis::Table::Records().

double const* Isis::Blobber::operator[] ( int  i  )  const [inline]

Returns the ith row/line in the BLOB that can be further referenced into samples.

This method provides const access to the data in row matrix form. To access the 2nd sample in the 10th line use:

   double sample = blobber[9][1];

Parameters:
i Index
Returns:
Const pointer to the ith row in the BLOB

Definition at line 209 of file Blobber.h.

References _buf.

double* Isis::Blobber::operator[] ( int  i  )  [inline]

Returns the ith row/line in the BLOB that can be further referenced into samples.

To access the 2nd sample in the 10th line use:

   double sample = blobber[9][1];

Parameters:
i Index
Returns:
Pointer to the ith row in the BLOB

Definition at line 196 of file Blobber.h.

References _buf.

const BlobBuf& Isis::Blobber::ref (  )  const [inline, protected]

Returns a const reference to the internal buffer for ease of use to derived objects.

Returns:
Const reference to BLOB buffer

Definition at line 224 of file Blobber.h.

References _buf.

int Isis::Blobber::Samples (  )  const [inline]

Number of columns or samples in the BLOB.

Returns:
The number of samples or columns

Definition at line 165 of file Blobber.h.

References _buf.

Referenced by size().

void Isis::Blobber::setBlobName ( const std::string &  bname  )  [inline]

Sets the name of the ISIS BLOB object that contains the data.

This is name of a ISIS Table object that contains one or more fields that make up the BLOB. This is the value of the [i]Name[/i] keyword in the Table object.

Parameters:
bname Blobber name

Definition at line 138 of file Blobber.h.

References _blobname.

void Isis::Blobber::setFieldName ( const std::string &  fname  )  [inline]

Sets field name in the ISIS BLOB object that contains data.

This method sets the name of the field contained within the Table object BLOB from which the data is extracted.

Parameters:
fname Field name

Definition at line 148 of file Blobber.h.

References _fieldname.

void Isis::Blobber::setName ( const std::string &  name  )  [inline]

Specifies the name of this class instantiation.

This is just an additional name that can be used to identify instantiations of this class. It provides a way to uniquely identify each object.

Parameters:
name Unique name

Definition at line 127 of file Blobber.h.

References _name.

int Isis::Blobber::size (  )  const [inline]

Returns the total number of elements (rows * columns) in blob.

Returns:
The product of rows and columns

Definition at line 154 of file Blobber.h.

References Lines(), and Samples().


Member Data Documentation

std::string Isis::Blobber::_blobname [private]

Name of BLOB to read.

Definition at line 227 of file Blobber.h.

Referenced by getBlobName(), and setBlobName().

BlobBuf Isis::Blobber::_buf [private]

Buffer holding data.

Definition at line 230 of file Blobber.h.

Referenced by deepcopy(), Lines(), operator[](), ref(), and Samples().

std::string Isis::Blobber::_fieldname [private]

Name of field in BLOB to read.

Definition at line 228 of file Blobber.h.

Referenced by getFieldName(), and setFieldName().

std::string Isis::Blobber::_name [private]

Name of this data set.

Definition at line 229 of file Blobber.h.

Referenced by getName(), and setName().


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