casa
$Rev:20696$
|
Provides read-only access to Scalar Quantum Columns in Tables. More...
#include <ScalarQuantColumn.h>
Public Member Functions | |
ROScalarQuantColumn () | |
The default constructor creates a null object. | |
ROScalarQuantColumn (const Table &tab, const String &columnName) | |
Create the ROScalarQuantColumn from the specified table and column name. | |
ROScalarQuantColumn (const Table &tab, const String &columnName, const Unit &) | |
Create the ROScalarQuantColumn from the specified table and column name. | |
ROScalarQuantColumn (const ROScalarQuantColumn< T > &that) | |
Copy constructor (copy semantics). | |
~ROScalarQuantColumn () | |
void | reference (const ROScalarQuantColumn< T > &that) |
Change the reference to another column. | |
Quantum< T > | operator() (uInt rownr) const |
Return the quantum stored in the specified row. | |
Quantum< T > | operator() (uInt rownr, const Unit &) const |
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 in the specified row, converted to the unit in other. | |
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. | |
Bool | isNull () const |
Test if the object is null. | |
void | throwIfNull () const |
Throw an exception if the object is null. | |
void | attach (const Table &tab, const String &columnName) |
Attach a column to the object. | |
void | attach (const Table &tab, const String &columnName, const Unit &) |
void | get (uInt rownr, Quantum< T > &q) const |
Get the quantum stored in the specified row. | |
void | get (uInt rownr, Quantum< T > &q, const Unit &) const |
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 in the specified row, converted to the unit in other. | |
Protected Member Functions | |
const ScalarColumn< String > * | unitsCol () const |
Get access to itsUnitsCol. | |
Protected Attributes | |
Unit | itsUnit |
Private Member Functions | |
ROScalarQuantColumn & | operator= (const ROScalarQuantColumn< T > &that) |
Assignment makes no sense in a read only class. | |
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. | |
void | getData (uInt rownr, Quantum< T > &q) const |
Get the data without possible conversion. | |
Private Attributes | |
ScalarColumn< T > * | itsDataCol |
ScalarColumn< String > * | itsUnitsCol |
Unit | itsUnitOut |
Bool | itsConvOut |
Provides read-only access to Scalar Quantum Columns in Tables.
Public interface
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 ScalarColumn object.
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.
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); }
Add support for Quanta in the Tables system.
Definition at line 120 of file ScalarQuantColumn.h.
casa::ROScalarQuantColumn< T >::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.
casa::ROScalarQuantColumn< T >::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.
casa::ROScalarQuantColumn< T >::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).
casa::ROScalarQuantColumn< T >::ROScalarQuantColumn | ( | const ROScalarQuantColumn< T > & | that | ) |
Copy constructor (copy semantics).
casa::ROScalarQuantColumn< T >::~ROScalarQuantColumn | ( | ) |
void casa::ROScalarQuantColumn< T >::attach | ( | const Table & | tab, |
const String & | columnName | ||
) |
Attach a column to the object.
Optionally supply a default unit which has the same meaning as the constructor unit argument.
Reimplemented in casa::ScalarQuantColumn< T >, casa::ScalarQuantColumn< Float >, and casa::ScalarQuantColumn< Double >.
void casa::ROScalarQuantColumn< T >::attach | ( | const Table & | tab, |
const String & | columnName, | ||
const Unit & | |||
) |
void casa::ROScalarQuantColumn< T >::cleanUp | ( | ) | [private] |
Deletes allocated memory etc.
Called by destructor and any member which needs to reallocate data.
Reimplemented in casa::ScalarQuantColumn< T >, casa::ScalarQuantColumn< Float >, and casa::ScalarQuantColumn< Double >.
void casa::ROScalarQuantColumn< T >::get | ( | uInt | rownr, |
Quantum< T > & | q | ||
) | const |
void casa::ROScalarQuantColumn< T >::get | ( | uInt | rownr, |
Quantum< T > & | q, | ||
const Unit & | |||
) | const |
Get the quantum in the specified row, converted to the given unit.
void casa::ROScalarQuantColumn< T >::get | ( | uInt | rownr, |
Quantum< T > & | q, | ||
const Quantum< T > & | other | ||
) | const |
Get the quantum in the specified row, converted to the unit in other.
void casa::ROScalarQuantColumn< T >::getData | ( | uInt | rownr, |
Quantum< T > & | q | ||
) | const [private] |
Get the data without possible conversion.
const String& casa::ROScalarQuantColumn< T >::getUnits | ( | ) | const [inline] |
Returns the column's value for Units as a string.
An empty string is returned if the column has variable units.
Definition at line 182 of file ScalarQuantColumn.h.
void casa::ROScalarQuantColumn< T >::init | ( | const Table & | tab, |
const String & | columnName | ||
) | [private] |
Initialize the ROScalarQuantColumn from the specified table and column.
Bool casa::ROScalarQuantColumn< T >::isNull | ( | ) | const [inline] |
Test if the object is null.
Definition at line 186 of file ScalarQuantColumn.h.
Bool casa::ROScalarQuantColumn< T >::isUnitVariable | ( | ) | const [inline] |
Test whether the Quantum column has variable units.
Definition at line 177 of file ScalarQuantColumn.h.
Quantum<T> casa::ROScalarQuantColumn< T >::operator() | ( | uInt | rownr | ) | const |
Return the quantum stored in the specified row.
Quantum<T> casa::ROScalarQuantColumn< T >::operator() | ( | uInt | rownr, |
const Unit & | |||
) | const |
Return the quantum stored in the specified row, converted to the given unit.
Quantum<T> casa::ROScalarQuantColumn< T >::operator() | ( | uInt | rownr, |
const Quantum< T > & | other | ||
) | const |
Return the quantum in the specified row, converted to the unit in other.
ROScalarQuantColumn& casa::ROScalarQuantColumn< T >::operator= | ( | const ROScalarQuantColumn< T > & | that | ) | [private] |
Assignment makes no sense in a read only class.
Declaring this operator private makes it unusable.
Bool casa::ROScalarQuantColumn< T >::operator== | ( | const ROScalarQuantColumn< T > & | that | ) | [private] |
Comparison is not defined, since its semantics are unclear.
void casa::ROScalarQuantColumn< T >::reference | ( | const ROScalarQuantColumn< T > & | that | ) |
Change the reference to another column.
void casa::ROScalarQuantColumn< T >::throwIfNull | ( | ) | const |
Throw an exception if the object is null.
const ScalarColumn<String>* casa::ROScalarQuantColumn< T >::unitsCol | ( | ) | const [inline, protected] |
Get access to itsUnitsCol.
Definition at line 197 of file ScalarQuantColumn.h.
Bool casa::ROScalarQuantColumn< T >::itsConvOut [private] |
Definition at line 208 of file ScalarQuantColumn.h.
ScalarColumn<T>* casa::ROScalarQuantColumn< T >::itsDataCol [private] |
Reimplemented in casa::ScalarQuantColumn< T >, casa::ScalarQuantColumn< Float >, and casa::ScalarQuantColumn< Double >.
Definition at line 202 of file ScalarQuantColumn.h.
Referenced by casa::ROScalarQuantColumn< Double >::isNull().
Unit casa::ROScalarQuantColumn< T >::itsUnit [protected] |
Definition at line 194 of file ScalarQuantColumn.h.
Referenced by casa::ROScalarQuantColumn< Double >::getUnits().
Unit casa::ROScalarQuantColumn< T >::itsUnitOut [private] |
Definition at line 206 of file ScalarQuantColumn.h.
ScalarColumn<String>* casa::ROScalarQuantColumn< T >::itsUnitsCol [private] |
Reimplemented in casa::ScalarQuantColumn< T >, casa::ScalarQuantColumn< Float >, and casa::ScalarQuantColumn< Double >.
Definition at line 204 of file ScalarQuantColumn.h.
Referenced by casa::ROScalarQuantColumn< Double >::isUnitVariable(), and casa::ROScalarQuantColumn< Double >::unitsCol().