casacore
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::ScalarMeasColumn< M > Class Template Reference

More...

#include <ScalarMeasColumn.h>

Public Member Functions

 ScalarMeasColumn ()
 The default constructor creates a null object. More...
 
 ScalarMeasColumn (const Table &tab, const String &columnName)
 Create the ScalarMeasColumn from the table and column Name. More...
 
 ScalarMeasColumn (const ScalarMeasColumn< M > &that)
 Copy constructor (copy semantics). More...
 
virtual ~ScalarMeasColumn ()
 
void reference (const ScalarMeasColumn< M > &that)
 Change the reference to another column. More...
 
void attach (const Table &tab, const String &columnName)
 Attach a column to the object. More...
 
void get (rownr_t rownr, M &meas) const
 Get the Measure contained in the specified row. More...
 
operator() (rownr_t rownr) const
 
convert (rownr_t 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. More...
 
convert (rownr_t rownr, const MeasRef< M > &measRef) const
 Get the Measure contained in the specified row and convert it to the given reference. More...
 
convert (rownr_t 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. More...
 
void setDescRefCode (uInt refCode, Bool tableMustBeEmpty=True)
 Reset the refCode, offset, or units. More...
 
void setDescOffset (const Measure &offset, Bool tableMustBeEmpty=True)
 
void setDescUnits (const Vector< Unit > &units, Bool tableMustBeEmpty=True)
 
void put (rownr_t rownr, const M &meas)
 Put a Measure into the given row. More...
 
- Public Member Functions inherited from casacore::TableMeasColumn
 TableMeasColumn ()
 The default constructor creates a null object. More...
 
 TableMeasColumn (const Table &tab, const String &columnName)
 Create the ScalarMeasColumn from the table and column Name. More...
 
 TableMeasColumn (const TableMeasColumn &that)
 Copy constructor (copy semantics). More...
 
virtual ~TableMeasColumn ()
 
void reference (const TableMeasColumn &that)
 Change the reference to another column. More...
 
void attach (const Table &tab, const String &columnName)
 Attach another column to the object. More...
 
Bool isDefined (rownr_t rownr) const
 Tests if a row contains a Measure (i.e., if the row has a defined value). More...
 
const TableMeasDescBasemeasDesc () const
 Get access to the TableMeasDescBase describing the column. More...
 
TableMeasDescBasemeasDesc ()
 
Bool isNull () const
 Test if the object is null. More...
 
void throwIfNull () const
 Throw an exception if the object is null. More...
 
const StringcolumnName () const
 Get the name of the column. More...
 
Table table () const
 Get the Table object this column belongs to. More...
 
Bool isScalar () const
 Is the column a scalar measures column? It is if the underlying column is a scalar column or an array column with a fixed 1-dimensional shape. More...
 

Protected Member Functions

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

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Protected Attributes inherited from casacore::TableMeasColumn
uInt itsNvals
 
CountedPtr< TableMeasDescBaseitsDescPtr
 
TableColumn itsTabDataCol
 
Bool itsVarRefFlag
 
Bool itsVarOffFlag
 

Detailed Description

template<class M>
class casacore::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);
Table table() const
Get the Table object this column belongs to.

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.
for (rownr_t 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;
}
static const Double MJD2000
General constants.
Definition: MeasData.h:107
Quantum< Double > Quantity
Definition: Quantum.h:38
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46

Motivation

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

Thrown Exceptions

Definition at line 143 of file ScalarMeasColumn.h.

Constructor & Destructor Documentation

◆ ScalarMeasColumn() [1/3]

template<class M >
casacore::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.

◆ ScalarMeasColumn() [2/3]

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

Create the ScalarMeasColumn from the table and column Name.

◆ ScalarMeasColumn() [3/3]

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

Copy constructor (copy semantics).

◆ ~ScalarMeasColumn()

template<class M >
virtual casacore::ScalarMeasColumn< M >::~ScalarMeasColumn ( )
virtual

Member Function Documentation

◆ attach()

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

Attach a column to the object.

◆ cleanUp()

template<class M >
void casacore::ScalarMeasColumn< M >::cleanUp ( )
private

◆ convert() [1/3]

template<class M >
M casacore::ScalarMeasColumn< M >::convert ( rownr_t  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 177 of file ScalarMeasColumn.h.

◆ convert() [2/3]

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

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

◆ convert() [3/3]

template<class M >
M casacore::ScalarMeasColumn< M >::convert ( rownr_t  rownr,
uInt  refCode 
) const

◆ equalRefs()

template<class M >
Bool casacore::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).

◆ get()

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

Get the Measure contained in the specified row.

It returns the Measure as found in the table.

◆ getMeasRef()

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

References casacore::ScalarMeasColumn< M >::itsMeasRef.

◆ makeMeasRef()

template<class M >
MeasRef<M> casacore::ScalarMeasColumn< M >::makeMeasRef ( rownr_t  rownr) const
protected

Make a MeasRef for the given row.

◆ operator()()

template<class M >
M casacore::ScalarMeasColumn< M >::operator() ( rownr_t  rownr) const

◆ operator=()

template<class M >
ScalarMeasColumn& casacore::ScalarMeasColumn< M >::operator= ( const ScalarMeasColumn< M > &  that)
private

Assignment makes no sense in a readonly class.

Declaring this operator private makes it unusable.

◆ put()

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

Put a Measure into the given row.


◆ reference()

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

Change the reference to another column.

◆ setDescOffset()

template<class M >
void casacore::ScalarMeasColumn< M >::setDescOffset ( const Measure offset,
Bool  tableMustBeEmpty = True 
)

◆ setDescRefCode()

template<class M >
void casacore::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;

◆ setDescUnits()

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

Member Data Documentation

◆ itsArrDataCol

template<class M >
ArrayColumn<Double>* casacore::ScalarMeasColumn< M >::itsArrDataCol
private

Definition at line 227 of file ScalarMeasColumn.h.

◆ itsConvFlag

template<class M >
Bool casacore::ScalarMeasColumn< M >::itsConvFlag
private

Definition at line 223 of file ScalarMeasColumn.h.

◆ itsMeasRef

template<class M >
MeasRef<M> casacore::ScalarMeasColumn< M >::itsMeasRef
private

Definition at line 237 of file ScalarMeasColumn.h.

Referenced by casacore::ScalarMeasColumn< M >::getMeasRef().

◆ itsOffsetCol

template<class M >
ScalarMeasColumn<M>* casacore::ScalarMeasColumn< M >::itsOffsetCol
private

Definition at line 234 of file ScalarMeasColumn.h.

◆ itsRefIntCol

template<class M >
ScalarColumn<Int>* casacore::ScalarMeasColumn< M >::itsRefIntCol
private

Definition at line 230 of file ScalarMeasColumn.h.

◆ itsRefStrCol

template<class M >
ScalarColumn<String>* casacore::ScalarMeasColumn< M >::itsRefStrCol
private

Definition at line 231 of file ScalarMeasColumn.h.

◆ itsScaDataCol

template<class M >
ScalarColumn<Double>* casacore::ScalarMeasColumn< M >::itsScaDataCol
private

Definition at line 228 of file ScalarMeasColumn.h.


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