casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSArrayParse.h
Go to the documentation of this file.
1 //# MSArrayParse.h: Classes to hold results from array grammar parser
2 //# Copyright (C) 1994,1995,1997,1998,1999,2000,2001,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef MS_MSARRAYPARSE_H
29 #define MS_MSARRAYPARSE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 
40 // <summary>
41 // Class to hold values from array grammar parser
42 // </summary>
43 
44 // <use visibility=local>
45 
46 // <reviewed reviewer="" date="" tests="">
47 // </reviewed>
48 
49 // <prerequisite>
50 //# Classes you should understand before using this one.
51 // </prerequisite>
52 
53 // <etymology>
54 // MSArrayParse is the class used to parse a array command.
55 // </etymology>
56 
57 // <synopsis>
58 // MSArrayParse is used by the parser of array sub-expression statements.
59 // The parser is written in Bison and Flex in files MSArrayGram.y and .l.
60 // The statements in there use the routines in this file to act
61 // upon a reduced rule.
62 // Since multiple tables can be given (with a shorthand), the table
63 // names are stored in a list. The variable names can be qualified
64 // by the table name and will be looked up in the appropriate table.
65 //
66 // The class MSArrayParse only contains information about a table
67 // used in the table command. Global variables (like a list and a vector)
68 // are used in MSArrayParse.cc to hold further information.
69 //
70 // Global functions are used to operate on the information.
71 // The main function is the global function msArrayCommand.
72 // It executes the given STaQL command and returns the resulting ms.
73 // This is, in fact, the only function to be used by a user.
74 // </synopsis>
75 
76 // <motivation>
77 // It is necessary to be able to give a ms command in ASCII.
78 // This can be used in a CLI or in the table browser to get a subset
79 // of a table or to sort a table.
80 // </motivation>
81 
82 //# <todo asof="$DATE:$">
83 //# A List of bugs, limitations, extensions or planned refinements.
84 //# </todo>
85 
86 
87 class MSArrayParse : public MSParse
88 {
89 
90 public:
91  // Default constructor
92  MSArrayParse ();
93 
94  // Associate the ms and the shorthand.
96 
97  // ~MSArrayParse() {if (node_p) delete node_p;node_p=0x0;}
98 
99  const TableExprNode *selectRangeGTAndLT(const Int& n0, const Int& n1);
100  const TableExprNode *selectRangeGEAndLE(const Int& n0, const Int& n1);
101  const TableExprNode *selectArrayIds(const Vector<Int>& arrayids);
103  const TableExprNode *selectArrayIdsGT(const Vector<Int>& arrayids);
104  const TableExprNode *selectArrayIdsLT(const Vector<Int>& arrayids);
105  const TableExprNode *selectArrayIdsGTEQ(const Vector<Int>& arrayids);
106  const TableExprNode *selectArrayIdsLTEQ(const Vector<Int>& arrayids);
107  std::vector<Int>& accumulateIDs(const Int id0, const Int id1=-1);
108 
109  // Get table expression node object.
110  const TableExprNode node();
111 
113  void reset(){idList.resize(0);parsedIDList_p.resize(0);}
114  void cleanup() {}
115 
116  void setMaxArray(const Int& n) {maxArrays_p=n;}
117 
119 
120 private:
123  std::vector<Int> parsedIDList_p;
125  void appendToIDList(const Vector<Int>& v);
127 };
128 
129 } //# NAMESPACE CASACORE - END
130 
131 #endif
int Int
Definition: aipstype.h:50
const TableExprNode * selectArrayIdsGT(const Vector< Int > &arrayids)
Class to hold values from an ms grammar parser.
Definition: MSParse.h:93
std::vector< Int > & accumulateIDs(const Int id0, const Int id1=-1)
Handle class for a table column expression tree.
Definition: ExprNode.h:156
void appendToIDList(const Vector< Int > &v)
std::vector< Int > parsedIDList_p
Definition: MSArrayParse.h:123
Class to hold values from array grammar parser.
Definition: MSArrayParse.h:87
void setMaxArray(const Int &n)
Definition: MSArrayParse.h:116
const TableExprNode * selectArrayIdsGTEQ(const Vector< Int > &arrayids)
const TableExprNode * selectArrayIdsLTEQ(const Vector< Int > &arrayids)
const TableExprNode node()
Get table expression node object.
TableExprNode node_p
Definition: MSArrayParse.h:121
MSArrayParse()
Default constructor.
static MSArrayParse * thisMSAParser
Definition: MSArrayParse.h:118
const TableExprNode * selectRangeGEAndLE(const Int &n0, const Int &n1)
A Table intended to hold astronomical data (a set of Measurements).
void resize(size_t len, bool copyValues=false)
Definition: Vector.h:168
const TableExprNode * selectArrayIds()
Definition: MSArrayParse.h:102
const TableExprNode * selectRangeGTAndLT(const Int &n0, const Int &n1)
~MSArrayParse() {if (node_p) delete node_p;node_p=0x0;}
Vector< Int > idList
Definition: MSArrayParse.h:122
String: the storage and methods of handling collections of characters.
Definition: String.h:225
MeasurementSet * ms()
Get ms object.
const TableExprNode * selectArrayIdsLT(const Vector< Int > &arrayids)
Vector< Int > selectedIDs()
Definition: MSArrayParse.h:112