MSSelectableTable.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //# MSSelectableTable.h: The generic interface for tables that can be used with MSSelection
00003 //# Copyright (C) 1996,1997,1998,1999,2001
00004 //# Associated Universities, Inc. Washington DC, USA.
00005 //#
00006 //# This library is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU Library General Public License as published by
00008 //# the Free Software Foundation; either version 2 of the License, or (at your
00009 //# option) any later version.
00010 //#
00011 //# This library is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 //# License for more details.
00015 //#
00016 //# You should have received a copy of the GNU Library General Public License
00017 //# along with this library; if not, write to the Free Software Foundation,
00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 //#
00027 //#
00028 //# $Id$
00029 
00030 #ifndef MS_MSSELECTABLETABLE_H
00031 #define MS_MSSELECTABLETABLE_H
00032 
00033 #include <casacore/casa/aips.h>
00034 #include <casacore/casa/BasicSL/String.h>
00035 #include <casacore/casa/Arrays/Vector.h>
00036 #include <casacore/casa/Arrays/Matrix.h>
00037 #include <casacore/casa/Arrays/Cube.h>
00038 #include <casacore/casa/Containers/OrderedMap.h>
00039 #include <casacore/casa/Containers/MapIO.h>
00040 #include <casacore/tables/TaQL/ExprNode.h>
00041 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
00042 #include <casacore/ms/MeasurementSets/MSMainEnums.h>
00043 #include <casacore/ms/MSSel/MSSelectionError.h>
00044 #include <casacore/ms/MSSel/MSSelectableMainColumn.h>
00045 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00046 
00047 // <summary> 
00048 //
00049 // MSSelectableTable: An interface class used by MSSelection module to
00050 // access the sub-tables and main-table columns of MS-like tables.
00051 //
00052 // </summary>
00053 
00054 // <use visibility=export>
00055 
00056 // <reviewed reviewer="" date="" tests="" demos="">
00057 
00058 // <prerequisite>
00059 // </prerequisite>
00060 //
00061 // <etymology>
00062 // From "msselection" and "table".
00063 // </etymology>
00064 //
00065 //<synopsis> 
00066 //
00067 // This is a pure virtual base-class to provide a table-type agnostic
00068 // interface to the <linkto
00069 // module="MeasurementSets:description">MSSelection</linkto> module to
00070 // access sub-tables and main-table columns of MS-like tables.
00071 //
00072 // </synopsis>
00073 //
00074 // <example>
00075 // <srcblock>
00076 // </srcblock>
00077 // </example>
00078 //
00079 // <motivation>
00080 //
00081 // To allow use of the <linkto
00082 // module="MeasurementSets:description">MSSelection</linkto> module
00083 // for selection on any table that follows the general structure of the
00084 // MS database.  Via this class, minor differences in the database
00085 // layout can be hidden from the MSSelection module.  This also keeps
00086 // MeasurementSet module from depending on other MS-like database
00087 // implemention which may use the MSSelection module.  Such usage will
00088 // need to implement a specialization of <linkto
00089 // module="MeasurementSets:description">MSSelectableTable</linkto> and
00090 // use it to instantiate the <linkto
00091 // module="MeasurementSets:description">MSSelection</linkto> object.
00092 //
00093 // </motivation>
00094 //
00095 // <todo asof="19/03/13">
00096 // </todo>
00097 
00098   class MSSelectableTable
00099   {
00100   public:
00101     enum MSSDataType {BASELINE_BASED=0, PURE_ANTENNA_BASED, REF_ANTENNA_BASED};
00102 
00103     MSSelectableTable()                       {}
00104     MSSelectableTable(const Table& table)     {table_p = &table;}
00105     virtual ~MSSelectableTable()              {}
00106 
00107     virtual void setTable(const Table& table) {table_p = &table;}
00108     const Table* table()                      {return table_p;}
00109     TableExprNode col(const String& colName)  {return table()->col(colName);}
00110 
00111     virtual Bool isMS()                       = 0;
00112     virtual MSSDataType dataType()            = 0;
00113     virtual const MSAntenna& antenna()        = 0;
00114     virtual const MSField& field()            = 0;
00115     virtual const MSSpectralWindow& spectralWindow() = 0;
00116     virtual const MSDataDescription& dataDescription() = 0;
00117     virtual const MSObservation& observation() = 0;
00118 
00119     virtual String columnName(MSMainEnums::PredefinedColumns nameEnum) = 0;
00120     virtual const MeasurementSet* asMS() = 0;
00121     
00122     virtual MSSelectableMainColumn* mainColumns() = 0;
00123 
00124   protected:
00125     const Table *table_p;
00126   };
00127 
00128 // <summary> 
00129 //
00130 // MSInterface: A specialization of MSSelectableTable for accessing
00131 // MS.
00132 //
00133 // </summary>
00134 
00135 // <use visibility=export>
00136 
00137 // <reviewed reviewer="" date="" tests="" demos="">
00138 
00139 // <prerequisite>
00140 // </prerequisite>
00141 //
00142 // <etymology>
00143 //
00144 // From "ms" and "interface".
00145 //
00146 // </etymology>
00147 //
00148 //<synopsis> 
00149 //
00150 // A class that can be passed around as MSSelectableTable, with most of
00151 // the methods overloaded to work with the underlaying MS.
00152 //
00153 //</synopsis>
00154 //
00155 // <example>
00156 // <srcblock>
00157 //
00158 // //
00159 // // Fill in the expression in the various strings that are passed for
00160 // // parsing to the MSSelection object later.
00161 // //
00162 // String fieldStr,timeStr,spwStr,baselineStr,
00163 //   uvdistStr,taqlStr,scanStr,arrayStr, polnStr,stateObsModeStr,
00164 //   observationStr;
00165 // baselineStr="1&2";
00166 // timeStr="*+0:10:0";
00167 // fieldStr="CygA*";
00168 // //
00169 // // Instantiate the MS and the MSInterface objects.
00170 // //
00171 // MS ms(MSName),selectedMS(ms);
00172 // MSInterface msInterface(ms);
00173 // //
00174 // // Setup the MSSelection thingi
00175 // //
00176 // MSSelection msSelection;
00177 //
00178 // msSelection.reset(msInterface,MSSelection::PARSE_NOW,
00179 //                  timeStr,baselineStr,fieldStr,spwStr,
00180 //                  uvdistStr,taqlStr,polnStr,scanStr,arrayStr,
00181 //                  stateObsModeStr,observationStr);
00182 // if (msSelection.getSelectedMS(selectedMS))
00183 //   cerr << "Got the selected MS!" << endl;
00184 // else
00185 //   cerr << "The set of expressions resulted into null-selection";
00186 // </srcblock>
00187 // </example>
00188 //
00189 // <motivation>
00190 //
00191 // To generalize the implementation of the MSSelection parsers.
00192 //
00193 // </motivation>
00194 //
00195 // <todo asof="19/03/13">
00196 // </todo>
00197 
00198   class MSInterface: public MSSelectableTable
00199   {
00200   public:
00201     MSInterface():msMainCols_p(NULL)                   {}
00202     MSInterface(const Table& table);
00203     virtual ~MSInterface()                             {if (msMainCols_p) delete msMainCols_p;}
00204     virtual const MSAntenna& antenna()                 {return asMS()->antenna();}
00205     virtual const MSField& field()                     {return asMS()->field();}
00206     virtual const MSSpectralWindow& spectralWindow()   {return asMS()->spectralWindow();}
00207     virtual const MSDataDescription& dataDescription() {return asMS()->dataDescription();}
00208     virtual const MSObservation& observation()         {return asMS()->observation();}
00209     virtual String columnName(MSMainEnums::PredefinedColumns nameEnum) {return MS::columnName(nameEnum);}
00210     virtual Bool isMS()                                {return True;}
00211     virtual MSSDataType dataType()                     {return MSSelectableTable::BASELINE_BASED;}
00212 
00213     virtual const MeasurementSet *asMS(){return static_cast<const MeasurementSet *>(table());}
00214     virtual MSSelectableMainColumn* mainColumns()
00215     {msMainCols_p = new MSMainColInterface(*table_p); return msMainCols_p;}
00216   private:
00217     MSMainColInterface *msMainCols_p;
00218   };
00219 } //# NAMESPACE CASACORE - END
00220 
00221 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1