TableMeasOffsetDesc.h

Classes

TableMeasOffsetDesc -- Definition of a Measure Offset in a Table. (full description)

class TableMeasOffsetDesc

Interface

Public Members
TableMeasOffsetDesc (const Measure& offset)
TableMeasOffsetDesc (const TableMeasDescBase& offsetColumn, Bool asArray=False)
TableMeasOffsetDesc (const TableMeasOffsetDesc& that)
~TableMeasOffsetDesc()
TableMeasOffsetDesc& operator= (const TableMeasOffsetDesc& that)
static TableMeasOffsetDesc* reconstruct (const TableRecord& measInfo, const String& prefix, const Table& tab)
const Measure& getOffset() const
Bool isVariable() const
Bool isArray() const
const String& columnName() const
void resetOffset (const Measure& offset)
void write (TableDesc&, TableRecord& measInfo, const String& prefix)
void write (Table&, TableRecord& measInfo, const String& prefix)
Private Members
TableMeasOffsetDesc (const TableRecord& measInfo, const String& prefix, const Table&)
void writeKeys (TableRecord& measInfo, const String& prefix)

Description

Review Status

Reviewed By:
Bob Garwood
Date Reviewed:
1999/12/23
Programs:
Tests:

Prerequisite

Synopsis

This class assists in the definition of the offset component of a TableMeasDesc in the TableMeasures system. Four possibilities exist for specifying the handling of measure offsets in a Measure column. These are:

Note that this last option is only relevant when using ArrayMeasColumns.

Examples of each of these follow.

Example

  1. Specifying a single fixed offset. Note that a Measure offset is itself a measure
        // create an MEpoch to use as the offset in an MEpoch column
        MEpoch offset(MVEpoch(MVTime(1996, 5, 17, (8+18./60.)/24.)), MEpoch::UTC);
        TableMeasOffsetDesc offsetDesc(offset);
    

  2. Storing an offset per row needs an offset column. Measure offsets are Measures so a Measure column is needed:
        // Need a column for the offsets.  This is to be a Measure column,
        // so the rules for creating a Measure column apply.
        ArrayColumnDesc<Double> cdOffset("OffsetCol", "Variable Offset col");
        ...
        // add the column to the table
        td.addColumn(cdOffset);
        ...
        // Create the Measure column to be used as the measure offset column
        TableMeasValueDesc valDesc(td, "OffsetCol");
        TableMeasDesc<MEpoch> offset(valDesc);
        // Create the offset descriptor
        TableMeasOffsetDesc offsetDesc(offset);
    
    

  3. Storing an offset per array element per row requires one change in the constructor used in the previous example:
        ...
        // set up column and TableMeasDesc as before
        ...
        // Setting the asArray parameter to True in the constructor specifies
        // per element offset storage
        TableMeasOffsetDesc offsetDesc(offset, True);
    

For an example of the use of the TableMeasOffsetDesc class in the context of a full TableMeasDesc declaration see class TableMeasDesc.

Motivation

Creating the required keyword for the definition of a Measure in a Table is somewhat complicated. This class assists in that process.

Thrown Exceptions

Member Description

TableMeasOffsetDesc (const Measure& offset)

Constructor which defines a constant (non-variable) offset. All measures in the columns will have the same offset.

TableMeasOffsetDesc (const TableMeasDescBase& offsetColumn, Bool asArray=False)

Constructor for defining a variable offset. If asArray is True then the offset is stored per array element. The default is for the offset to be stored (and hence variable) per row.

TableMeasOffsetDesc (const TableMeasOffsetDesc& that)

Copy constructor (copy semantics).

~TableMeasOffsetDesc()

TableMeasOffsetDesc& operator= (const TableMeasOffsetDesc& that)

Assignment operator (copy semantics).

static TableMeasOffsetDesc* reconstruct (const TableRecord& measInfo, const String& prefix, const Table& tab)

Reconstructs the TableMeasOffsetDesc from the measInfo TableRecord.

const Measure& getOffset() const

Get the (non-variable) measure offset for this column. If it doesn't exist (thus if the offset is variable), an exception is thrown.

Bool isVariable() const

Returns True if the offset varies per row.

Bool isArray() const

Returns True if the offset varies per array element.

const String& columnName() const

Gets the name of the column which stores the variable offset. "" is returned if the offset is not variable.

void resetOffset (const Measure& offset)

Reset the offset. It overwrites the value used when defining the TableMeasDesc. It is only possible if it was defined as fixed for the entire column.

void write (TableDesc&, TableRecord& measInfo, const String& prefix)
void write (Table&, TableRecord& measInfo, const String& prefix)

Write the information into the record.

TableMeasOffsetDesc (const TableRecord& measInfo, const String& prefix, const Table&)

Constructor which uses the measInfo TableRecord.

void writeKeys (TableRecord& measInfo, const String& prefix)

Write the actual keywords.