MSFeedParse.h

Go to the documentation of this file.
00001 //# MSFeedParse.h: Classes to hold results from feed grammar parser
00002 //# Copyright (C) 2015
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_MSFEEDPARSE_H
00029 #define MS_MSFEEDPARSE_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/ms/MSSel/MSParse.h>
00034 #include <casacore/ms/MSSel/MSSelectionErrorHandler.h>
00035 #include <casacore/casa/Arrays/Matrix.h>
00036 
00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00038   
00039   //# Forward Declarations
00040   
00041   // <summary>
00042   // Class to hold values from feed grammar parser
00043   // </summary>
00044   
00045   // <use visibility=local>
00046   
00047   // <reviewed reviewer="" date="" tests="">
00048   // </reviewed>
00049   
00050   // <prerequisite>
00051   //# Classes you should understand before using this one.
00052   // </prerequisite>
00053   
00054   // <etymology>
00055   // MSFeedParse is the class used to parse a feed command.
00056   // </etymology>
00057   
00058   // <synopsis>
00059   // MSFeedParse is used by the parser of feed sub-expression statements.
00060   // The parser is written in Bison and Flex in files MSFeedGram.yy and .ll.
00061   // The statements there use the routines in this file to act
00062   // upon a reduced rule.
00063   // Since multiple tables can be given (with a shorthand), the table
00064   // names are stored in a list. The variable names can be qualified
00065   // by the table name and will be looked up in the appropriate table.
00066   //
00067   // The class MSFeedParse only contains information about a table
00068   // used in the table command. Global variables (like a list and a vector)
00069   // are used in MSFeedParse.cc to hold further information.
00070   //
00071   // Global functions are used to operate on the information.
00072   // The main function is the global function msFeedCommand.
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 MSFeedParse : public MSParse
00089   {
00090     
00091   public:
00092     // Define the operator types (&&&, &&, and &).
00093     // NB: Keeping the same notation as Antenna parser, even tho not a baseline here!
00094     enum BaselineListType {AutoCorrOnly=0, AutoCorrAlso, CrossOnly};
00095 
00096     // Default constructor
00097     MSFeedParse();
00098     
00099     // Associate the ms.
00100     MSFeedParse (const MeasurementSet* ms);
00101 
00102     MSFeedParse (const MSFeed& feedSubTable, 
00103                     const TableExprNode& feed1AsTEN, const TableExprNode& feed2AsTEN);
00104 
00105     ~MSFeedParse() {column1AsTEN_p=TableExprNode();column2AsTEN_p=TableExprNode();}
00106 
00107     // Add the given feed selection.
00108     const TableExprNode* selectFeedIds(const Vector<Int>& feedIds, 
00109                                           BaselineListType baselineType=CrossOnly,
00110                                           Bool negate=False);
00111 
00112     // Add the given "baseline" selection.
00113     const TableExprNode* selectFeedIds(const Vector<Int>& feedIds1,
00114                       const Vector<Int>& feedIds2, 
00115                                           BaselineListType baselineType=CrossOnly,
00116                       Bool negate=False);
00117 
00118     // Get a pointer to the table expression node object.
00119     TableExprNode node() const
00120       { return node_p; }
00121     const Vector<Int>& selectedFeed1() const
00122       { return feed1List; }
00123     const Vector<Int>& selectedFeed2() const
00124       { return feed2List; }
00125     const Matrix<Int>& selectedFeedPairs() const
00126       { return feedPairList; }
00127 
00128     MSFeed& subTable() {return msSubTable_p;}
00129 
00130   private:
00131 
00132     const TableExprNode* setTEN(TableExprNode& condition, 
00133                                 BaselineListType baselineType=CrossOnly,
00134                                 Bool negate=False);
00135     void makeFeedPairList(const Vector<Int>&f1, const Vector<Int>&f2, Matrix<Int>&fp, 
00136                           BaselineListType baselineType=CrossOnly,
00137                           Bool negate=False);
00138     void makeFeedList(Vector<Int>& feedList,const Vector<Int>& thisList,
00139                          Bool negate=False);
00140     Bool addFeedPair(const Matrix<Int>& feedpairlist,
00141                      const Int feed1, const Int feed2, 
00142                      BaselineListType baselineType=CrossOnly);
00143 
00144     //# Data members.
00145   public:
00146     static MSFeedParse* thisMSFParser;
00147     static MSSelectionErrorHandler* thisMSFErrorHandler;
00148     static void cleanupErrorHandler() {if (thisMSFErrorHandler) delete thisMSFErrorHandler;thisMSFErrorHandler=0x0;}
00149   private:
00150     TableExprNode node_p;
00151     const String colName1, colName2;
00152     Vector<Int> feed1List, feed2List;
00153     Matrix<Int> feedPairList;
00154     MSFeed msSubTable_p;
00155     static TableExprNode column1AsTEN_p,column2AsTEN_p;
00156   };
00157   
00158 } //# NAMESPACE CASACORE - END
00159 
00160 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1