casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TableMeasValueDesc.h
Go to the documentation of this file.
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: TableMeasValueDesc.h 18093 2004-11-30 17:51:10Z ddebonis $
00027 
00028 #ifndef MEASURES_TABLEMEASVALUEDESC_H
00029 #define MEASURES_TABLEMEASVALUEDESC_H
00030 
00031 //# Includes
00032 #include <casa/BasicSL/String.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 //# Forward Declarations
00037 class ColumnDesc;
00038 class Table;
00039 class TableDesc;
00040 class TableRecord;
00041 
00042 
00043 // <summary>
00044 // Definition of a Measure Value in a Table.
00045 // </summary>
00046 
00047 // <use visibility=export>
00048 
00049 // <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc">
00050 // </reviewed>
00051 
00052 // <prerequisite>
00053 //# Classes you should understand before using this one.
00054 //   <li> <linkto module=Measures>Measures</linkto>
00055 //   <li> <linkto module=Tables>Tables</linkto>
00056 //   <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto>
00057 // </prerequisite>
00058 
00059 // <synopsis>
00060 // TableMeasValueDesc is a class for setting up the Measure value
00061 // component of the TableMeasDesc in the TableMeasures system.   Its purpose
00062 // it to specify the Table column to be used as a Measure column through
00063 // which Measures are subsequently written to and read from via
00064 // either an <linkto class="ArrayMeasColumn">ArrayMeasColumn</linkto>
00065 // or <linkto class="ScalarMeasColumn">ScalarMeasColumn</linkto> object.
00066 //
00067 // The column used as the Measure column is always an ArrayColumn<Double>
00068 // irrespective of whether it is to store scalars or arrays of Measures and
00069 // irrespective of the type of Measure.
00070 // </synopsis>
00071 
00072 // <example>
00073 //<ol>
00074 // <li>
00075 // <srcblock>
00076 //    // Add a column to the table.  This column is to be used to store
00077 //    // MPositions.  Measure columns are alway ArrayColumn<Double>
00078 //    ArrayColumnDesc<Double> cdPosCol("MPosColumn", "MPosition column");
00079 //    td.addColumn(cdPosCol);
00080 //    ...
00081 //    // create the TableMeasValueDesc object
00082 //    TableMeasValueDesc valueDesc(td, "MPosColumn");
00083 // </srcblock>
00084 //</ol>
00085 // For an example of the use of the TableMeasValueDesc class in the context
00086 // of a full TableMeasDesc declaration see class
00087 // <linkto class="TableMeasDesc">TableMeasDesc</linkto>.
00088 // </example>
00089 
00090 // <motivation>
00091 // Creating the required keyword for the definition of a Measure
00092 // in a Table is somewhat complicated. This class assists in that
00093 // process.
00094 // </motivation>
00095 //
00096 // <thrown>
00097 //    <li>AipsError if the specified column doesn't exist or it isn't
00098 //      an ArrayColumn or its type is not Double.
00099 // </thrown>
00100 //
00101 //# <todo asof="$DATE:$">
00102 //# A List of bugs, limitations, extensions or planned refinements.
00103 //# </todo>
00104 
00105 
00106 class TableMeasValueDesc
00107 {
00108 public:
00109   // Null constructor
00110   TableMeasValueDesc();
00111 
00112   // Construct the MeasValue column descriptor for the given column.
00113   // The column must be a column of type Double and should exist in
00114   // the TableDesc.
00115   TableMeasValueDesc (const TableDesc&, const String& columnName);
00116 
00117   // Construct the MeasValue column descriptor for the given column.
00118   // Checking if the column exists is done in the write function.
00119   // <group>
00120   TableMeasValueDesc (const String& columnName)
00121     : itsColumn (columnName) {}
00122   TableMeasValueDesc (const Char* columnName)
00123     : itsColumn (columnName) {}
00124   // </group>
00125 
00126   // Copy constructor.
00127   TableMeasValueDesc (const TableMeasValueDesc& that);
00128 
00129   ~TableMeasValueDesc();
00130 
00131   // Assignment operator.
00132   TableMeasValueDesc& operator= (const TableMeasValueDesc& that);
00133 
00134   // Write the type, unit, and MEASINFO record into the column keywords.
00135   // It checks if the column exists in the given table description.
00136   // <group>
00137   void write (TableDesc&, const TableRecord& measInfo);
00138   void write (Table&, const TableRecord& measInfo);
00139   // </group>
00140 
00141   // Get the name of the underlying column.
00142   const String& columnName() const
00143     { return itsColumn; }
00144 
00145 private:
00146   String itsColumn;         //# MeasValue column name.
00147 
00148 
00149   // Write the actual keywords.
00150   void writeKeys (TableRecord& columnKeyset,
00151                   const TableRecord& measInfo);
00152 
00153   // Throw an exception if the quantum column doesn't exist or is of the
00154   // wrong type.
00155   void checkColumn (const TableDesc& td) const;
00156 };
00157 
00158 
00159 
00160 } //# NAMESPACE CASA - END
00161 
00162 #endif