MSTable.h

Classes

MSTable -- A Table intended to hold astronomical data (full description)

template <class ColEnum, class KeyEnum> class MSTable : public Table

Interface

Public Members
Bool isColumn(ColEnum which) const
Bool isColumnWritable(ColEnum which) const
Bool isColumnWritable (const String& columnName) const
Bool isColumnWritable (uInt columnIndex) const
Bool isScalar(ColEnum which) const
Bool isArray(ColEnum which) const
const String& unit(const String& which) const
const String& unit(ColEnum which) const
static const String& columnName(ColEnum which)
static ColEnum columnType(const String &name)
static DataType columnDataType(ColEnum which)
static const String& columnStandardComment(ColEnum which)
static const String& columnUnit(ColEnum which)
static const String& columnMeasureType(ColEnum which)
static void addColumnToDesc(TableDesc & tabDesc, ColEnum which, Int ndim=-1,const String& refCol="")
static void addColumnToDesc(TableDesc & tabDesc, ColEnum which, const IPosition& shape, IPosition::Option option, const String& refCol="")
static const String& keywordName(KeyEnum which)
static KeyEnum keywordType(const String &name)
static DataType keywordDataType(KeyEnum which)
static const String& keywordStandardComment(KeyEnum which)
Bool isKeyword(KeyEnum which) const
static void addKeyToDesc(TableDesc & tabDesc, KeyEnum key)
static Bool validate(const TableDesc& tabDesc)
static Bool validate(const TableRecord& tabKeySet)
Bool validate() const
static const TableDesc& requiredTableDesc()
static void addColumnCompression (TableDesc& td, ColEnum which, Bool autoScale = True, const String& type = String())
Protected Members
MSTable ()
MSTable (const String &tableName, TableOption option)
MSTable (const String &tableName, const TableLock& lockOptions, TableOption option)
MSTable (const String &tableName, const String &tableDescName, TableOption option)
MSTable (const String &tableName, const String &tableDescName, const TableLock& lockOptions, TableOption option)
MSTable (SetupNewTable &newTab, uInt nrrow, Bool initialize)
MSTable (SetupNewTable &newTab, const TableLock& lockOptions, uInt nrrow, Bool initialize)
MSTable (const Table &table)
MSTable (const MSTable<ColEnum,KeyEnum> &other)
~MSTable()
MSTable& operator=(const MSTable<ColEnum,KeyEnum>&)
static void colMapDef(ColEnum col, const String& colName, DataType colType, const String& colComment, const String& colUnit="", const String& colMeasureType="")
static void keyMapDef(KeyEnum key, const String& keyName, DataType keyType, const String& keyComment)
Table referenceCopy(const String& newTableName, const Block<String>& writableColumns) const

Description

Review Status

Reviewed By:
Bob Garwood
Date Reviewed:
1997/02/01

Prerequisite

Etymology

The MSTable is the base class for all MeasurementSet Tables, hence the name.

Synopsis

A MSTable is a Table. Most operations on a MSTable are Table operations. See the Tables module for a list of those operations. The member functions provided by this class are primarily convenience functions to help users follow the agreed upon column and keyword naming conventions. They are useful when creating a Table following the MSTable conventions from scratch as well as when creating the column objects to access those columns. All actual MeasurementSet Tables will be derived from this class.

The standard way of accessing table columns is through Strings. Mistakes in typing the column name will not be caught at compile time (and may not be caught at run time). We have therefore decided to use an enumeration to specify columns so that many mistakes will be caught at compile time. This requires functions to map to and from this enumeration to the strings that are ultimately used.

Upon destruction, the table is checked to see that all required columns and keywords are still present. If not an exception is thrown. Nevertheless, the table will be flushed to disk if it is writable - preserving its state.

Example

For examples of use, see the MeasurementSet class.

Motivation

The Table module is more than adequate as a container of data. However, in order for applications to be useful with data from different sources, some conventions need to be adopted in the use of Tables to store data. The MSTable provides the framework for these conventions and conversion functions. The actual definitions of columns and keywords are found in the derived classes and their "enum" base class (e.g. MSAntenna and MSAntennaEnums).

To Do

Member Description

Bool isColumn(ColEnum which) const

ColEnum convenience functions

check to see if a column exists

Bool isColumnWritable(ColEnum which) const
Bool isColumnWritable (const String& columnName) const
Bool isColumnWritable (uInt columnIndex) const

ColEnum convenience functions

check to see if a column is writable

Bool isScalar(ColEnum which) const
Bool isArray(ColEnum which) const

ColEnum convenience functions

Information about scalar vs array of a column

const String& unit(const String& which) const
const String& unit(ColEnum which) const

ColEnum convenience functions

Return the UNIT keyword value associated with the specified column

static ColEnum columnType(const String &name)

ColEnum convenience functions

Convert a name to a ColEnum

static DataType columnDataType(ColEnum which)

ColEnum convenience functions

return the data type for a given ColEnum

static const String& columnStandardComment(ColEnum which)

ColEnum convenience functions

return the standard comment for a given ColEnum

static const String& columnUnit(ColEnum which)

ColEnum convenience functions

return the UNIT string for a given ColEnum

static const String& columnMeasureType(ColEnum which)

ColEnum convenience functions

return the MEASURE_TYPE string for a given ColEnum

static void addColumnToDesc(TableDesc & tabDesc, ColEnum which, Int ndim=-1,const String& refCol="")

ColEnum convenience functions

add a column to a TableDesc An exception is thrown for an invalid data type. This indicates a programming error in this class when this occurs. For Array columns you can optionally define the dimension here. For Measure columns you can define a variable reference column.

Thrown Exceptions

static void addColumnToDesc(TableDesc & tabDesc, ColEnum which, const IPosition& shape, IPosition::Option option, const String& refCol="")

ColEnum convenience functions

add a column to a TableDesc, defining the shape and setting the ColumnDesc option (Fixed, Undefined, Direct) For Measure columns you can define a variable reference column.

static const String& columnName(ColEnum which)

ColEnum convenience functions

Bool isKeyword(KeyEnum which) const

KeyEnum convenience functions

check to see if a keyword exists

static void addKeyToDesc(TableDesc & tabDesc, KeyEnum key)

KeyEnum convenience functions

add a keyword to a TableDesc An exception is thrown for an invalid data type. This indicates a missing data type in the code..

Thrown Exceptions

static const String& keywordName(KeyEnum which)
static KeyEnum keywordType(const String &name)
static DataType keywordDataType(KeyEnum which)
static const String& keywordStandardComment(KeyEnum which)

KeyEnum convenience functions

static Bool validate(const TableRecord& tabKeySet)

tableDesc convenience functions

check that the keyword set is valid

Bool validate() const

tableDesc convenience functions

validate self (make sure that this MS is valid)

static const TableDesc& requiredTableDesc()

tableDesc convenience functions

return the required table description

static void addColumnCompression (TableDesc& td, ColEnum which, Bool autoScale = True, const String& type = String())

tableDesc convenience functions

Add the compress option for the given column to the TableDesc. It can only be used for a Float or a Complex column. For complex columns the type determines which CompressComplex engine is used. "SD" means that CompressComplexSD is used; otherwise CompressComplex is used.

static Bool validate(const TableDesc& tabDesc)

tableDesc convenience functions

MSTable ()
MSTable (const String &tableName, TableOption option)
MSTable (const String &tableName, const TableLock& lockOptions, TableOption option)
MSTable (const String &tableName, const String &tableDescName, TableOption option)
MSTable (const String &tableName, const String &tableDescName, const TableLock& lockOptions, TableOption option)
MSTable (SetupNewTable &newTab, uInt nrrow, Bool initialize)
MSTable (SetupNewTable &newTab, const TableLock& lockOptions, uInt nrrow, Bool initialize)
MSTable (const Table &table)
MSTable (const MSTable<ColEnum,KeyEnum> &other)

These constructors mirror the Table ones

~MSTable()

MSTable& operator=(const MSTable<ColEnum,KeyEnum>&)

Assignment operator, reference semantics

static void colMapDef(ColEnum col, const String& colName, DataType colType, const String& colComment, const String& colUnit="", const String& colMeasureType="")

Define an entry in the column maps

static void keyMapDef(KeyEnum key, const String& keyName, DataType keyType, const String& keyComment)

Define an entry in the keyword maps

Table referenceCopy(const String& newTableName, const Block<String>& writableColumns) const

Return a table that references all columns in this table except for those given in writableColumns, those are empty and writable.