Loading...
Searching...
No Matches
casacore::ScalarQuantColumn< T > Class Template Reference
measures package (libcasa_measures) » TableMeasures_module

More...

`#include <ScalarQuantColumn.h>`

## Public Member Functions

| ScalarQuantColumn ()
| The default constructor creates a null object.
| ScalarQuantColumn (const Table &tab, const String &columnName)
| Create the ScalarQuantColumn from the specified table and column name.
| ScalarQuantColumn (const Table &tab, const String &columnName, const Unit &)
| Create the ScalarQuantColumn from the specified table and column name.
| 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 | attach (const Table &tab, const String &columnName, const Unit &)
void | get (rownr_t rownr, Quantum< T > &q) const
| Get the quantum stored in the specified row.
void | get (rownr_t rownr, Quantum< T > &q, const Unit &) const
| Get the quantum in the specified row, converted to the given unit.
void | get (rownr_t rownr, Quantum< T > &q, const Quantum< T > &other) const
| Get the quantum in the specified row, converted to the unit in other.
Quantum< T > | operator() (rownr_t rownr) const
| Return the quantum stored in the specified row.
Quantum< T > | operator() (rownr_t rownr, const Unit &) const
| Return the quantum stored in the specified row, converted to the given unit.
Quantum< T > | operator() (rownr_t rownr, const Quantum< T > &other) const
| Return the quantum in the specified row, converted to the unit in other.
void | put (rownr_t rownr, const Quantum< T > &q)
| Put a quantum into the table.
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.
std::shared_ptr< Quantum< Vector< T > > > | getColumn (const Unit &unit="") const
| Get the column as a Quantum<Vector<T> >.

## Protected Member Functions

const ScalarColumn< String > * | unitsCol () const
| Get access to itsUnitsCol.

## Protected Attributes

Unit | itsUnit

## Private Member Functions

ScalarQuantColumn & | operator= (const ScalarQuantColumn< T > &that)
| Assignment makes no sense in a read only class.
Bool | operator== (const ScalarQuantColumn< T > &that)
| Comparison is not defined, since its semantics are unclear.
void | init (const Table &tab, const String &columnName)
| Initialize the ScalarQuantColumn from the specified table and column.
void | cleanUp ()
| Deletes allocated memory etc.
void | getData (rownr_t rownr, Quantum< T > &q) const
| Get the data without possible conversion.

## Private Attributes

ScalarColumn< T > * | itsDataCol
ScalarColumn< String > * | itsUnitsCol
Unit | itsUnitOut
Bool | itsConvOut

## Detailed Description

template<class T>
class casacore::ScalarQuantColumn< T >

Provides access to Scalar Quantum Columns in Tables.

### Intended use:

Public interface

### Review Status

Reviewed By:
  Bob Garwood
Date Reviewed:
  1999/12/23
Test programs:
  tTableQuantum

### Prerequisite

- TableQuantumDesc
- Table
- ScalarColumn
- Quantum

### Synopsis

The ScalarQuantColumn class provides read/write 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 ScalarQuantColumn object to be useful the column should contain Quanta.

A ScalarQuantColumn object is used much in the same way as a ScalarColumn 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 ScalarQuantColumn 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.
ScalarQuantColumn<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);
}
casacore::QC::h
static const Quantum< Double > & h()
Planck.
Definition QC.h:180
casacore::Quantum
Definition Quantum.h:269
casacore::ScalarQuantColumn::ScalarQuantColumn
ScalarQuantColumn()
The default constructor creates a null object.

### Motivation

Add support for Quanta in the Tables system.

### Thrown Exceptions

- TableInvOper if the Table column is null.

### To Do

- Functions like getColumn

Definition at line 117 of file ScalarQuantColumn.h.

## Constructor & Destructor Documentation

## ScalarQuantColumn() [1/4]

template<class T>

casacore::ScalarQuantColumn< T >::ScalarQuantColumn | ( |  | ) |

The default constructor creates a null object.

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

Referenced by operator=(), operator==(), reference(), and ScalarQuantColumn().

## ScalarQuantColumn() [2/4]

template<class T>

casacore::ScalarQuantColumn< T >::ScalarQuantColumn | ( | const Table & | tab,
|  | const String & | columnName )

Create the ScalarQuantColumn from the specified table and column name.

The default unit for data retrieved is the unit in which they were stored.

## ScalarQuantColumn() [3/4]

template<class T>

casacore::ScalarQuantColumn< T >::ScalarQuantColumn | ( | const Table & | tab,
|  | const String & | columnName,
|  | const Unit & | )

Create the ScalarQuantColumn from the specified table and column name.

The default unit for data retrieved is the given unit (the data is converted as needed).

## ScalarQuantColumn() [4/4]

template<class T>

casacore::ScalarQuantColumn< T >::ScalarQuantColumn | ( | const ScalarQuantColumn< T > & | that | ) |

Copy constructor (copy semantics).

References ScalarQuantColumn().

## ~ScalarQuantColumn()

template<class T>

casacore::ScalarQuantColumn< T >::~ScalarQuantColumn | ( |  | ) |

## Member Function Documentation

## attach() [1/2]

template<class T>

void casacore::ScalarQuantColumn< 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.

## attach() [2/2]

template<class T>

void casacore::ScalarQuantColumn< T >::attach | ( | const Table & | tab,
|  | const String & | columnName,
|  | const Unit & | )

## cleanUp()

template<class T>

void casacore::ScalarQuantColumn< T >::cleanUp | ( |  | ) |

private

Deletes allocated memory etc.

Called by destructor and any member which needs to reallocate data.

## get() [1/3]

template<class T>

void casacore::ScalarQuantColumn< T >::get | ( | rownr_t | rownr,
|  | Quantum< T > & | q ) const

Get the quantum stored in the specified row.

## get() [2/3]

template<class T>

void casacore::ScalarQuantColumn< T >::get | ( | rownr_t | rownr,
|  | Quantum< T > & | q,
|  | const Quantum< T > & | other ) const

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

## get() [3/3]

template<class T>

void casacore::ScalarQuantColumn< T >::get | ( | rownr_t | rownr,
|  | Quantum< T > & | q,
|  | const Unit & | ) const

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

## getColumn()

template<class T>

std::shared_ptr< Quantum< Vector< T > > > casacore::ScalarQuantColumn< T >::getColumn | ( | const Unit & | unit = "" | ) | const

Get the column as a Quantum<Vector<T> >.

If unit is not empty, the returned Quantum will have that unit. Else if the units are variable, the values in the returned Vector have been converted to the unit of the 0th row entry. Otherwise, the units of the returned Quantum are the units specified in the column descriptor.

## getData()

template<class T>

void casacore::ScalarQuantColumn< T >::getData | ( | rownr_t | rownr,
|  | Quantum< T > & | q ) const

private

Get the data without possible conversion.

## getUnits()

template<class T>

const String & casacore::ScalarQuantColumn< 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 185 of file ScalarQuantColumn.h.

References itsUnit.

## init()

template<class T>

void casacore::ScalarQuantColumn< T >::init | ( | const Table & | tab,
|  | const String & | columnName )

private

Initialize the ScalarQuantColumn from the specified table and column.

## isNull()

template<class T>

Bool casacore::ScalarQuantColumn< T >::isNull | ( |  | ) | const

inline

Test if the object is null.

Definition at line 189 of file ScalarQuantColumn.h.

References itsDataCol.

## isUnitVariable()

template<class T>

Bool casacore::ScalarQuantColumn< T >::isUnitVariable | ( |  | ) | const

inline

Test whether the Quantum column has variable units.

Definition at line 180 of file ScalarQuantColumn.h.

References itsUnitsCol.

## operator()() [1/3]

template<class T>

Quantum< T > casacore::ScalarQuantColumn< T >::operator() | ( | rownr_t | rownr | ) | const

Return the quantum stored in the specified row.

## operator()() [2/3]

template<class T>

Quantum< T > casacore::ScalarQuantColumn< T >::operator() | ( | rownr_t | rownr,
|  | const Quantum< T > & | other ) const

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

## operator()() [3/3]

template<class T>

Quantum< T > casacore::ScalarQuantColumn< T >::operator() | ( | rownr_t | rownr,
|  | const Unit & | ) const

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

## operator=()

template<class T>

ScalarQuantColumn & casacore::ScalarQuantColumn< T >::operator= | ( | const ScalarQuantColumn< T > & | that | ) |

private

Assignment makes no sense in a read only class.

Declaring this operator private makes it unusable.

References ScalarQuantColumn().

## operator==()

template<class T>

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

private

Comparison is not defined, since its semantics are unclear.

References ScalarQuantColumn().

## put()

template<class T>

void casacore::ScalarQuantColumn< T >::put | ( | rownr_t | 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.

## reference()

template<class T>

void casacore::ScalarQuantColumn< T >::reference | ( | const ScalarQuantColumn< T > & | that | ) |

Change the reference to another column.

References ScalarQuantColumn().

## throwIfNull()

template<class T>

void casacore::ScalarQuantColumn< T >::throwIfNull | ( |  | ) | const

Throw an exception if the object is null.

## unitsCol()

template<class T>

const ScalarColumn< String > * casacore::ScalarQuantColumn< T >::unitsCol | ( |  | ) | const

inline protected

Get access to itsUnitsCol.

Definition at line 208 of file ScalarQuantColumn.h.

References itsUnitsCol.

## Member Data Documentation

## itsConvOut

template<class T>

Bool casacore::ScalarQuantColumn< T >::itsConvOut

private

Definition at line 219 of file ScalarQuantColumn.h.

## itsDataCol

template<class T>

ScalarColumn<T>* casacore::ScalarQuantColumn< T >::itsDataCol

private

Definition at line 213 of file ScalarQuantColumn.h.

Referenced by isNull().

## itsUnit

template<class T>

Unit casacore::ScalarQuantColumn< T >::itsUnit

protected

Definition at line 205 of file ScalarQuantColumn.h.

Referenced by getUnits().

## itsUnitOut

template<class T>

Unit casacore::ScalarQuantColumn< T >::itsUnitOut

private

Definition at line 217 of file ScalarQuantColumn.h.

## itsUnitsCol

template<class T>

ScalarColumn<String>* casacore::ScalarQuantColumn< T >::itsUnitsCol

private

Definition at line 215 of file ScalarQuantColumn.h.

Referenced by isUnitVariable(), and unitsCol().

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

- measures/TableMeasures/ScalarQuantColumn.h