casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSValidIds.h
Go to the documentation of this file.
00001 //# MSValidIds: ensures that required MS Ids are valid or -1 by row number
00002 //# Copyright (C) 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 //#
00027 //# $Id: MSValidIds.h 18093 2004-11-30 17:51:10Z ddebonis $
00028 
00029 #ifndef MS_MSVALIDIDS_H
00030 #define MS_MSVALIDIDS_H
00031 
00032 #include <casa/aips.h>
00033 #include <ms/MeasurementSets/MeasurementSet.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward declarations
00038 class ROMSColumns;
00039 
00040 // <summary>
00041 // </summary>
00042 
00043 // <use visibility=export>
00044 
00045 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00046 // </reviewed>
00047 
00048 // <prerequisite>
00049 //   <li> MeasurementSet
00050 // </prerequisite>
00051 //
00052 // <etymology>
00053 // </etymology>
00054 //
00055 // <synopsis>
00056 // </synopsis>
00057 //
00058 // <example>
00059 // </example>
00060 //
00061 // <motivation>
00062 // </motivation>
00063 //
00064 // <thrown>
00065 //    <li>
00066 //    <li>
00067 // </thrown>
00068 
00069 class MSValidIds
00070 {
00071 public:
00072     // Construct one unattached to a MeasurementSet.  All functions return -1.
00073     // Use the attach function to attach this to a MeasurementSet after construction.
00074     MSValidIds();
00075 
00076     // Construct one attached to the indicated MeasurementSet
00077     MSValidIds(const MeasurementSet &ms);
00078 
00079     // Construct one from another
00080     MSValidIds(const MSValidIds &other);
00081 
00082     // The destructor
00083     ~MSValidIds();
00084 
00085     // Assignment operator, reference semantics.
00086     MSValidIds &operator=(const MSValidIds &other);
00087 
00088     // Attach this one to a MeasurementSet.  This can also be used to
00089     // re-attach to the same MeasurementSet when additional optional 
00090     // subtables have been added since this object was constructed.
00091     void attach(const MeasurementSet &ms);
00092 
00093     // These functions check on the validity of the appropriate value in
00094     // the main table or sub-tables in the case of some Ids.  The actual
00095     // value stored is returned unless the sub-table does not exist (for
00096     // optional subtables) or the indicated row number does not exist
00097     // in that sub-table where appropriate.
00098     // <group>
00099     Int antenna1(uInt rownr) const;
00100     Int antenna2(uInt rownr) const;
00101     Int dataDescId(uInt rownr) const;
00102     Int fieldId(uInt rownr) const;
00103     Int observationId(uInt rownr) const;
00104     Int processorId(uInt rownr) const;
00105     Int stateId(uInt rownr) const;
00106     // The polarizationId comes from the DATA_DESCRIPTION subtable, so dataDescId must
00107     // first be valid in order for this to also be valid.
00108     Int polarizationId(uInt rownr) const;
00109     // The spectralWindowId comes from the DATA_DESCRIPTION subtable, so dataDescId must
00110     // first be valid in order for this to also be valid.
00111     Int spectralWindowId(uInt rownr) const;
00112     // the dopplerId comes from the SPECTRAL_WINDOW subtable so spectralWindowId must
00113     // first be valid in order for this to also be valid.  Since the DOPPLER subtable
00114     // is not simply indexed by DOPPLER_ID, the DOPPLER subtable exists and a dopplerId
00115     // can be found in the SPECTRAL_WINDOW subtable, that value will be returned, whatever
00116     // it is.
00117     Int dopplerId(uInt rownr) const;
00118     // The sourceId comes from the FIELD subtable so fieldId must first be valid
00119     // in order for this to also be valid.  Since the SOURCE table is also
00120     // indexed by TIME, the only additional check is that a SOURCE table must
00121     // exist in order for this to be valid.
00122     Int sourceId(uInt rownr) const;
00123     // </group>
00124 private:
00125     MeasurementSet ms_p;
00126     ROMSColumns *romsCols_p;
00127 
00128     Bool hasDoppler_p, hasSource_p;
00129     
00130     void clear();
00131     Int checkResult(Int testResult, const Table &mstable) const
00132     { return (testResult < 0 || uInt(testResult) >= mstable.nrow()) ? -1 : testResult;}
00133 
00134     Bool checkRow(uInt rownr) const {return rownr < ms_p.nrow();}
00135 };
00136 
00137 
00138 } //# NAMESPACE CASA - END
00139 
00140 #endif