00001 //# TableMeasValueDesc.h: Definition of a MeasValue in a Table. 00002 //# Copyright (C) 1997,1999,2000,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef MEASURES_TABLEMEASVALUEDESC_H 00029 #define MEASURES_TABLEMEASVALUEDESC_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/casa/BasicSL/String.h> 00034 00035 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00036 00037 //# Forward Declarations 00038 class ColumnDesc; 00039 class Table; 00040 class TableDesc; 00041 class TableRecord; 00042 00043 00044 // <summary> 00045 // Definition of a Measure Value in a Table. 00046 // </summary> 00047 00048 // <use visibility=export> 00049 00050 // <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc"> 00051 // </reviewed> 00052 00053 // <prerequisite> 00054 //# Classes you should understand before using this one. 00055 // <li> <linkto module=Measures>Measures</linkto> 00056 // <li> <linkto module=Tables>Tables</linkto> 00057 // <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto> 00058 // </prerequisite> 00059 00060 // <synopsis> 00061 // TableMeasValueDesc is a class for setting up the Measure value 00062 // component of the TableMeasDesc in the TableMeasures system. Its purpose 00063 // it to specify the Table column to be used as a Measure column through 00064 // which Measures are subsequently written to and read from via 00065 // either an <linkto class="ArrayMeasColumn">ArrayMeasColumn</linkto> 00066 // or <linkto class="ScalarMeasColumn">ScalarMeasColumn</linkto> object. 00067 // 00068 // The column used as the Measure column is always an ArrayColumn<Double> 00069 // irrespective of whether it is to store scalars or arrays of Measures and 00070 // irrespective of the type of Measure. 00071 // </synopsis> 00072 00073 // <example> 00074 //<ol> 00075 // <li> 00076 // <srcblock> 00077 // // Add a column to the table. This column is to be used to store 00078 // // MPositions. Measure columns are alway ArrayColumn<Double> 00079 // ArrayColumnDesc<Double> cdPosCol("MPosColumn", "MPosition column"); 00080 // td.addColumn(cdPosCol); 00081 // ... 00082 // // create the TableMeasValueDesc object 00083 // TableMeasValueDesc valueDesc(td, "MPosColumn"); 00084 // </srcblock> 00085 //</ol> 00086 // For an example of the use of the TableMeasValueDesc class in the context 00087 // of a full TableMeasDesc declaration see class 00088 // <linkto class="TableMeasDesc">TableMeasDesc</linkto>. 00089 // </example> 00090 00091 // <motivation> 00092 // Creating the required keyword for the definition of a Measure 00093 // in a Table is somewhat complicated. This class assists in that 00094 // process. 00095 // </motivation> 00096 // 00097 // <thrown> 00098 // <li>AipsError if the specified column doesn't exist or it isn't 00099 // an ArrayColumn or its type is not Double. 00100 // </thrown> 00101 // 00102 //# <todo asof="$DATE:$"> 00103 //# A List of bugs, limitations, extensions or planned refinements. 00104 //# </todo> 00105 00106 00107 class TableMeasValueDesc 00108 { 00109 public: 00110 // Null constructor 00111 TableMeasValueDesc(); 00112 00113 // Construct the MeasValue column descriptor for the given column. 00114 // The column must be a column of type Double and should exist in 00115 // the TableDesc. 00116 TableMeasValueDesc (const TableDesc&, const String& columnName); 00117 00118 // Construct the MeasValue column descriptor for the given column. 00119 // Checking if the column exists is done in the write function. 00120 // <group> 00121 TableMeasValueDesc (const String& columnName) 00122 : itsColumn (columnName) {} 00123 TableMeasValueDesc (const Char* columnName) 00124 : itsColumn (columnName) {} 00125 // </group> 00126 00127 // Copy constructor. 00128 TableMeasValueDesc (const TableMeasValueDesc& that); 00129 00130 ~TableMeasValueDesc(); 00131 00132 // Assignment operator. 00133 TableMeasValueDesc& operator= (const TableMeasValueDesc& that); 00134 00135 // Write the type, unit, and MEASINFO record into the column keywords. 00136 // It checks if the column exists in the given table description. 00137 // <group> 00138 void write (TableDesc&, const TableRecord& measInfo); 00139 void write (Table&, const TableRecord& measInfo); 00140 // </group> 00141 00142 // Get the name of the underlying column. 00143 const String& columnName() const 00144 { return itsColumn; } 00145 00146 private: 00147 String itsColumn; //# MeasValue column name. 00148 00149 00150 // Write the actual keywords. 00151 void writeKeys (TableRecord& columnKeyset, 00152 const TableRecord& measInfo); 00153 00154 // Throw an exception if the quantum column doesn't exist or is of the 00155 // wrong type. 00156 void checkColumn (const TableDesc& td) const; 00157 }; 00158 00159 00160 00161 } //# NAMESPACE CASACORE - END 00162 00163 #endif