ScalarQuantColumn.h

Classes

ROScalarQuantColumn -- Provides read-only access to Scalar Quantum Columns in Tables. (full description)
ScalarQuantColumn -- Provides read/write access to Scalar Quantum Columns in Tables. (full description)

template<class T> class ROScalarQuantColumn

Interface

Public Members
ROScalarQuantColumn()
ROScalarQuantColumn (const Table& tab, const String& columnName)
ROScalarQuantColumn (const Table& tab, const String& columnName, const Unit&)
ROScalarQuantColumn (const ROScalarQuantColumn<T>& that)
~ROScalarQuantColumn()
void reference (const ROScalarQuantColumn<T>& that)
void attach (const Table& tab, const String& columnName)
void attach (const Table& tab, const String& columnName, const Unit&)
void get (uInt rownr, Quantum<T>& q) const
void get (uInt rownr, Quantum<T>& q, const Unit&) const
void get (uInt rownr, Quantum<T>& q, const Quantum<T>& other) const
Quantum<T> operator() (uInt rownr) const
Quantum<T> operator() (uInt rownr, const Unit&) const
Quantum<T> operator() (uInt rownr, const Quantum<T>& other) const
Bool isUnitVariable() const
const String& getUnits() const
Bool isNull() const
void throwIfNull() const
Protected Members
const ROScalarColumn<String>* unitsCol() const
Private Members
ROScalarQuantColumn& operator= (const ROScalarQuantColumn<T>& that)
Bool operator== (const ROScalarQuantColumn<T>& that)
void init (const Table& tab, const String& columnName)
void cleanUp()
void getData (uInt rownr, Quantum<T>& q) const

Description

Review Status

Reviewed By:
Bob Garwood
Date Reviewed:
1999/12/23
Programs:
Tests:

Prerequisite

Synopsis

The ROScalarQuantColumn class provides read-only access to quanta stored in a scalar Quantum Table column. The Quantum column should already exist in the table and would have been defined by means of a TableQuantumDesc object. In addition, for a ROScalarQuantColumn object to be useful the column should contain Quanta. Inserting Quanta into a column requires the use of a ScalarQuantColumn object.

A ROScalarQuantColumn object is used much in the same way as a ROScalarColumn object.

Quantum Units

Quanta retrieved from the column will normally have the Unit that was specified when the Quantum column was defined. However, it is possible to override the default column Unit by supplying a Unit in the ROScalarQuantColumn constructor. When constructed in this fashion the retrieved Quanta will by default be retrieved in this unit, i.e. they will by default be converted to this unit.
By giving a unit (as a Unit or Quantum object) to a get function, the data can be retrieved in another unit than the default.

Example

     Quantum<Double> q(5.3, "keV");
     // "QuantScalar" has previously been defined as a Quantum column
     // by means of a TableQuantumDesc. This example assumes the column
     // already contains quanta.
     ROScalarQuantColumn<Double> qCol(qtab, "QuantScalar");
     // return and print quanta as stored in the column
     for (i = 0; i < qtab.nrow(); i++) {
         cout << qCol(i) << endl;
     }
     // The following retrieves and converts the quanta to GHz.  They
     // are then divided by the Quantum constant QC::h (Planck).
     for (i=0; i < qtab.nrow(); i++) {
         cout << (qCol(i, "GHz"))/(QC::h);
     }

Motivation

Add support for Quanta in the Tables system.

Thrown Exceptions

To Do

Member Description

ROScalarQuantColumn()

The default constructor creates a null object. It is useful for creating arrays of ROScalarQuantColumn objects. Attempting to use a null object will produce a segmentation fault so care needs to be taken to initialise the objects by using the attach() member before any attempt is made to use the object. The isNull() member can be used to test if a ROScalarQuantColumn object is null.

ROScalarQuantColumn (const Table& tab, const String& columnName)

Create the ROScalarQuantColumn from the specified table and column name. The default unit for data retrieved is the unit in which they were stored.

ROScalarQuantColumn (const Table& tab, const String& columnName, const Unit&)

Create the ROScalarQuantColumn from the specified table and column name. The default unit for data retrieved is the given unit (the data is converted as needed).

ROScalarQuantColumn (const ROScalarQuantColumn<T>& that)

Copy constructor (copy semantics).

~ROScalarQuantColumn()

void reference (const ROScalarQuantColumn<T>& that)

Change the reference to another column.

void attach (const Table& tab, const String& columnName)
void attach (const Table& tab, const String& columnName, const Unit&)

Attach a column to the object. Optionally supply a default unit which has the same meaning as the constructor unit argument.

void get (uInt rownr, Quantum<T>& q, const Unit&) const

Get the quantum stored in the specified row.

Get the quantum in the specified row, converted to the given unit.

void get (uInt rownr, Quantum<T>& q, const Quantum<T>& other) const

Get the quantum stored in the specified row.

Get the quantum in the specified row, converted to the unit in other.

void get (uInt rownr, Quantum<T>& q) const

Get the quantum stored in the specified row.

Quantum<T> operator() (uInt rownr, const Unit&) const

Return the quantum stored in the specified row.

Return the quantum stored in the specified row, converted to the given unit.

Quantum<T> operator() (uInt rownr, const Quantum<T>& other) const

Return the quantum stored in the specified row.

Return the quantum in the specified row, converted to the unit in other.

Quantum<T> operator() (uInt rownr) const

Return the quantum stored in the specified row.

Bool isUnitVariable() const

Test whether the Quantum column has variable units

const String& getUnits() const

Returns the column's value for Units as a string. An empty string is returned if the column has variable units.

Bool isNull() const

Test if the object is null.

void throwIfNull() const

Throw an exception if the object is null.

const ROScalarColumn<String>* unitsCol() const

Get access to itsUnitsCol.

ROScalarQuantColumn& operator= (const ROScalarQuantColumn<T>& that)

Assignment makes no sense in a read only class. Declaring this operator private makes it unusable.

Bool operator== (const ROScalarQuantColumn<T>& that)

Comparison is not defined, since its semantics are unclear.

void init (const Table& tab, const String& columnName)

Initialize the ROScalarQuantColumn from the specified table and column.

void cleanUp()

Deletes allocated memory etc. Called by destructor and any member which needs to reallocate data.

void getData (uInt rownr, Quantum<T>& q) const

Get the data without possible conversion.


template<class T> class ScalarQuantColumn : public ROScalarQuantColumn<T>

Interface

Public Members
ScalarQuantColumn()
ScalarQuantColumn (const Table& tab, const String& columnName)
ScalarQuantColumn (const ScalarQuantColumn<T>& that)
~ScalarQuantColumn()
void reference (const ScalarQuantColumn<T>& that)
void attach (const Table& tab, const String& columnName)
void put (uInt rownr, const Quantum<T>& q)
Private Members
ScalarQuantColumn& operator= (const ScalarQuantColumn<T>& that)
Bool operator== (const ScalarQuantColumn<T>& that)
void cleanUp()

Description

Review Status

Reviewed By:
Bob Garwood
Date Reviewed:
1999/12/23
Programs:
Tests:
  • tTableQuantum.cc

Prerequisite

Synopsis

The ScalarQuantColumn class provides read/write access to Quanta stored in a Quantum Table column. The column should previously have been defined as a Quantum column by means of the TableQuantumDesc object. In addition to the operations provided by its read-only partner, ROScalarQuantColumn, use of a ScalarQuantColumn object allows the insertion of Quanta into a column.

Quantum Units

The underlying Quantum column will have been defined to have either variable or fixed Units. If the Quantum column's Unit is fixed then writing quanta converts the data to that unit. If the column's unit is variable, the data is written unconverted and the unit is written into the unit column defined in the TableQuantumDesc object.

Example

     Quantum<Double> q(5.3, "keV");
     // "QuantScalar" has previously been defined as a Quantum column
     // by means of a TableQuantumDesc.
     ScalarQuantColumn<Double> qCol(qtab, "QuantScalar");
     for (uInt i=0; i < qtab.nrow(); i++) {
         qCol.put(i, q);
     }

Motivation

Add support for Quanta in the Tables system.

Thrown Exceptions

To Do

Member Description

ScalarQuantColumn()

The default constructor creates a null object. Useful for creating arrays of ScalarQuantColumn objects. Attempting to use a null object will produce a segmentation fault so care needs to be taken to initialise the objects by using the attach() member before any attempt is made to use the object. The isNull() member can be used to test if a ScalarQuantColumn object is null.

ScalarQuantColumn (const Table& tab, const String& columnName)

Create the ROScalarQuantColumn from the specified table and column name. The default unit for data retrieved is the unit in which they were stored.

ScalarQuantColumn (const ScalarQuantColumn<T>& that)

Copy constructor (copy semantics).

~ScalarQuantColumn()

void reference (const ScalarQuantColumn<T>& that)

Change the reference to another column.

void attach (const Table& tab, const String& columnName)

Attach a column to the object.

void put (uInt rownr, const Quantum<T>& q)

Put a quantum into the table. If the column supports variable units the q's unit is stored into the unit column defined in the TableQuantumDesc object. If units are fixed for the column, the quantum is converted as needed.

ScalarQuantColumn& operator= (const ScalarQuantColumn<T>& that)

Assignment facility offered via reference() member. Declaring this operator private makes it unusable.

Bool operator== (const ScalarQuantColumn<T>& that)

Comparison is not defined, since its semantics are unclear.

void cleanUp()

Deletes allocated memory etc. Called by destructor and any member which needs to reallocate data.