00001 //# MSFieldParse.h: Classes to hold results from field 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_MSFIELDPARSE_H 00029 #define MS_MSFIELDPARSE_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/ms/MeasurementSets/MSField.h> 00034 #include <casacore/ms/MeasurementSets/MSFieldColumns.h> 00035 #include <casacore/ms/MSSel/MSParse.h> 00036 #include <casacore/ms/MSSel/MSSelectionError.h> 00037 #include <casacore/ms/MSSel/MSSelectableTable.h> 00038 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00039 00040 //# Forward Declarations 00041 00042 00043 // <motivation> 00044 // It is necessary to be able to give a ms command in ASCII. 00045 // This can be used in a CLI or in the table browser to get a subset 00046 // of a table or to sort a table. 00047 // </motivation> 00048 00049 // <summary> 00050 // Class to hold values from field grammar parser 00051 // </summary> 00052 00053 // <use visibility=local> 00054 00055 // <reviewed reviewer="" date="" tests=""> 00056 // </reviewed> 00057 00058 // <prerequisite> 00059 //# Classes you should understand before using this one. 00060 // </prerequisite> 00061 00062 // <etymology> 00063 // MSFieldParse is the class used to parse a field command. 00064 // </etymology> 00065 00066 // <synopsis> 00067 // MSFieldParse is used by the parser of field sub-expression statements. 00068 // The parser is written in Bison and Flex in files MSFieldGram.y and .l. 00069 // The statements in there use the routines in this file to act 00070 // upon a reduced rule. 00071 // Since multiple tables can be given (with a shorthand), the table 00072 // names are stored in a list. The variable names can be qualified 00073 // by the table name and will be looked up in the appropriate table. 00074 // 00075 // The class MSFieldParse only contains information about a table 00076 // used in the table command. Global variables (like a list and a vector) 00077 // are used in MSFieldParse.cc to hold further information. 00078 // 00079 // Global functions are used to operate on the information. 00080 // The main function is the global function msFieldCommand. 00081 // It executes the given STaQL command and returns the resulting ms. 00082 // This is, in fact, the only function to be used by a user. 00083 // </synopsis> 00084 00085 class MSFieldParse : public MSParse 00086 { 00087 00088 public: 00089 // Default constructor 00090 MSFieldParse (); 00091 MSFieldParse (const MeasurementSet* ms); 00092 MSFieldParse (const MSField& fieldSubTable, const TableExprNode& columnAsTEN); 00093 ~MSFieldParse() {columnAsTEN_p=TableExprNode();} 00094 00095 const TableExprNode *selectFieldIds(const Vector<Int>& fieldIds); 00096 00097 // Get table expression node object. 00098 static const TableExprNode* node(); 00099 static MSFieldParse* thisMSFParser; 00100 static Vector<Int> selectedIDs() {return idList;} 00101 static void reset(); 00102 static void cleanup() 00103 {if (node_p) delete node_p;node_p=0x0;} 00104 MSField& subTable() {return msFieldSubTable_p;} 00105 private: 00106 static TableExprNode* node_p; 00107 const String colName; 00108 static Vector<Int> idList; 00109 MSField msFieldSubTable_p; 00110 static TableExprNode columnAsTEN_p; 00111 }; 00112 00113 } //# NAMESPACE CASACORE - END 00114 00115 #endif 00116 00117 00118 //---------------------OLD CODE START (Feb. 2012)------------------- 00119 // #ifndef MS_MSFIELDPARSE_H 00120 // #define MS_MSFIELDPARSE_H 00121 00122 // //# Includes 00123 // #include <casacore/ms/MSSel/MSParse.h> 00124 // #include <casacore/ms/MSSel/MSSelectionError.h> 00125 // #include <casacore/ms/MSSel/MSSelectableTable.h> 00126 // namespace casacore { //# NAMESPACE CASACORE - BEGIN 00127 00128 // //# Forward Declarations 00129 00130 00131 // // <summary> 00132 // // Class to hold values from field grammar parser 00133 // // </summary> 00134 00135 // // <use visibility=local> 00136 00137 // // <reviewed reviewer="" date="" tests=""> 00138 // // </reviewed> 00139 00140 // // <prerequisite> 00141 // //# Classes you should understand before using this one. 00142 // // </prerequisite> 00143 00144 // // <etymology> 00145 // // MSFieldParse is the class used to parse a field command. 00146 // // </etymology> 00147 00148 // // <synopsis> 00149 // // MSFieldParse is used by the parser of field sub-expression statements. 00150 // // The parser is written in Bison and Flex in files MSFieldGram.y and .l. 00151 // // The statements in there use the routines in this file to act 00152 // // upon a reduced rule. 00153 // // Since multiple tables can be given (with a shorthand), the table 00154 // // names are stored in a list. The variable names can be qualified 00155 // // by the table name and will be looked up in the appropriate table. 00156 // // 00157 // // The class MSFieldParse only contains information about a table 00158 // // used in the table command. Global variables (like a list and a vector) 00159 // // are used in MSFieldParse.cc to hold further information. 00160 // // 00161 // // Global functions are used to operate on the information. 00162 // // The main function is the global function msFieldCommand. 00163 // // It executes the given STaQL command and returns the resulting ms. 00164 // // This is, in fact, the only function to be used by a user. 00165 // // </synopsis> 00166 00167 // // <motivation> 00168 // // It is necessary to be able to give a ms command in ASCII. 00169 // // This can be used in a CLI or in the table browser to get a subset 00170 // // of a table or to sort a table. 00171 // // </motivation> 00172 00173 // //# <todo asof="$DATE:$"> 00174 // //# A List of bugs, limitations, extensions or planned refinements. 00175 // //# </todo> 00176 00177 00178 // class MSFieldParse : public MSParse 00179 // { 00180 00181 // public: 00182 // // Default constructor 00183 // MSFieldParse (); 00184 // // ~MSFieldParse() {idList.resize(0);} 00185 // // Associate the ms and the shorthand. 00186 // MSFieldParse (const MeasurementSet* ms); 00187 // MSFieldParse (MSSelectableTable* msLike); 00188 // //~MSFieldParse() {if (node_p) delete node_p;node_p=0x0;} 00189 00190 // const TableExprNode *selectFieldIds(const Vector<Int>& fieldIds); 00191 // // const TableExprNode *selectFieldOrSource(const String& fieldName); 00192 00193 // // Get table expression node object. 00194 // static const TableExprNode* node(); 00195 // static MSFieldParse* thisMSFParser; 00196 // static Vector<Int> selectedIDs() {return idList;} 00197 // static void reset();//{idList.resize(0);} 00198 // static void cleanup() {if (node_p) delete node_p;node_p=0x0;} 00199 // private: 00200 // static TableExprNode* node_p; 00201 // const String colName; 00202 // static Vector<Int> idList; 00203 00204 // }; 00205 00206 // } //# NAMESPACE CASACORE - END 00207 00208 // #endif 00209 //---------------------OLD CODE END (Feb. 2012)-------------------