casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSArrayParse.h
Go to the documentation of this file.
00001 //# MSArrayParse.h: Classes to hold results from array 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: MSArrayParse.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $
00027 
00028 #ifndef MS_MSARRAYPARSE_H
00029 #define MS_MSARRAYPARSE_H
00030 
00031 //# Includes
00032 #include <ms/MeasurementSets/MSParse.h>
00033 #include <measures/Measures/MEpoch.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward Declarations
00038 
00039 // <summary>
00040 // Class to hold values from array grammar parser
00041 // </summary>
00042 
00043 // <use visibility=local>
00044 
00045 // <reviewed reviewer="" date="" tests="">
00046 // </reviewed>
00047 
00048 // <prerequisite>
00049 //# Classes you should understand before using this one.
00050 // </prerequisite>
00051 
00052 // <etymology>
00053 // MSArrayParse is the class used to parse a array command.
00054 // </etymology>
00055 
00056 // <synopsis>
00057 // MSArrayParse is used by the parser of array sub-expression statements.
00058 // The parser is written in Bison and Flex in files MSArrayGram.y and .l.
00059 // The statements in there use the routines in this file to act
00060 // upon a reduced rule.
00061 // Since multiple tables can be given (with a shorthand), the table
00062 // names are stored in a list. The variable names can be qualified
00063 // by the table name and will be looked up in the appropriate table.
00064 //
00065 // The class MSArrayParse only contains information about a table
00066 // used in the table command. Global variables (like a list and a vector)
00067 // are used in MSArrayParse.cc to hold further information.
00068 //
00069 // Global functions are used to operate on the information.
00070 // The main function is the global function msArrayCommand.
00071 // It executes the given STaQL command and returns the resulting ms.
00072 // This is, in fact, the only function to be used by a user.
00073 // </synopsis>
00074 
00075 // <motivation>
00076 // It is necessary to be able to give a ms command in ASCII.
00077 // This can be used in a CLI or in the table browser to get a subset
00078 // of a table or to sort a table.
00079 // </motivation>
00080 
00081 //# <todo asof="$DATE:$">
00082 //# A List of bugs, limitations, extensions or planned refinements.
00083 //# </todo>
00084 
00085 
00086 class MSArrayParse : public MSParse
00087 {
00088 
00089 public:
00090   // Default constructor
00091   MSArrayParse ();
00092 
00093   // Associate the ms and the shorthand.
00094   MSArrayParse (const MeasurementSet* ms);
00095 
00096   //  ~MSArrayParse() {if (node_p) delete node_p;node_p=0x0;};
00097 
00098   const TableExprNode *selectRangeGTAndLT(const Int& n0, const Int& n1);
00099   const TableExprNode *selectRangeGEAndLE(const Int& n0, const Int& n1);
00100   const TableExprNode *selectArrayIds(const Vector<Int>& arrayids);
00101   inline const TableExprNode *selectArrayIds() {return selectArrayIds(parsedIDList_p);};
00102   const TableExprNode *selectArrayIdsGT(const Vector<Int>& arrayids);
00103   const TableExprNode *selectArrayIdsLT(const Vector<Int>& arrayids);
00104   const TableExprNode *selectArrayIdsGTEQ(const Vector<Int>& arrayids);
00105   const TableExprNode *selectArrayIdsLTEQ(const Vector<Int>& arrayids);
00106   std::vector<Int>& accumulateIDs(const Int id0, const Int id1=-1);
00107 
00108     // Get table expression node object.
00109   const TableExprNode node();
00110 
00111   Vector<Int> selectedIDs() {return idList;};
00112   void reset(){idList.resize(0);parsedIDList_p.resize(0);};
00113   void cleanup() {};
00114 
00115   void setMaxArray(const Int& n) {maxArrays_p=n;};
00116 
00117   static MSArrayParse* thisMSAParser;
00118 
00119 private:
00120   TableExprNode node_p;
00121   Vector<Int> idList;
00122   std::vector<Int> parsedIDList_p;
00123   const String colName;
00124   void appendToIDList(const Vector<Int>& v);
00125   Int maxArrays_p;
00126 };
00127 
00128 } //# NAMESPACE CASA - END
00129 
00130 #endif