casa::ROScalarMeasColumn< M > Class Template Reference
[TableMeasures]

#include <ScalarMeasColumn.h>

Inheritance diagram for casa::ROScalarMeasColumn< M >:

Inheritance graph
[legend]
Collaboration diagram for casa::ROScalarMeasColumn< M >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class M>
class casa::ROScalarMeasColumn< M >

Read only access to table scalar Measure columns.

Intended use:

Part of API

Review Status

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

Prerequisite

Synopsis

ROScalarMeasColumn and ScalarMeasColumn objects can be used to access Scalar Measure Columns in tables. The ROScalarMeasColumn provides read only access whereas the ScalarMeasColumn object can be used for writing and reading of Measures to and from a Table column.

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

The (RO)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);
    MDoppler::ROScalarMeasColumn dc(table, "DopplerCol");

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 ROScalarMeasColumn 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.isRefVariable()) {
           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::ROScalarMeasColumn timeColRead(tab, "Time1");
        for (i=0; i<tab.nrow(); i++) {
            cout << timeColRead(i) << endl;
        }

Motivation

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

Thrown Exceptions

Definition at line 147 of file ScalarMeasColumn.h.

Public Member Functions

 ROScalarMeasColumn ()
 The default constructor creates a null object.
 ROScalarMeasColumn (const Table &tab, const String &columnName)
 Create the ScalarMeasColumn from the table and column Name.
 ROScalarMeasColumn (const ROScalarMeasColumn< M > &that)
 Copy constructor (copy semantics).
virtual ~ROScalarMeasColumn ()
void reference (const ROScalarMeasColumn< 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.
const MeasRef< M > & getMeasRef () const
 Returns the column's fixed reference or the reference of the last read Measure if references are variable.
void get (uInt rownr, M &meas) const
 Get the Measure contained in the specified row.
operator() (uInt rownr) const
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

Protected Member Functions

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

Protected Attributes

MeasRef< M > itsMeasRef

Private Member Functions

ROScalarMeasColumnoperator= (const ROScalarMeasColumn< M > &that)
 Assignment makes no sense in a readonly class.
void cleanUp ()

Private Attributes

ROArrayColumn< Double > * itsArrDataCol
ROScalarColumn< Double > * itsScaDataCol
ROScalarColumn< Int > * itsRefIntCol
ROScalarColumn< String > * itsRefStrCol
ROScalarMeasColumn< M > * itsOffsetCol


Constructor & Destructor Documentation

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

The default constructor creates a null object.

Useful for creating arrays of ROScalarMeasColumn 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 ROScalarMeasColumn object can be tested if it is null by using the isNull() member.

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

Create the ScalarMeasColumn from the table and column Name.

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

Copy constructor (copy semantics).

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


Member Function Documentation

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

Change the reference to another column.

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

Attach a column to the object.

Reimplemented from casa::ROTableMeasColumn.

template<class M>
void casa::ROScalarMeasColumn< 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>
M casa::ROScalarMeasColumn< M >::operator() ( uInt  rownr  )  const

template<class M>
M casa::ROScalarMeasColumn< 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 181 of file ScalarMeasColumn.h.

Referenced by casa::ROScalarMeasColumn< casa::MFrequency >::convert().

template<class M>
M casa::ROScalarMeasColumn< 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::ROScalarMeasColumn< M >::convert ( uInt  rownr,
uInt  refCode 
) const

template<class M>
const MeasRef<M>& casa::ROScalarMeasColumn< 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 193 of file ScalarMeasColumn.h.

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

Make a MeasRef for the given row.

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

Assignment makes no sense in a readonly class.

Declaring this operator private makes it unusable.

template<class M>
void casa::ROScalarMeasColumn< M >::cleanUp (  )  [private]


Member Data Documentation

template<class M>
MeasRef<M> casa::ROScalarMeasColumn< M >::itsMeasRef [protected]

Definition at line 203 of file ScalarMeasColumn.h.

Referenced by casa::ROScalarMeasColumn< casa::MFrequency >::getMeasRef().

template<class M>
ROArrayColumn<Double>* casa::ROScalarMeasColumn< M >::itsArrDataCol [private]

Definition at line 209 of file ScalarMeasColumn.h.

template<class M>
ROScalarColumn<Double>* casa::ROScalarMeasColumn< M >::itsScaDataCol [private]

Definition at line 210 of file ScalarMeasColumn.h.

template<class M>
ROScalarColumn<Int>* casa::ROScalarMeasColumn< M >::itsRefIntCol [private]

Definition at line 212 of file ScalarMeasColumn.h.

template<class M>
ROScalarColumn<String>* casa::ROScalarMeasColumn< M >::itsRefStrCol [private]

Definition at line 213 of file ScalarMeasColumn.h.

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

Definition at line 216 of file ScalarMeasColumn.h.


The documentation for this class was generated from the following file:
Generated on Mon Sep 1 22:46:02 2008 for NRAOCASA by  doxygen 1.5.1