casa
$Rev:20696$
|
00001 //# MSParse.h: Classes to hold results from an ms 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: MSParse.h 20266 2008-02-26 00:43:05Z gervandiepen $ 00027 00028 #ifndef MS_MSPARSE_H 00029 #define MS_MSPARSE_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <tables/Tables/ExprNode.h> 00034 #include <tables/Tables/ExprNodeSet.h> 00035 00036 #include <ms/MeasurementSets/MeasurementSet.h> 00037 #include <ms/MeasurementSets/MSSelectableTable.h> 00038 #include <casa/BasicSL/String.h> 00039 00040 namespace casa { //# NAMESPACE CASA - BEGIN 00041 00042 //# Forward Declarations 00043 class AipsIO; 00044 00045 00046 // <summary> 00047 // Class to hold values from an ms grammar parser 00048 // </summary> 00049 00050 // <use visibility=local> 00051 00052 // <reviewed reviewer="" date="" tests=""> 00053 // </reviewed> 00054 00055 // <prerequisite> 00056 //# Classes you should understand before using this one. 00057 // </prerequisite> 00058 00059 // <etymology> 00060 // MSParse is the class used to parse an ms command. 00061 // </etymology> 00062 00063 // <synopsis> 00064 // MSParse is used by the parser of an ms sub-expression statements. 00065 // The parser is written in Bison and Flex in files MSXXXGram.y and .l. 00066 // The statements in there use the routines in this file to act 00067 // upon a reduced rule. 00068 // Since multiple tables can be given (with a shorthand), the table 00069 // names are stored in a list. The variable names can be qualified 00070 // by the table name and will be looked up in the appropriate table. 00071 // 00072 // The class MSParse only contains information about an ms 00073 // used in the ms command. Global variables (like a list and a vector) 00074 // are used in MSParse.cc to hold further information. 00075 // 00076 // Global functions are used to operate on the information. 00077 // The main function is the global function msXXXCommand. 00078 // It executes the given STaQL command and returns the resulting ms. 00079 // This is, in fact, the only function to be used by a user. 00080 // </synopsis> 00081 00082 // <motivation> 00083 // It is necessary to be able to give a ms command in ASCII. 00084 // This can be used in a CLI or in the table browser to get a subset 00085 // of a table or to sort a table. 00086 // </motivation> 00087 00088 //# <todo asof="$DATE:$"> 00089 //# A List of bugs, limitations, extensions or planned refinements. 00090 //# </todo> 00091 00092 00093 class MSParse 00094 { 00095 // Dummy AipsIO routines; they are needed for the List container. 00096 // <group> 00097 friend AipsIO& operator<< (AipsIO&, const MSParse&); 00098 friend AipsIO& operator>> (AipsIO&, MSParse&); 00099 // </group> 00100 00101 public: 00102 // Default constructor for List container class. 00103 MSParse (); 00104 00105 // Copy constructor (copy semantics). 00106 MSParse (const MSParse&); 00107 00108 ~MSParse (); 00109 00110 // Assignment (copy semantics). 00111 MSParse& operator= (const MSParse&); 00112 00113 // Associate the ms and the shorthand. 00114 MSParse (const MeasurementSet* ms, const String& shorthand); 00115 // Associate the ms and the shorthand. 00116 MSParse (const MSSelectableTable* ms, const String& shorthand); 00117 00118 // Test if shorthand matches. 00119 Bool test (const String& shortHand) const; 00120 00121 // Get the shorthand. 00122 String& shorthand(); 00123 00124 // Get ms object. 00125 MeasurementSet* ms(); 00126 // Get ms object. 00127 MSSelectableTable* msInterface(); 00128 00129 void setMS(MeasurementSet* ms) {ms_p=ms;}; 00130 static MeasurementSet *ms_p; 00131 static MSSelectableTable *msInterface_p; 00132 void addCondition(TableExprNode& target, TableExprNode& source); 00133 00134 private: 00135 String shorthand_p; 00136 // The following exists for the period we make the transition from 00137 // using MS to using MSSelectableTable. Till then, both interfaces 00138 // have to be supported. 00139 MSSelectableTable *tempMSInterface_p; 00140 }; 00141 00142 } //# NAMESPACE CASA - END 00143 00144 #endif