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