MSSpwParse.h

Go to the documentation of this file.
00001 //# MSSpwParse.h: Classes to hold results from spw grammar parser
00002 //# Copyright (C) 1994,1995,1997,1998,1999,2000,2001,2003
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$
00027 
00028 #ifndef MS_MSSPWPARSE_H
00029 #define MS_MSSPWPARSE_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/ms/MSSel/MSParse.h>
00034 #include <casacore/casa/Arrays/Matrix.h>
00035 #include <casacore/ms/MSSel/MSSelectionErrorHandler.h>
00036 
00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00038 
00039 //# Forward Declarations
00040 
00041 
00042 // <summary>
00043 // Class to hold values from field grammar parser
00044 // </summary>
00045 
00046 // <use visibility=local>
00047 
00048 // <reviewed reviewer="" date="" tests="">
00049 // </reviewed>
00050 
00051 // <prerequisite>
00052 //# Classes you should understand before using this one.
00053 // </prerequisite>
00054 
00055 // <etymology>
00056 // MSSpwParse is the class used to parse a spectral window selection command.
00057 // </etymology>
00058 
00059 // <synopsis> MSSpwParse is used by the parser of spectral window
00060 // (Spw) sub-expression statements.  The parser is written in Bison
00061 // and Flex in files MSSpwGram.y and .l.  The statements in there use
00062 // the routines in this file to act upon a reduced rule.  Since
00063 // multiple tables can be given (with a shorthand), the table names
00064 // are stored in a list. The variable names can be qualified by the
00065 // table name and will be looked up in the appropriate table.
00066 //
00067 // The class MSSpwParse only contains information about a table
00068 // used in the table command. Global variables (like a list and a vector)
00069 // are used in MSSpwParse.cc to hold further information.
00070 //
00071 // Global functions are used to operate on the information.
00072 // The main function is the global function msSpwCommand.
00073 // It executes the given STaQL command and returns the resulting ms.
00074 // This is, in fact, the only function to be used by a user.
00075 // </synopsis>
00076 
00077 // <motivation>
00078 // It is necessary to be able to give a ms command in ASCII.
00079 // This can be used in a CLI or in the table browser to get a subset
00080 // of a table or to sort a table.
00081 // </motivation>
00082 
00083 //# <todo asof="$DATE:$">
00084 //# A List of bugs, limitations, extensions or planned refinements.
00085 //# </todo>
00086 
00087 
00088 class MSSpwParse : public MSParse
00089 {
00090 public:
00091   // Default constructor
00092   MSSpwParse ();
00093   //  ~MSSpwParse() {if (node_p) delete node_p;node_p=0x0;};
00094 
00095   // Associate the ms and the shorthand.
00096   MSSpwParse (const MeasurementSet* ms);
00097   MSSpwParse (const MSSpectralWindow& spwSubTable, const MSDataDescription& ddSubTable,
00098               const TableExprNode& columnAsTEN);
00099   ~MSSpwParse() {columnAsTEN_p=TableExprNode();};
00100 
00101   const TableExprNode *selectSpwIdsFromIDList(const Vector<Int>& spwIds, 
00102                                               const Bool addTen=True,
00103                                               const Bool addIDs=True);
00104   const TableExprNode *selectSpwIdsFromFreqList(const Vector<Float>& spwIds,
00105                                                 const Float factor);
00106   void selectChannelsFromIDList(Vector<Int>& spwIds,
00107                                 Vector<Int>& chanIDList,
00108                                 Int nFSpec);
00109 
00110   void selectChannelsFromDefaultList(Vector<Int>& spwIds,
00111                                      Vector<Int>& chanDefaultList);
00112   const TableExprNode* endOfCeremony(const TableExprNode& ten);
00113 
00114   //    const TableExprNode *selectSpwOrSource(const String& fieldName);
00115 
00116   // Get table expression node object.
00117   static const TableExprNode* node();
00118   static MSSpwParse* thisMSSParser;
00119   static MSSelectionErrorHandler* thisMSSpwErrorHandler;
00120   static Vector<Int> selectedDDIDs() {return ddidList;}
00121   static Vector<Int> selectedIDs() {return idList;}
00122   static Matrix<Int> selectedChanIDs() {return chanList;}
00123   static void reset() {idList.resize(0);chanList.resize(0,0);ddidList.resize(0);};
00124   static void cleanupNode() {if (node_p) delete node_p;node_p=0x0;}
00125   static void cleanupErrorHandler() {if (thisMSSpwErrorHandler) delete thisMSSpwErrorHandler;thisMSSpwErrorHandler=0x0;}
00126   static void cleanup() {cleanupNode(); cleanupErrorHandler();}
00127 
00128   MSSpectralWindow& subTable() {return spwSubTable_p;}
00129 private:
00130   static TableExprNode* node_p;
00131   static Vector<Int> idList, ddidList;
00132   static Matrix<Int> chanList;
00133   MSSpectralWindow spwSubTable_p;
00134   MSDataDescription ddSubTable_p;
00135   static TableExprNode columnAsTEN_p;
00136 };
00137 
00138 } //# NAMESPACE CASACORE - END
00139 
00140 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1