casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSSourceColumns.h
Go to the documentation of this file.
00001 //# MSSourceColumns.h: provides easy access to MSSource 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: MSSourceColumns.h 19944 2007-02-27 11:14:34Z Malte.Marquarding $
00027 
00028 #ifndef MS_MSSOURCECOLUMNS_H
00029 #define MS_MSSOURCECOLUMNS_H
00030 
00031 #include <casa/aips.h>
00032 #include <measures/Measures/MDirection.h>
00033 #include <measures/Measures/MEpoch.h>
00034 #include <measures/Measures/MFrequency.h>
00035 #include <measures/Measures/MPosition.h>
00036 #include <measures/Measures/MRadialVelocity.h>
00037 #include <measures/Measures/MCDirection.h>
00038 #include <measures/Measures/MCEpoch.h>
00039 #include <measures/Measures/MCFrequency.h>
00040 #include <measures/Measures/MCPosition.h>
00041 #include <measures/Measures/MCRadialVelocity.h>
00042 #include <measures/TableMeasures/ArrayMeasColumn.h>
00043 #include <measures/TableMeasures/ArrayQuantColumn.h>
00044 #include <measures/TableMeasures/ScalarMeasColumn.h>
00045 #include <measures/TableMeasures/ScalarQuantColumn.h>
00046 #include <tables/Tables/ArrayColumn.h>
00047 #include <tables/Tables/ScalarColumn.h>
00048 #include <tables/Tables/TableRecord.h>
00049 #include <casa/BasicSL/String.h>
00050 
00051 namespace casa { //# NAMESPACE CASA - BEGIN
00052 
00053 class MSSource;
00054 
00055 // <summary>
00056 // A class to provide easy read-only access to MSSource columns
00057 // </summary>
00058 
00059 // <use visibility=export>
00060 
00061 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00062 // </reviewed>
00063 
00064 // <prerequisite>
00065 //   <li> MSSource
00066 //   <li> ArrayColumn
00067 //   <li> ScalarColumn
00068 // </prerequisite>
00069 //
00070 // <etymology>
00071 // ROMSSourceColumns stands for Read-Only MeasurementSet Source Table columns.
00072 // </etymology>
00073 //
00074 // <synopsis>
00075 // This class provides read-only access to the columns in the MSSource Table.
00076 // It does the declaration of all the Scalar and ArrayColumns with the
00077 // correct types, so the application programmer doesn't have to
00078 // worry about getting those right. There is an access function
00079 // for every predefined column. Access to non-predefined columns will still
00080 // have to be done with explicit declarations.
00081 // See <linkto class=ROMSColumns> ROMSColumns</linkto> for an example.
00082 // </synopsis>
00083 //
00084 // <motivation>
00085 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00086 // </motivation>
00087 
00088 class ROMSSourceColumns
00089 {
00090 public:
00091   // Construct from the supplied Table
00092   ROMSSourceColumns(const MSSource& msSource);
00093 
00094   // The destructor does nothing special
00095   ~ROMSSourceColumns();
00096 
00097   // Is this object defined? (MSSource table is optional)
00098   Bool isNull() const {return isNull_p;}
00099 
00100   // Access to required columns
00101   // <group>
00102   const ROScalarColumn<Int>& calibrationGroup() const {
00103     return calibrationGroup_p;}
00104   const ROScalarColumn<String>& code() const {return code_p;}
00105   const ROArrayColumn<Double>& direction() const {return direction_p;}
00106   const ROArrayQuantColumn<Double>& directionQuant() const {
00107     return directionQuant_p;}
00108   const ROScalarMeasColumn<MDirection>& directionMeas() const {
00109     return directionMeas_p;}
00110   const ROScalarColumn<Double>& interval() const {return interval_p;}
00111   const ROScalarQuantColumn<Double>& intervalQuant() const {
00112     return intervalQuant_p;}
00113   const ROScalarColumn<String>& name() const {return name_p;}
00114   const ROScalarColumn<Int>& numLines() const {return numLines_p;}
00115   const ROArrayColumn<Double>& properMotion() const {return properMotion_p;}
00116   const ROArrayQuantColumn<Double>& properMotionQuant() const {
00117     return properMotionQuant_p;}
00118   const ROScalarColumn<Int>& sourceId() const {return sourceId_p;}
00119   const ROScalarColumn<Int>& spectralWindowId() const {
00120     return spectralWindowId_p;}
00121   const ROScalarColumn<Double>& time() const {return time_p;}
00122   const ROScalarQuantColumn<Double>& timeQuant() const {return timeQuant_p;}
00123   const ROScalarMeasColumn<MEpoch>& timeMeas() const {return timeMeas_p;}
00124   // </group>
00125 
00126   // Access to optional columns
00127   // <group>
00128   const ROArrayColumn<Double>& position() const {return position_p;}
00129   const ROArrayQuantColumn<Double>& positionQuant() const {
00130     return positionQuant_p;}
00131   const ROScalarMeasColumn<MPosition>& positionMeas() const {
00132     return positionMeas_p;}
00133   const ROScalarColumn<Int>& pulsarId() const {return pulsarId_p;}
00134   const ROArrayColumn<Double>& restFrequency() const {return restFrequency_p;}
00135   const ROArrayQuantColumn<Double>& restFrequencyQuant() const {
00136     return restFrequencyQuant_p;}
00137   const ROArrayMeasColumn<MFrequency>& restFrequencyMeas() const {
00138     return restFrequencyMeas_p;}
00139   const ROScalarColumn<TableRecord>& sourceModel() const {
00140     return sourceModel_p;}
00141   const ROArrayColumn<Double>& sysvel() const {return sysvel_p;}
00142   const ROArrayQuantColumn<Double>& sysvelQuant() const {return sysvelQuant_p;}
00143   const ROArrayMeasColumn<MRadialVelocity>& sysvelMeas() const {
00144     return sysvelMeas_p;}
00145   const ROArrayColumn<String>& transition() const {return transition_p;}
00146   // </group>
00147 
00148   // Convenience function that returns the number of rows in any of the
00149   // columns. Returns zero if the object is null.
00150   uInt nrow() const {return isNull() ? 0 : calibrationGroup_p.nrow();}
00151 
00152 protected:
00153   //# default constructor creates a object that is not usable. Use the attach
00154   //# function correct this.
00155   ROMSSourceColumns();
00156 
00157   //# attach this object to the supplied table.
00158   void attach(const MSSource& msSource);
00159 
00160 private:
00161   //# Make the assignment operator and the copy constructor private to prevent
00162   //# any compiler generated one from being used.
00163   ROMSSourceColumns(const ROMSSourceColumns&);
00164   ROMSSourceColumns& operator=(const ROMSSourceColumns&);
00165 
00166   //# Check if any optional columns exist and if so attach them.
00167   void attachOptionalCols(const MSSource& msSource);
00168   
00169   //# Is the object not attached to a Table.
00170   Bool isNull_p;
00171 
00172   //# required columns
00173   ROScalarColumn<Int> calibrationGroup_p;
00174   ROScalarColumn<String> code_p;
00175   ROArrayColumn<Double> direction_p;
00176   ROScalarColumn<Double> interval_p;
00177   ROScalarColumn<String> name_p;
00178   ROScalarColumn<Int> numLines_p;
00179   ROArrayColumn<Double> properMotion_p;
00180   ROScalarColumn<Int> sourceId_p;
00181   ROScalarColumn<Int> spectralWindowId_p;
00182   ROScalarColumn<Double> time_p;
00183   //# optional columns
00184   ROArrayColumn<Double> position_p;
00185   ROScalarColumn<Int> pulsarId_p;
00186   ROArrayColumn<Double> restFrequency_p;
00187   ROScalarColumn<TableRecord> sourceModel_p;
00188   ROArrayColumn<Double> sysvel_p;
00189   ROArrayColumn<String> transition_p;
00190 
00191   //# Access to Measure columns
00192   ROScalarMeasColumn<MDirection> directionMeas_p;
00193   ROScalarMeasColumn<MEpoch> timeMeas_p;
00194   //# Optional Measure columns
00195   ROScalarMeasColumn<MPosition> positionMeas_p;
00196   ROArrayMeasColumn<MFrequency> restFrequencyMeas_p;
00197   ROArrayMeasColumn<MRadialVelocity> sysvelMeas_p;
00198 
00199   //# Access to Quantum columns
00200   ROArrayQuantColumn<Double> directionQuant_p;
00201   ROScalarQuantColumn<Double> intervalQuant_p;
00202   ROArrayQuantColumn<Double> properMotionQuant_p;
00203   ROScalarQuantColumn<Double> timeQuant_p;
00204   //# Optional Quantum columns
00205   ROArrayQuantColumn<Double> positionQuant_p;
00206   ROArrayQuantColumn<Double> restFrequencyQuant_p;
00207   ROArrayQuantColumn<Double> sysvelQuant_p;
00208 };
00209 
00210 // <summary>
00211 // A class to provide easy read-write access to MSSource columns
00212 // </summary>
00213 
00214 // <use visibility=export>
00215 
00216 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00217 // </reviewed>
00218 
00219 // <prerequisite>
00220 //   <li> MSSource
00221 //   <li> ArrayColumn
00222 //   <li> ScalarColumn
00223 // </prerequisite>
00224 //
00225 // <etymology>
00226 // MSSourceColumns stands for MeasurementSet Source Table columns.
00227 // </etymology>
00228 //
00229 // <synopsis>
00230 // This class provides access to the columns in the MSSource Table,
00231 // it does the declaration of all the Scalar and ArrayColumns with the
00232 // correct types, so the application programmer doesn't have to
00233 // worry about getting those right. There is an access function
00234 // for every predefined column. Access to non-predefined columns will still
00235 // have to be done with explicit declarations.
00236 // See <linkto class=MSColumns> MSColumns</linkto> for an example.
00237 // </synopsis>
00238 //
00239 // <motivation>
00240 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00241 // </motivation>
00242 
00243 class MSSourceColumns: public ROMSSourceColumns
00244 {
00245 public:
00246   // Construct from the supplied Table
00247   MSSourceColumns(MSSource& msSource);
00248 
00249   // The destructor does nothing special
00250   ~MSSourceColumns();
00251 
00252   // Read-write access to required columns
00253   // <group>
00254   ScalarColumn<Int>& calibrationGroup() {return calibrationGroup_p;}
00255   ScalarColumn<String>& code() {return code_p;}
00256   ArrayColumn<Double>& direction() {return direction_p;}
00257   ArrayQuantColumn<Double>& directionQuant() {return directionQuant_p;}
00258   ScalarMeasColumn<MDirection>& directionMeas() {return directionMeas_p;}
00259   ScalarColumn<Double>& interval() {return interval_p;}
00260   ScalarQuantColumn<Double>& intervalQuant() {return intervalQuant_p;}
00261   ScalarColumn<String>& name() {return name_p;}
00262   ScalarColumn<Int>& numLines() {return numLines_p;}
00263   ArrayColumn<Double>& properMotion() {return properMotion_p;}
00264   ArrayQuantColumn<Double>& properMotionQuant() {return properMotionQuant_p;}
00265   ScalarColumn<Int>& sourceId() {return sourceId_p;}
00266   ScalarColumn<Int>& spectralWindowId() {return spectralWindowId_p;}
00267   ScalarColumn<Double>& time() {return time_p;}
00268   ScalarQuantColumn<Double>& timeQuant() {return timeQuant_p;}
00269   ScalarMeasColumn<MEpoch>& timeMeas() {return timeMeas_p;}
00270   // </group>
00271 
00272   // Read-write access to optional columns
00273   // <group>
00274   ArrayColumn<Double>& position() {return position_p;}
00275   ArrayQuantColumn<Double>& positionQuant() {return positionQuant_p;}
00276   ScalarMeasColumn<MPosition>& positionMeas() {return positionMeas_p;}
00277   ScalarColumn<Int>& pulsarId() {return pulsarId_p;}
00278   ArrayColumn<Double>& restFrequency() {return restFrequency_p;}
00279   ArrayQuantColumn<Double>& restFrequencyQuant() {return restFrequencyQuant_p;}
00280   ArrayMeasColumn<MFrequency>& restFrequencyMeas() {
00281     return restFrequencyMeas_p;}
00282   ScalarColumn<TableRecord>& sourceModel() {return sourceModel_p;}
00283   ArrayColumn<Double>& sysvel() {return sysvel_p;}
00284   ArrayQuantColumn<Double>& sysvelQuant() {return sysvelQuant_p;}
00285   ArrayMeasColumn<MRadialVelocity>& sysvelMeas() {return sysvelMeas_p;}
00286   ArrayColumn<String>& transition() {return transition_p;}
00287   // </group>
00288 
00289   // Read-only access to required columns
00290   // <group>
00291   const ROScalarColumn<Int>& calibrationGroup() const {
00292     return ROMSSourceColumns::calibrationGroup();}
00293   const ROScalarColumn<String>& code() const {
00294     return ROMSSourceColumns::code();}
00295   const ROArrayColumn<Double>& direction() const {
00296     return ROMSSourceColumns::direction();}
00297   const ROArrayQuantColumn<Double>& directionQuant() const {
00298     return ROMSSourceColumns::directionQuant();}
00299   const ROScalarMeasColumn<MDirection>& directionMeas() const {
00300     return ROMSSourceColumns::directionMeas();}
00301   const ROScalarColumn<Double>& interval() const {
00302     return ROMSSourceColumns::interval();}
00303   const ROScalarQuantColumn<Double>& intervalQuant() const {
00304     return ROMSSourceColumns::intervalQuant();}
00305   const ROScalarColumn<String>& name() const {
00306     return ROMSSourceColumns::name();}
00307   const ROScalarColumn<Int>& numLines() const {
00308     return ROMSSourceColumns::numLines();}
00309   const ROArrayColumn<Double>& properMotion() const {
00310     return ROMSSourceColumns::properMotion();}
00311   const ROArrayQuantColumn<Double>& properMotionQuant() const {
00312     return ROMSSourceColumns::properMotionQuant();}
00313   const ROScalarColumn<Int>& sourceId() const {
00314     return ROMSSourceColumns::sourceId();}
00315   const ROScalarColumn<Int>& spectralWindowId() const {
00316     return ROMSSourceColumns::spectralWindowId();}
00317   const ROScalarColumn<Double>& time() const {
00318     return ROMSSourceColumns::time();}
00319   const ROScalarQuantColumn<Double>& timeQuant() const {
00320     return ROMSSourceColumns::timeQuant();}
00321   const ROScalarMeasColumn<MEpoch>& timeMeas() const {
00322     return ROMSSourceColumns::timeMeas();}
00323   // </group>
00324 
00325   // Read-only access to optional columns
00326   // <group>
00327   const ROArrayColumn<Double>& position() const {
00328     return ROMSSourceColumns::position();}
00329   const ROArrayQuantColumn<Double>& positionQuant() const {
00330     return ROMSSourceColumns::positionQuant();}
00331   const ROScalarMeasColumn<MPosition>& positionMeas() const {
00332     return ROMSSourceColumns::positionMeas();}
00333   const ROScalarColumn<Int>& pulsarId() const {
00334     return ROMSSourceColumns::pulsarId();}
00335   const ROArrayColumn<Double>& restFrequency() const {
00336     return ROMSSourceColumns::restFrequency();}
00337   const ROArrayQuantColumn<Double>& restFrequencyQuant() const {
00338     return ROMSSourceColumns::restFrequencyQuant();}
00339   const ROArrayMeasColumn<MFrequency>& restFrequencyMeas() const {
00340     return ROMSSourceColumns::restFrequencyMeas();}
00341   const ROScalarColumn<TableRecord>& sourceModel() const {
00342     return ROMSSourceColumns::sourceModel();}
00343   const ROArrayColumn<Double>& sysvel() const {
00344     return ROMSSourceColumns::sysvel();}
00345   const ROArrayQuantColumn<Double>& sysvelQuant() const {
00346     return ROMSSourceColumns::sysvelQuant();}
00347   const ROArrayMeasColumn<MRadialVelocity>& sysvelMeas() const {
00348     return ROMSSourceColumns::sysvelMeas();}
00349   const ROArrayColumn<String>& transition() const {
00350     return ROMSSourceColumns::transition();}
00351   // </group>
00352 
00353   // set the epoch type for the TIME column.
00354   // <note role=tip>
00355   // In principle this function can only be used if the table is empty,
00356   // otherwise already written values may thereafter have an incorrect
00357   // reference, offset, or unit.  However, it is possible that part of the
00358   // table gets written before these values are known.  In that case the
00359   // reference, offset, or units can be set by using a False
00360   // <src>tableMustBeEmpty</src> argument.
00361   // </note>
00362   void setEpochRef(MEpoch::Types ref, Bool tableMustBeEmpty=True);
00363 
00364   // set the direction type for the DIRECTION column. This can only be done
00365   // when the table has no rows. Trying to do so at other times will throw an
00366   // exception.
00367   void setDirectionRef(MDirection::Types ref);
00368 
00369   // set the position type for the POSITION column. This can only be done when
00370   // the table has no rows. Trying to do so at other times will throw an
00371   // exception.
00372   void setPositionRef(MPosition::Types ref);
00373 
00374   // set the frequency type for the REST_FREQUENCY column. Does nothing if this
00375   // column is not defined. This can only be done when the table has no
00376   // rows. Trying to do so at other times will throw an exception.
00377   void setFrequencyRef(MFrequency::Types ref);
00378 
00379   // set the radial velocity type for the SYSVEL column. Does nothing if this
00380   // column is not defined. This can only be done when the table has no
00381   // rows. Trying to do so at other times will throw an exception.
00382   void setRadialVelocityRef(MRadialVelocity::Types ref);
00383 
00384 protected:
00385   //# default constructor creates a object that is not usable. Use the attach
00386   //# function correct this.
00387   MSSourceColumns();
00388 
00389   //# attach this object to the supplied table.
00390   void attach(MSSource& msSource);
00391 
00392 private:
00393   //# Make the assignment operator and the copy constructor private to prevent
00394   //# any compiler generated one from being used.
00395   MSSourceColumns(const MSSourceColumns&);
00396   MSSourceColumns& operator=(const MSSourceColumns&);
00397 
00398   //# Check if any optional columns exist and if so attach them.
00399   void attachOptionalCols(MSSource& msSource);
00400   
00401   //# required columns
00402   ScalarColumn<Int> calibrationGroup_p;
00403   ScalarColumn<String> code_p;
00404   ArrayColumn<Double> direction_p;
00405   ScalarColumn<Double> interval_p;
00406   ScalarColumn<String> name_p;
00407   ScalarColumn<Int> numLines_p;
00408   ArrayColumn<Double> properMotion_p;
00409   ScalarColumn<Int> sourceId_p;
00410   ScalarColumn<Int> spectralWindowId_p;
00411   ScalarColumn<Double> time_p;
00412   //# optional columns
00413   ArrayColumn<Double> position_p;
00414   ScalarColumn<Int> pulsarId_p;
00415   ArrayColumn<Double> restFrequency_p;
00416   ScalarColumn<TableRecord> sourceModel_p;
00417   ArrayColumn<Double> sysvel_p;
00418   ArrayColumn<String> transition_p;
00419 
00420   //# Access to Measure columns
00421   ScalarMeasColumn<MDirection> directionMeas_p;
00422   ScalarMeasColumn<MEpoch> timeMeas_p;
00423   //# Optional Measure columns
00424   ScalarMeasColumn<MPosition> positionMeas_p;
00425   ArrayMeasColumn<MFrequency> restFrequencyMeas_p;
00426   ArrayMeasColumn<MRadialVelocity> sysvelMeas_p;
00427 
00428   //# Access to Quantum columns
00429   ArrayQuantColumn<Double> directionQuant_p;
00430   ScalarQuantColumn<Double> intervalQuant_p;
00431   ArrayQuantColumn<Double> properMotionQuant_p;
00432   ScalarQuantColumn<Double> timeQuant_p;
00433   //# Optional Quantum columns
00434   ArrayQuantColumn<Double> positionQuant_p;
00435   ArrayQuantColumn<Double> restFrequencyQuant_p;
00436   ArrayQuantColumn<Double> sysvelQuant_p;
00437 };
00438 
00439 } //# NAMESPACE CASA - END
00440 
00441 #endif