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