casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSDataDescColumns.h
Go to the documentation of this file.
00001 //# MSDataDescColumns.h: provides easy access to MSDataDescription columns
00002 //# Copyright (C) 1996,1999,2000
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: MSDataDescColumns.h 18093 2004-11-30 17:51:10Z ddebonis $
00027 
00028 #ifndef MS_MSDATADESCCOLUMNS_H
00029 #define MS_MSDATADESCCOLUMNS_H
00030 
00031 #include <casa/aips.h>
00032 #include <tables/Tables/ScalarColumn.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 class MSDataDescription;
00037 // <summary>
00038 // A class to provide easy read-only access to MSDataDesc columns
00039 // </summary>
00040 
00041 // <use visibility=export>
00042 
00043 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00044 // </reviewed>
00045 
00046 // <prerequisite>
00047 //   <li> MSDataDesc
00048 //   <li> ScalarColumn
00049 // </prerequisite>
00050 //
00051 // <etymology>
00052 // ROMSDataDescColumns stands for Read-Only MeasurementSet DataDesc Table
00053 // columns.
00054 // </etymology>
00055 //
00056 // <synopsis>
00057 // This class provides read-only access to the columns in the MSDataDesc
00058 // Table.  It does the declaration of all the Scalar and ArrayColumns with the
00059 // correct types, so the application programmer doesn't have to worry about
00060 // getting those right. There is an access function for every predefined
00061 // column. Access to non-predefined columns will still have to be done with
00062 // explicit declarations.  See <linkto class=ROMSColumns>
00063 // ROMSColumns</linkto> for an example.  <note role=warning> The Table that
00064 // is used to construct this class must not be destroyed (or go out of scope)
00065 // before this class does. Otherwise the scalar and array columns use by this
00066 // class will be left dangling.</note>
00067 
00068 // </synopsis>
00069 //
00070 // <motivation>
00071 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00072 // </motivation>
00073 
00074 class ROMSDataDescColumns
00075 {
00076 public:
00077   // Create a columns object that accesses the data in the specified Table
00078   ROMSDataDescColumns(const MSDataDescription& msDataDesc);
00079   
00080   // The destructor does nothing special
00081   ~ROMSDataDescColumns();
00082   
00083   // Access to required columns
00084   // <group>
00085   const ROScalarColumn<Bool>& flagRow() const {return flagRow_p;}
00086   const ROScalarColumn<Int>& polarizationId() const {return polarizationId_p;}
00087   const ROScalarColumn<Int>& spectralWindowId() const {
00088     return spectralWindowId_p;}
00089   // </group>
00090 
00091   // Access to optional columns
00092   // <group>
00093   const ROScalarColumn<Int>& lagId() const {return lagId_p;}
00094   // </group>
00095   
00096   // Convenience function that returns the number of rows in any of the columns
00097   uInt nrow() const {return flagRow_p.nrow();}
00098 
00099   // returns the last row that contains the specified entries in the
00100   // SPECTRAL_WINDOW_ID & POLARIZATION_ID columns. Returns -1 if no match could
00101   // be found. Flagged rows can never match. If tryRow is non-negative, then
00102   // that row is tested to see if it matches before any others are
00103   // tested. Setting tryRow to a positive value greater than the table length
00104   // will throw an exception (AipsError).
00105   Int match(uInt spwId, uInt polId, Int tryRow=-1);
00106 
00107 protected:
00108   //# default constructor creates a object that is not usable. Use the attach
00109   //# function correct this.
00110   ROMSDataDescColumns();
00111 
00112   //# attach this object to the supplied table.
00113   void attach(const MSDataDescription& msDataDesc);
00114 
00115 private:
00116   //# Make the assignment operator and the copy constructor private to prevent
00117   //# any compiler generated one from being used.
00118   ROMSDataDescColumns(const ROMSDataDescColumns&);
00119   ROMSDataDescColumns& operator=(const ROMSDataDescColumns&);
00120 
00121   //# Check if any optional columns exist and if so attach them.
00122   void attachOptionalCols(const MSDataDescription& msDataDesc);
00123   
00124   //# required columns
00125   ROScalarColumn<Bool> flagRow_p;
00126   ROScalarColumn<Int> polarizationId_p;
00127   ROScalarColumn<Int> spectralWindowId_p;
00128   //# optional columns
00129   ROScalarColumn<Int> lagId_p;
00130 };
00131 
00132 // <summary>
00133 // A class to provide easy read-write access to MSDataDescription columns
00134 // </summary>
00135 
00136 // <use visibility=export>
00137 
00138 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00139 // </reviewed>
00140 
00141 // <prerequisite>
00142 //   <li> MSDataDesc
00143 //   <li> ScalarColumn
00144 // </prerequisite>
00145 //
00146 // <etymology>
00147 // MSDataDescColumns stands for MeasurementSet DataDescription Table
00148 // columns.
00149 // </etymology>
00150 //
00151 // <synopsis>
00152 // This class provides access to the columns in the MSDataDesc Table,
00153 // it does the declaration of all the Scalar and ArrayColumns with the
00154 // correct types, so the application programmer doesn't have to
00155 // worry about getting those right. There is an access function
00156 // for every predefined column. Access to non-predefined columns will still
00157 // have to be done with explicit declarations.
00158 // See <linkto class=MSColumns> MSColumns</linkto> for an example.
00159 // <note role=warning> The Table that is used to construct this class must not
00160 // be destroyed (or go out of scope) before this class does. Otherwise the
00161 // scalar and array columns use by this class will be left dangling.</note>
00162 // </synopsis>
00163 //
00164 // <motivation>
00165 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00166 // </motivation>
00167 
00168 class MSDataDescColumns: public ROMSDataDescColumns
00169 {
00170 public:
00171   // Create a columns object that accesses the data in the specified Table
00172   MSDataDescColumns(MSDataDescription& msDataDesc);
00173 
00174   // The destructor does nothing special
00175   ~MSDataDescColumns();
00176 
00177   // Read-write access to required columns
00178   // <group>
00179   ScalarColumn<Bool>& flagRow() {return flagRow_p;}
00180   ScalarColumn<Int>& polarizationId() {return polarizationId_p;}
00181   ScalarColumn<Int>& spectralWindowId() {return spectralWindowId_p;}
00182   // </group>
00183 
00184   // read-write access to optional columns
00185   // <group>
00186   ScalarColumn<Int>& lagId() {return lagId_p;}
00187   // </group>
00188 
00189   // Read-only access to required columns
00190   // <group>
00191   const ROScalarColumn<Bool>& flagRow() const {
00192     return ROMSDataDescColumns::flagRow();}
00193   const ROScalarColumn<Int>& polarizationId() const {
00194     return ROMSDataDescColumns::polarizationId();}
00195   const ROScalarColumn<Int>& spectralWindowId() const {
00196     return ROMSDataDescColumns::spectralWindowId();}
00197   // </group>
00198 
00199   // Read-only access to optional columns
00200   // <group>
00201   const ROScalarColumn<Int>& lagId() const {
00202     return ROMSDataDescColumns::lagId();}
00203   // </group>
00204   
00205 protected:
00206   //# default constructor creates a object that is not usable. Use the attach
00207   //# function correct this.
00208   MSDataDescColumns();
00209 
00210   //# attach all the columns in the supplied table to this object
00211   void attach(MSDataDescription& msDataDesc);
00212 
00213 private:
00214   //# Make the assignment operator and the copy constructor private to prevent
00215   //# any compiler generated one from being used.
00216   MSDataDescColumns(const MSDataDescColumns&);
00217   MSDataDescColumns& operator=(const MSDataDescColumns&);
00218 
00219   //# attach optional columns in the supplied Table (if they exist)
00220   void attachOptionalCols(MSDataDescription& msDataDesc);
00221 
00222   //# required columns
00223   ScalarColumn<Bool> flagRow_p;
00224   ScalarColumn<Int> polarizationId_p;
00225   ScalarColumn<Int> spectralWindowId_p;
00226   //# optional columns
00227   ScalarColumn<Int> lagId_p;
00228 };
00229 
00230 } //# NAMESPACE CASA - END
00231 
00232 #endif