TableMeasRefDesc.h

Classes

TableMeasRefDesc -- Definition of a Measure Reference in a Table. (full description)

class TableMeasRefDesc

Interface

Public Members
explicit TableMeasRefDesc (uInt refCode = 0)
TableMeasRefDesc (uInt refCode, const TableMeasOffsetDesc&)
TableMeasRefDesc (const TableDesc&, const String& column)
TableMeasRefDesc (const TableDesc&, const String& column, const TableMeasOffsetDesc&)
TableMeasRefDesc (const TableRecord& measInfo, const Table&, const TableMeasDescBase&)
TableMeasRefDesc (const TableMeasRefDesc& that)
~TableMeasRefDesc()
TableMeasRefDesc& operator= (const TableMeasRefDesc& that)
uInt getRefCode() const
Bool isRefCodeVariable() const
const String& columnName() const
Bool hasOffset() const
Bool isOffsetVariable() const
Bool isOffsetArray() const
const Measure& getOffset() const
const String& offsetColumnName() const
void resetRefCode (uInt refCode)
void resetOffset (const Measure& offset)
void write (TableDesc&, TableRecord& measInfo, const TableMeasDescBase&)
void write (Table&, TableRecord& measInfo, const TableMeasDescBase&)
Private Members
void writeKeys (TableRecord& measInfo, const TableMeasDescBase& measDesc)
void checkColumn (const TableDesc& td) const

Description

Review Status

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

Prerequisite

Synopsis

TableMeasRefDesc is a class for setting up the MeasRef component of a TableMeasDesc in the TableMeasures system. With the aid of a TableMeasRefDesc the following possibilities for defining a Measure column's reference exist: For each of the above options an offset component can be specified along with a reference code. When a Measure offset is required a TableMeasOffsetDesc is supplied as an argument to the TableMeasRefDesc constructor. With references containing an offset component either component can be set to be variable or fixed independently of the other.

Tip It is not necessary to specify a Reference when defining a Measure column. In such cases the Measures retrieved from the column will have the default reference for the type of Measure stored in the column.

A fixed reference code is trivially stored as part of the column keywords in the Measure column but a variable reference code requires its own column. A Scalar or Array column can be used dependent on your needs but its type must always be either Int or String. Note that it is legal to specify a Scalar reference column for use with an ArrayMeasColumn. In such cases a single reference code will be stored per array (row) of Measures. However, attempting to associate an Array column for references with a ScalarMeasColumn will generate an exception.

Caution When storing Measures into a Measure column with a fixed reference code the reference code component of the Measures stored is ignored.

Example

  1. Simplest kind of TableMeasRefDesc (apart from not specifying one at all) is a fixed reference code. All Measures subsequently retrieved from the column will have the reference MEpoch::LAST.
        // measure reference column
        TableMeasRefDesc reference(MEpoch::LAST);
    
  2. A variable reference code requires its own Int column.
        // An int column for the variable references.
        ScalarColumnDesc<Int> cdRefCol("refCol", "Measure reference column");
        td.addColumn(cdRefCol);
        ...
        // create the Measure reference descriptor
        TableMeasRefDesc varRef(td, "refCol");
    
  3. A fix Measure reference code with a fixed Offset
        // Create the Offset descriptor
        MEpoch offset(MVEpoch(MVTime(1996, 5, 17, (8+18./60.)/24.))
        TableMeasOffsetDesc offsetDesc(offset);
        // create the Measure reference descriptor
        TableMeasRefDesc varRef(MEpoch::LAST, offsetDesc);
    
For an example of the use of a TableMeasRefDesc 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

explicit TableMeasRefDesc (uInt refCode = 0)
TableMeasRefDesc (uInt refCode, const TableMeasOffsetDesc&)

Define a fixed MeasRef by supplying its reference code Optionally a Measure offset can be specified. The reference code and offset should not need a reference frame.

TableMeasRefDesc (const TableDesc&, const String& column)
TableMeasRefDesc (const TableDesc&, const String& column, const TableMeasOffsetDesc&)

Define a variable reference by supplying the name of the column in which the reference is to be stored. Either an Int or String column can be specified. This determines how references are stored. Int columns are likely to be faster but storing references as Strings may be useful if there is a need to browse tables manually. Optionally supply a Measure offset. The reference code and offset should not need a reference frame.

TableMeasRefDesc (const TableRecord& measInfo, const Table&, const TableMeasDescBase&)

Reconstruct the object from the MEASINFO record. Not useful for the public.

TableMeasRefDesc (const TableMeasRefDesc& that)

Copy constructor (copy semantics)

~TableMeasRefDesc()

TableMeasRefDesc& operator= (const TableMeasRefDesc& that)

Assignment operator (copy semantics).

uInt getRefCode() const

Return the reference code.

Bool isRefCodeVariable() const

Is the reference variable?

const String& columnName() const

Return the name of its variable reference code column.

Bool hasOffset() const

Returns True if the reference has an offset.

Bool isOffsetVariable() const

Returns True if the offset is variable.

Bool isOffsetArray() const

Returns True is the offset is variable and it is an ArrayMeasColumn.

const Measure& getOffset() const

Return the fixed Measure offset. It does not test if the offset is defined; hasOffset() should be used for that purpose.

const String& offsetColumnName() const

Return the name of the Measure offset column. An empty string is returned if no variable offset is used.

void resetRefCode (uInt refCode)
void resetOffset (const Measure& offset)

Reset the refCode or 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 TableMeasDescBase&)
void write (Table&, TableRecord& measInfo, const TableMeasDescBase&)

Make the Measure value descriptor persistent. Normally would not be called by the user directly.

void writeKeys (TableRecord& measInfo, const TableMeasDescBase& measDesc)

Write the actual keywords.

void checkColumn (const TableDesc& td) const

Throw an exception if the column doesn't exist or is of the wrong type.