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

Read only access to table scalar Measure columns. More...

#include <ScalarMeasColumn.h>

Inheritance diagram for casa::ScalarMeasColumn< M >:
casa::TableMeasColumn

List of all members.

Public Member Functions

 ScalarMeasColumn ()
 The default constructor creates a null object.
 ScalarMeasColumn (const Table &tab, const String &columnName)
 Create the ScalarMeasColumn from the table and column Name.
 ScalarMeasColumn (const ScalarMeasColumn< M > &that)
 Copy constructor (copy semantics).
virtual ~ScalarMeasColumn ()
void reference (const ScalarMeasColumn< M > &that)
 Change the reference to another column.
void attach (const Table &tab, const String &columnName)
 Attach a column to the object.
convert (uInt rownr, const M &meas) const
 Get the Measure contained in the specified row and convert it to the reference and offset found in the given measure.
convert (uInt rownr, const MeasRef< M > &measRef) const
 Get the Measure contained in the specified row and convert it to the given reference.
convert (uInt rownr, uInt refCode) const
const MeasRef< M > & getMeasRef () const
 Returns the column's fixed reference or the reference of the last read Measure if references are variable.
void setDescRefCode (uInt refCode, Bool tableMustBeEmpty=True)
 Reset the refCode, offset, or units.
void setDescOffset (const Measure &offset, Bool tableMustBeEmpty=True)
void setDescUnits (const Vector< Unit > &units, Bool tableMustBeEmpty=True)
void get (uInt rownr, M &meas) const
 Get the Measure contained in the specified row.
operator() (uInt rownr) const
void put (uInt rownr, const M &meas)
 Put a Measure into the given row.

Protected Member Functions

MeasRef< M > makeMeasRef (uInt rownr) const
 Make a MeasRef for the given row.

Private Member Functions

ScalarMeasColumnoperator= (const ScalarMeasColumn< M > &that)
 Assignment makes no sense in a readonly class.
Bool equalRefs (const MRBase &r1, const MRBase &r2) const
 Check if refs have the same value (as opposed to being the same object).
void cleanUp ()

Private Attributes

Bool itsConvFlag
ArrayColumn< Double > * itsArrDataCol
ScalarColumn< Double > * itsScaDataCol
ScalarColumn< Int > * itsRefIntCol
ScalarColumn< String > * itsRefStrCol
ScalarMeasColumn< M > * itsOffsetCol
MeasRef< M > itsMeasRef

Detailed Description

template<class M>
class casa::ScalarMeasColumn< M >

Read only access to table scalar Measure columns.

Intended use:

Public interface

Review Status

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

Prerequisite

Synopsis

ScalarMeasColumn objects can be used to access scalar Measure Columns in tables, both for reading and writing (if the table is writable).

Before a column can be accessed it must have previously been defined as a Measure column by use of the TableMeasDesc object.

The ScalarMeasColumn class is templated on Measure type. Typedefs exist in the various Measure classes (e.g. MEpoch ) to make declaration less long winded. Constructing scalar Measure column objects using these typedefs looks like this:

    MEpoch::ScalarMeasColumn ec(table, "ColumnName);

Reading and writing Measures

The reading and writing of Measures columns is very similar to reading and writing of "ordinary" Table columns. get() and operator() exist for reading Measures and the put() member for adding Measures to a column. (put() is obviously not defined for ScalarMeasColumn objects.) Each of these members accepts a row number as an argument. The get() function gets the measure with the reference and offset as it is stored in the column. Furthermore the convert() function is available to get the measure with the given reference, possible offset, and possible frame

When a Measure is put, the reference and possible offset are converted if the measure column is defined with a fixed reference and/or offset. If the column's reference and offset are variable, the reference and offset of the measure as put are written into the appropriate reference and offset columns.

Example

        // This creates a Scalar MEpoch column for read/write access.  Column
        // "Time1" must exist in Table "tab" and must have previously been
        // defined as a MEpoch column using a TableMeasDesc.
        MEpoch::ScalarMeasColumn timeCol(tab, "Time1");
        
        // print some details about the column
        if (timeCol.measDesc().isRefCodeVariable()) {
           cout << "The column has variable references." << endl;
        } else {
            cout << "The fixed MeasRef for the column is: "
                << timeCol.getMeasRef() << endl;
        }
   
        // Add tab.nrow() measures to the column.       
        MEpoch tm(Quantity(MeasData::MJD2000, "d"), MEpoch::TAI);
        for (uInt i=0; i<tab.nrow(); i++) {
            timeCol.put(i, tm);
        }
   
        // We could read from the column using timeCol but instead a read
        // only column object is created.
        MEpoch::ScalarMeasColumn timeColRead(tab, "Time1");
        for (i=0; i<tab.nrow(); i++) {
            cout << timeColRead(i) << endl;
        }

Motivation

The standard Casacore Table system does not support Measures columns. This class overcomes this limitation.

Thrown Exceptions

Definition at line 142 of file ScalarMeasColumn.h.


Constructor & Destructor Documentation

template<class M>
casa::ScalarMeasColumn< M >::ScalarMeasColumn ( )

The default constructor creates a null object.

Useful for creating arrays of ScalarMeasColumn objects. Attempting to use a null object will produce a segmentation fault so care needs to be taken to initialize the objects first by using attach(). An ScalarMeasColumn object can be tested if it is null by using the isNull() member.

template<class M>
casa::ScalarMeasColumn< M >::ScalarMeasColumn ( const Table tab,
const String columnName 
)

Create the ScalarMeasColumn from the table and column Name.

template<class M>
casa::ScalarMeasColumn< M >::ScalarMeasColumn ( const ScalarMeasColumn< M > &  that)

Copy constructor (copy semantics).

template<class M>
virtual casa::ScalarMeasColumn< M >::~ScalarMeasColumn ( ) [virtual]

Member Function Documentation

template<class M>
void casa::ScalarMeasColumn< M >::attach ( const Table tab,
const String columnName 
)

Attach a column to the object.

Reimplemented from casa::TableMeasColumn.

template<class M>
void casa::ScalarMeasColumn< M >::cleanUp ( ) [private]
template<class M>
M casa::ScalarMeasColumn< M >::convert ( uInt  rownr,
const M &  meas 
) const [inline]

Get the Measure contained in the specified row and convert it to the reference and offset found in the given measure.

Definition at line 176 of file ScalarMeasColumn.h.

Referenced by casa::ScalarMeasColumn< MEpoch >::convert().

template<class M>
M casa::ScalarMeasColumn< M >::convert ( uInt  rownr,
const MeasRef< M > &  measRef 
) const

Get the Measure contained in the specified row and convert it to the given reference.

template<class M>
M casa::ScalarMeasColumn< M >::convert ( uInt  rownr,
uInt  refCode 
) const
template<class M>
Bool casa::ScalarMeasColumn< M >::equalRefs ( const MRBase r1,
const MRBase r2 
) const [private]

Check if refs have the same value (as opposed to being the same object).

template<class M>
void casa::ScalarMeasColumn< M >::get ( uInt  rownr,
M &  meas 
) const

Get the Measure contained in the specified row.

 It returns the Measure as found in the table.

template<class M>
const MeasRef<M>& casa::ScalarMeasColumn< M >::getMeasRef ( ) const [inline]

Returns the column's fixed reference or the reference of the last read Measure if references are variable.

Definition at line 188 of file ScalarMeasColumn.h.

template<class M>
MeasRef<M> casa::ScalarMeasColumn< M >::makeMeasRef ( uInt  rownr) const [protected]

Make a MeasRef for the given row.

template<class M>
M casa::ScalarMeasColumn< M >::operator() ( uInt  rownr) const
template<class M>
ScalarMeasColumn& casa::ScalarMeasColumn< M >::operator= ( const ScalarMeasColumn< M > &  that) [private]

Assignment makes no sense in a readonly class.

Declaring this operator private makes it unusable.

template<class M>
void casa::ScalarMeasColumn< M >::put ( uInt  rownr,
const M &  meas 
)

Put a Measure into the given row.

template<class M>
void casa::ScalarMeasColumn< M >::reference ( const ScalarMeasColumn< M > &  that)

Change the reference to another column.

template<class M>
void casa::ScalarMeasColumn< M >::setDescOffset ( const Measure offset,
Bool  tableMustBeEmpty = True 
)
template<class M>
void casa::ScalarMeasColumn< M >::setDescRefCode ( uInt  refCode,
Bool  tableMustBeEmpty = True 
)

Reset the refCode, offset, or units.

It overwrites the value used when defining the TableMeasDesc. Resetting the refCode and offset can only be done if they were defined as fixed in the description.
Tip: In principle the functions can only be used if the table is empty, otherwise already written values have thereafter the incorrect reference, offset, or unit; However, it is possible that part of the table is already written and that the entire measure column is filled in later; In that case the reference, offset, or units can be set by using a False tableMustBeEmpty argument;

template<class M>
void casa::ScalarMeasColumn< M >::setDescUnits ( const Vector< Unit > &  units,
Bool  tableMustBeEmpty = True 
)

Member Data Documentation

template<class M>
ArrayColumn<Double>* casa::ScalarMeasColumn< M >::itsArrDataCol [private]

Definition at line 226 of file ScalarMeasColumn.h.

template<class M>
Bool casa::ScalarMeasColumn< M >::itsConvFlag [private]

Definition at line 222 of file ScalarMeasColumn.h.

template<class M>
MeasRef<M> casa::ScalarMeasColumn< M >::itsMeasRef [private]

Definition at line 236 of file ScalarMeasColumn.h.

Referenced by casa::ScalarMeasColumn< MEpoch >::getMeasRef().

template<class M>
ScalarMeasColumn<M>* casa::ScalarMeasColumn< M >::itsOffsetCol [private]

Definition at line 233 of file ScalarMeasColumn.h.

template<class M>
ScalarColumn<Int>* casa::ScalarMeasColumn< M >::itsRefIntCol [private]

Definition at line 229 of file ScalarMeasColumn.h.

template<class M>
ScalarColumn<String>* casa::ScalarMeasColumn< M >::itsRefStrCol [private]

Definition at line 230 of file ScalarMeasColumn.h.

template<class M>
ScalarColumn<Double>* casa::ScalarMeasColumn< M >::itsScaDataCol [private]

Definition at line 227 of file ScalarMeasColumn.h.


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