casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
casa::ROArrayQuantColumn< T > Class Template Reference

Provides read-only access to Array Quantum columns in Tables. More...

#include <ArrayQuantColumn.h>

Inheritance diagram for casa::ROArrayQuantColumn< T >:
casa::ArrayQuantColumn< T >

List of all members.

Public Member Functions

 ROArrayQuantColumn ()
 The default constructor creates a null object.
 ROArrayQuantColumn (const Table &tab, const String &columnName)
 Create the ROArrayQuantColumn from the supplied table and column name.
 ROArrayQuantColumn (const Table &tab, const String &columnName, const Unit &)
 Create the ROArrayQuantColumn from the supplied table and column name.
 ROArrayQuantColumn (const Table &tab, const String &columnName, const Vector< Unit > &)
 ROArrayQuantColumn (const ROArrayQuantColumn< T > &that)
 Copy constructor (copy semantics).
 ~ROArrayQuantColumn ()
void reference (const ROArrayQuantColumn< T > &that)
 Make this object reference the column in "that".
Array< Quantum< T > > operator() (uInt rownr) const
 Return the quantum array stored in the specified row.
Array< Quantum< T > > operator() (uInt rownr, const Unit &) const
 Return the quantum array stored in the specified row, converted to the given unit.
Array< Quantum< T > > operator() (uInt rownr, const Vector< Unit > &) const
 Return the quantum array stored in the specified row, converted to the given units.
Array< Quantum< T > > operator() (uInt rownr, const Quantum< T > &other) const
 Return the quantum array stored in the specified row, converted to the unit in other.
Bool isUnitVariable () const
 Test whether the Quantum column has variable units.
Vector< StringgetUnits () const
 Returns the column's units as a vector of strings.
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 attach (const Table &tab, const String &columnName, const Vector< Unit > &)
void get (uInt rownr, Array< Quantum< T > > &q, Bool resize=False) const
 Get the quantum array in the specified row.
void get (uInt rownr, Array< Quantum< T > > &q, const Unit &, Bool resize=False) const
 Get the quantum array in the specified row.
void get (uInt rownr, Array< Quantum< T > > &q, const Vector< Unit > &, Bool resize=False) const
 Get the quantum array in the specified row.
void get (uInt rownr, Array< Quantum< T > > &q, const Quantum< T > &other, Bool resize=False) const
 Get the quantum array in the specified row.

Protected Member Functions

const ArrayColumn< String > * arrUnitsCol () const
 Get access to itsUnitsCol.
const ScalarColumn< String > * scaUnitsCol () const

Protected Attributes

Vector< UnititsUnit

Private Member Functions

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

Private Attributes

ArrayColumn< T > * itsDataCol
 
    

ArrayColumn< String > * itsArrUnitsCol
ScalarColumn< String > * itsScaUnitsCol
Vector< UnititsUnitOut
Bool itsConvOut

Detailed Description

template<class T>
class casa::ROArrayQuantColumn< T >

Provides read-only access to Array Quantum columns in Tables.

Intended use:

Public interface

Review Status

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

Prerequisite

Synopsis

The ROArrayQuantColumn class provides read-only access to quanta stored in a array 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 ROArrayQuantColumn object to be useful the column should contain Quanta. Inserting Quanta into a column requires the use of a ArrayQuantColumn object.

The ROArrayQuantColumn class is the array version of the ROScalarQuantColumn class.

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 ROArrayQuantColumn 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

(See TableQuantumDesc class for an example of how to define a Quantum column).

       // Create the column object with default units "deg".
       // It gets the quantum array from row 0 and prints it to stdout.
       ROArrayQuantColumn<Double> roaqCol(qtab, "ArrQuantDouble", "deg");
       cout << roaqCol(0) << endl;
       // This retrieves the same array with units converted to "m/s".  
       cout << roaqCol(0, "m/s") << endl;

Motivation

Add support for Quanta in the Tables system.

Thrown Exceptions

To Do

Definition at line 120 of file ArrayQuantColumn.h.


Constructor & Destructor Documentation

template<class T>
casa::ROArrayQuantColumn< T >::ROArrayQuantColumn ( )

The default constructor creates a null object.

It is useful for creating arrays of ROArrayQuantColumn objects. Attempting to use a null object will produce a segmentation fault so care needs to be taken to initialize 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 ROArrayQuantColumn object is null.

template<class T>
casa::ROArrayQuantColumn< T >::ROArrayQuantColumn ( const Table tab,
const String columnName 
)

Create the ROArrayQuantColumn from the supplied table and column name.

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

template<class T>
casa::ROArrayQuantColumn< T >::ROArrayQuantColumn ( const Table tab,
const String columnName,
const Unit  
)

Create the ROArrayQuantColumn from the supplied table and column name.

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

template<class T>
casa::ROArrayQuantColumn< T >::ROArrayQuantColumn ( const Table tab,
const String columnName,
const Vector< Unit > &   
)
template<class T>
casa::ROArrayQuantColumn< T >::ROArrayQuantColumn ( const ROArrayQuantColumn< T > &  that)

Copy constructor (copy semantics).

template<class T>
casa::ROArrayQuantColumn< T >::~ROArrayQuantColumn ( )

Member Function Documentation

template<class T>
const ArrayColumn<String>* casa::ROArrayQuantColumn< T >::arrUnitsCol ( ) const [inline, protected]

Get access to itsUnitsCol.

Definition at line 218 of file ArrayQuantColumn.h.

template<class T>
void casa::ROArrayQuantColumn< 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::ArrayQuantColumn< T >, casa::ArrayQuantColumn< Float >, and casa::ArrayQuantColumn< Double >.

template<class T>
void casa::ROArrayQuantColumn< T >::attach ( const Table tab,
const String columnName,
const Unit  
)
template<class T>
void casa::ROArrayQuantColumn< T >::attach ( const Table tab,
const String columnName,
const Vector< Unit > &   
)
template<class T>
void casa::ROArrayQuantColumn< T >::cleanUp ( ) [private]

Deletes allocated memory etc.

Called by ~tor and any member which needs to reallocate data.

Reimplemented in casa::ArrayQuantColumn< T >, casa::ArrayQuantColumn< Float >, and casa::ArrayQuantColumn< Double >.

template<class T>
void casa::ROArrayQuantColumn< T >::get ( uInt  rownr,
Array< Quantum< T > > &  q,
Bool  resize = False 
) const

Get the quantum array in the specified row.

 If resize is True the resulting array is resized if its shape
 is not correct. Otherwise a "conformance exception" is thrown
 if the array is not empty and its shape mismatches.

template<class T>
void casa::ROArrayQuantColumn< T >::get ( uInt  rownr,
Array< Quantum< T > > &  q,
const Unit ,
Bool  resize = False 
) const

Get the quantum array in the specified row.

Each quantum is converted to the given unit.

template<class T>
void casa::ROArrayQuantColumn< T >::get ( uInt  rownr,
Array< Quantum< T > > &  q,
const Vector< Unit > &  ,
Bool  resize = False 
) const

Get the quantum array in the specified row.

Each quantum is converted to the given units.

template<class T>
void casa::ROArrayQuantColumn< T >::get ( uInt  rownr,
Array< Quantum< T > > &  q,
const Quantum< T > &  other,
Bool  resize = False 
) const

Get the quantum array in the specified row.

Each quantum is converted to the unit in other.

template<class T>
void casa::ROArrayQuantColumn< T >::getData ( uInt  rownr,
Array< Quantum< T > > &  q,
Bool  resize 
) const [private]

Get the data without possible conversion.

template<class T>
Vector<String> casa::ROArrayQuantColumn< T >::getUnits ( ) const

Returns the column's units as a vector of strings.

An empty vector is returned if the column has no fixed units.

template<class T>
void casa::ROArrayQuantColumn< T >::init ( const Table tab,
const String columnName 
) [private]

Initialize the ROArrayQuantColumn from the specified table and column.

template<class T>
Bool casa::ROArrayQuantColumn< T >::isNull ( ) const [inline]

Test if the object is null.

Definition at line 206 of file ArrayQuantColumn.h.

template<class T>
Bool casa::ROArrayQuantColumn< T >::isUnitVariable ( ) const [inline]

Test whether the Quantum column has variable units.

Definition at line 198 of file ArrayQuantColumn.h.

template<class T>
Array<Quantum<T> > casa::ROArrayQuantColumn< T >::operator() ( uInt  rownr) const

Return the quantum array stored in the specified row.

template<class T>
Array<Quantum<T> > casa::ROArrayQuantColumn< T >::operator() ( uInt  rownr,
const Unit  
) const

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

template<class T>
Array<Quantum<T> > casa::ROArrayQuantColumn< T >::operator() ( uInt  rownr,
const Vector< Unit > &   
) const

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

template<class T>
Array<Quantum<T> > casa::ROArrayQuantColumn< T >::operator() ( uInt  rownr,
const Quantum< T > &  other 
) const

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

template<class T>
ROArrayQuantColumn& casa::ROArrayQuantColumn< T >::operator= ( const ROArrayQuantColumn< T > &  that) [private]

Assignment makes no sense in a read only class.

Declaring this operator private makes it unusable.

template<class T>
Bool casa::ROArrayQuantColumn< T >::operator== ( const ROArrayQuantColumn< T > &  that) [private]

Comparison is not defined, since its semantics are unclear.

template<class T>
void casa::ROArrayQuantColumn< T >::reference ( const ROArrayQuantColumn< T > &  that)

Make this object reference the column in "that".

template<class T>
const ScalarColumn<String>* casa::ROArrayQuantColumn< T >::scaUnitsCol ( ) const [inline, protected]

Definition at line 220 of file ArrayQuantColumn.h.

template<class T>
void casa::ROArrayQuantColumn< T >::throwIfNull ( ) const

Throw an exception if the object is null.


Member Data Documentation

template<class T>
ArrayColumn<String>* casa::ROArrayQuantColumn< T >::itsArrUnitsCol [private]
template<class T>
Bool casa::ROArrayQuantColumn< T >::itsConvOut [private]

Definition at line 235 of file ArrayQuantColumn.h.

template<class T>
ArrayColumn<T>* casa::ROArrayQuantColumn< T >::itsDataCol [private]
template<class T>
ScalarColumn<String>* casa::ROArrayQuantColumn< T >::itsScaUnitsCol [private]
template<class T>
Vector<Unit> casa::ROArrayQuantColumn< T >::itsUnit [protected]

Definition at line 214 of file ArrayQuantColumn.h.

template<class T>
Vector<Unit> casa::ROArrayQuantColumn< T >::itsUnitOut [private]

Definition at line 233 of file ArrayQuantColumn.h.


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