casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
casacore::ArrayQuantColumn< T > Class Template Reference

Provides read/write access to Array Quantum columns in Tables. More...

#include <ArrayQuantColumn.h>

Public Member Functions

 ArrayQuantColumn ()
 The default constructor creates a null object. More...
 
 ArrayQuantColumn (const Table &tab, const String &columnName)
 Create the ArrayQuantColumn from the supplied table and column name. More...
 
 ArrayQuantColumn (const Table &tab, const String &columnName, const Unit &)
 Create the ArrayQuantColumn from the supplied table and column name. More...
 
 ArrayQuantColumn (const Table &tab, const String &columnName, const Vector< Unit > &)
 
 ArrayQuantColumn (const ArrayQuantColumn< T > &that)
 Copy constructor (copy semantics). More...
 
 ~ArrayQuantColumn ()
 
void reference (const ArrayQuantColumn< T > &that)
 Make this object reference the column in "that". More...
 
Array< Quantum< T > > operator() (rownr_t rownr) const
 Return the quantum array stored in the specified row. More...
 
Array< Quantum< T > > operator() (rownr_t rownr, const Unit &) const
 Return the quantum array stored in the specified row, converted to the given unit. More...
 
Array< Quantum< T > > operator() (rownr_t rownr, const Vector< Unit > &) const
 Return the quantum array stored in the specified row, converted to the given units. More...
 
Array< Quantum< T > > operator() (rownr_t rownr, const Quantum< T > &other) const
 Return the quantum array stored in the specified row, converted to the unit in other. More...
 
void put (rownr_t rownr, const Array< Quantum< T > > &q)
 Put an array of quanta into the specified row of the table. More...
 
Bool isUnitVariable () const
 Test whether the Quantum column has variable units. More...
 
Vector< StringgetUnits () const
 Returns the column's units as a vector of strings. More...
 
Bool isNull () const
 Test if the object is null. More...
 
void throwIfNull () const
 Throw an exception if the object is null. More...
 
void attach (const Table &tab, const String &columnName)
 Attach a column to the object. More...
 
void attach (const Table &tab, const String &columnName, const Unit &)
 
void attach (const Table &tab, const String &columnName, const Vector< Unit > &)
 
void get (rownr_t rownr, Array< Quantum< T > > &q, Bool resize=False) const
 Get the quantum array in the specified row. More...
 
void get (rownr_t rownr, Array< Quantum< T > > &q, const Unit &, Bool resize=False) const
 Get the quantum array in the specified row. More...
 
void get (rownr_t rownr, Array< Quantum< T > > &q, const Vector< Unit > &, Bool resize=False) const
 Get the quantum array in the specified row. More...
 
void get (rownr_t rownr, Array< Quantum< T > > &q, const Quantum< T > &other, Bool resize=False) const
 Get the quantum array in the specified row. More...
 

Protected Member Functions

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

Protected Attributes

Vector< UnititsUnit
 

Private Member Functions

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

Private Attributes

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

Detailed Description

template<class T>
class casacore::ArrayQuantColumn< T >

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

The ArrayQuantColumn class is the array version of the ScalarQuantColumn 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 ArrayQuantColumn 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.
ArrayQuantColumn<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 119 of file ArrayQuantColumn.h.

Constructor & Destructor Documentation

template<class T>
casacore::ArrayQuantColumn< T >::ArrayQuantColumn ( )

The default constructor creates a null object.

It is useful for creating arrays of ArrayQuantColumn 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 ArrayQuantColumn object is null.

template<class T>
casacore::ArrayQuantColumn< T >::ArrayQuantColumn ( const Table tab,
const String columnName 
)

Create the ArrayQuantColumn from the supplied table and column name.

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

template<class T>
casacore::ArrayQuantColumn< T >::ArrayQuantColumn ( const Table tab,
const String columnName,
const Unit  
)

Create the ArrayQuantColumn 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>
casacore::ArrayQuantColumn< T >::ArrayQuantColumn ( const Table tab,
const String columnName,
const Vector< Unit > &   
)
template<class T>
casacore::ArrayQuantColumn< T >::ArrayQuantColumn ( const ArrayQuantColumn< T > &  that)

Copy constructor (copy semantics).

template<class T>
casacore::ArrayQuantColumn< T >::~ArrayQuantColumn ( )

Member Function Documentation

template<class T>
const ArrayColumn<String>* casacore::ArrayQuantColumn< T >::arrUnitsCol ( ) const
inlineprotected

Get access to itsUnitsCol.

Definition at line 222 of file ArrayQuantColumn.h.

template<class T>
void casacore::ArrayQuantColumn< 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.

template<class T>
void casacore::ArrayQuantColumn< T >::attach ( const Table tab,
const String columnName,
const Unit  
)
template<class T>
void casacore::ArrayQuantColumn< T >::attach ( const Table tab,
const String columnName,
const Vector< Unit > &   
)
template<class T>
void casacore::ArrayQuantColumn< T >::cleanUp ( )
private

Deletes allocated memory etc.

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

template<class T>
void casacore::ArrayQuantColumn< T >::get ( rownr_t  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 casacore::ArrayQuantColumn< T >::get ( rownr_t  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 casacore::ArrayQuantColumn< T >::get ( rownr_t  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 casacore::ArrayQuantColumn< T >::get ( rownr_t  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 casacore::ArrayQuantColumn< T >::getData ( rownr_t  rownr,
Array< Quantum< T > > &  q,
Bool  resize 
) const
private

Get the data without possible conversion.

template<class T>
Vector<String> casacore::ArrayQuantColumn< 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 casacore::ArrayQuantColumn< T >::init ( const Table tab,
const String columnName 
)
private

Initialize the ArrayQuantColumn from the specified table and column.

template<class T>
Bool casacore::ArrayQuantColumn< T >::isNull ( ) const
inline

Test if the object is null.

Definition at line 210 of file ArrayQuantColumn.h.

template<class T>
Bool casacore::ArrayQuantColumn< T >::isUnitVariable ( ) const
inline

Test whether the Quantum column has variable units.

Definition at line 202 of file ArrayQuantColumn.h.

template<class T>
Array<Quantum<T> > casacore::ArrayQuantColumn< T >::operator() ( rownr_t  rownr) const

Return the quantum array stored in the specified row.

template<class T>
Array<Quantum<T> > casacore::ArrayQuantColumn< T >::operator() ( rownr_t  rownr,
const Unit  
) const

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

template<class T>
Array<Quantum<T> > casacore::ArrayQuantColumn< T >::operator() ( rownr_t  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> > casacore::ArrayQuantColumn< T >::operator() ( rownr_t  rownr,
const Quantum< T > &  other 
) const

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

template<class T>
ArrayQuantColumn& casacore::ArrayQuantColumn< T >::operator= ( const ArrayQuantColumn< T > &  that)
private

Assignment makes no sense in a read only class.

Declaring this operator private makes it unusable.

template<class T>
Bool casacore::ArrayQuantColumn< T >::operator== ( const ArrayQuantColumn< T > &  that)
private

Comparison is not defined, since its semantics are unclear.

template<class T>
void casacore::ArrayQuantColumn< T >::put ( rownr_t  rownr,
const Array< Quantum< T > > &  q 
)

Put an array of quanta into the specified row of the table.

If the column supports variable units, the units are stored as well. Otherwise the quanta are converted to the column's units.

template<class T>
void casacore::ArrayQuantColumn< T >::reference ( const ArrayQuantColumn< T > &  that)

Make this object reference the column in "that".

template<class T>
const ScalarColumn<String>* casacore::ArrayQuantColumn< T >::scaUnitsCol ( ) const
inlineprotected

Definition at line 224 of file ArrayQuantColumn.h.

template<class T>
void casacore::ArrayQuantColumn< T >::throwIfNull ( ) const

Throw an exception if the object is null.

Member Data Documentation

template<class T>
ArrayColumn<String>* casacore::ArrayQuantColumn< T >::itsArrUnitsCol
private
template<class T>
Bool casacore::ArrayQuantColumn< T >::itsConvOut
private

Definition at line 239 of file ArrayQuantColumn.h.

template<class T>
ArrayColumn<T>* casacore::ArrayQuantColumn< T >::itsDataCol
private

Definition at line 231 of file ArrayQuantColumn.h.

Referenced by casacore::ArrayQuantColumn< Double >::isNull().

template<class T>
ScalarColumn<String>* casacore::ArrayQuantColumn< T >::itsScaUnitsCol
private
template<class T>
Vector<Unit> casacore::ArrayQuantColumn< T >::itsUnit
protected

Definition at line 218 of file ArrayQuantColumn.h.

template<class T>
Vector<Unit> casacore::ArrayQuantColumn< T >::itsUnitOut
private

Definition at line 237 of file ArrayQuantColumn.h.


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