casacore
MSFeedParse.h
Go to the documentation of this file.
1 //# MSFeedParse.h: Classes to hold results from feed grammar parser
2 //# Copyright (C) 2015
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_MSFEEDPARSE_H
29 #define MS_MSFEEDPARSE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/ms/MSSel/MSParse.h>
34 #include <casacore/ms/MSSel/MSSelectionErrorHandler.h>
35 #include <casacore/casa/Arrays/Matrix.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39  //# Forward Declarations
40 
41  // <summary>
42  // Class to hold values from feed grammar parser
43  // </summary>
44 
45  // <use visibility=local>
46 
47  // <reviewed reviewer="" date="" tests="">
48  // </reviewed>
49 
50  // <prerequisite>
51  //# Classes you should understand before using this one.
52  // </prerequisite>
53 
54  // <etymology>
55  // MSFeedParse is the class used to parse a feed command.
56  // </etymology>
57 
58  // <synopsis>
59  // MSFeedParse is used by the parser of feed sub-expression statements.
60  // The parser is written in Bison and Flex in files MSFeedGram.yy and .ll.
61  // The statements there use the routines in this file to act
62  // upon a reduced rule.
63  // Since multiple tables can be given (with a shorthand), the table
64  // names are stored in a list. The variable names can be qualified
65  // by the table name and will be looked up in the appropriate table.
66  //
67  // The class MSFeedParse only contains information about a table
68  // used in the table command. Global variables (like a list and a vector)
69  // are used in MSFeedParse.cc to hold further information.
70  //
71  // Global functions are used to operate on the information.
72  // The main function is the global function msFeedCommand.
73  // It executes the given STaQL command and returns the resulting ms.
74  // This is, in fact, the only function to be used by a user.
75  // </synopsis>
76 
77  // <motivation>
78  // It is necessary to be able to give a ms command in ASCII.
79  // This can be used in a CLI or in the table browser to get a subset
80  // of a table or to sort a table.
81  // </motivation>
82 
83  //# <todo asof="$DATE:$">
84  //# A List of bugs, limitations, extensions or planned refinements.
85  //# </todo>
86 
87 
88  class MSFeedParse : public MSParse
89  {
90 
91  public:
92  // Define the operator types (&&&, &&, and &).
93  // NB: Keeping the same notation as Antenna parser, even tho not a baseline here!
95 
96  // Default constructor
98 
99  // Associate the ms.
101 
102  MSFeedParse (const MSFeed& feedSubTable,
103  const TableExprNode& feed1AsTEN, const TableExprNode& feed2AsTEN);
104 
106 
107  // Add the given feed selection.
108  const TableExprNode* selectFeedIds(const Vector<Int>& feedIds,
109  BaselineListType baselineType=CrossOnly,
110  Bool negate=False);
111 
112  // Add the given "baseline" selection.
113  const TableExprNode* selectFeedIds(const Vector<Int>& feedIds1,
114  const Vector<Int>& feedIds2,
115  BaselineListType baselineType=CrossOnly,
116  Bool negate=False);
117 
118  // Get a pointer to the table expression node object.
120  { return node_p; }
121  const Vector<Int>& selectedFeed1() const
122  { return feed1List; }
123  const Vector<Int>& selectedFeed2() const
124  { return feed2List; }
126  { return feedPairList; }
127 
129 
130  private:
131 
132  const TableExprNode* setTEN(TableExprNode& condition,
133  BaselineListType baselineType=CrossOnly,
134  Bool negate=False);
135  void makeFeedPairList(const Vector<Int>&f1, const Vector<Int>&f2, Matrix<Int>&fp,
136  BaselineListType baselineType=CrossOnly,
137  Bool negate=False);
138  void makeFeedList(Vector<Int>& feedList,const Vector<Int>& thisList,
139  Bool negate=False);
140  Bool addFeedPair(const Matrix<Int>& feedpairlist,
141  const Int feed1, const Int feed2,
142  BaselineListType baselineType=CrossOnly);
143 
144  //# Data members.
145  public:
148  static void cleanupErrorHandler() {thisMSFErrorHandler.reset();}
149  private:
156  };
157 
158 } //# NAMESPACE CASACORE - END
159 
160 #endif
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
void makeFeedPairList(const Vector< Int > &f1, const Vector< Int > &f2, Matrix< Int > &fp, BaselineListType baselineType=CrossOnly, Bool negate=False)
static void cleanupErrorHandler()
Definition: MSFeedParse.h:148
void makeFeedList(Vector< Int > &feedList, const Vector< Int > &thisList, Bool negate=False)
Matrix< Int > feedPairList
Definition: MSFeedParse.h:153
Vector< Int > feed2List
Definition: MSFeedParse.h:152
const Matrix< Int > & selectedFeedPairs() const
Definition: MSFeedParse.h:125
const Vector< Int > & selectedFeed1() const
Definition: MSFeedParse.h:121
MSFeedParse(const MeasurementSet *ms)
Associate the ms.
static TableExprNode column1AsTEN_p
Definition: MSFeedParse.h:155
static TableExprNode column2AsTEN_p
Definition: MSFeedParse.h:155
TableExprNode node() const
Get a pointer to the table expression node object.
Definition: MSFeedParse.h:119
Vector< Int > feed1List
Definition: MSFeedParse.h:152
const TableExprNode * selectFeedIds(const Vector< Int > &feedIds, BaselineListType baselineType=CrossOnly, Bool negate=False)
Add the given feed selection.
static CountedPtr< MSSelectionErrorHandler > thisMSFErrorHandler
Definition: MSFeedParse.h:147
TableExprNode node_p
Definition: MSFeedParse.h:150
const Vector< Int > & selectedFeed2() const
Definition: MSFeedParse.h:123
MSFeedParse(const MSFeed &feedSubTable, const TableExprNode &feed1AsTEN, const TableExprNode &feed2AsTEN)
const TableExprNode * selectFeedIds(const Vector< Int > &feedIds1, const Vector< Int > &feedIds2, BaselineListType baselineType=CrossOnly, Bool negate=False)
Add the given "baseline" selection.
const TableExprNode * setTEN(TableExprNode &condition, BaselineListType baselineType=CrossOnly, Bool negate=False)
const String colName2
Definition: MSFeedParse.h:151
Bool addFeedPair(const Matrix< Int > &feedpairlist, const Int feed1, const Int feed2, BaselineListType baselineType=CrossOnly)
const String colName1
Definition: MSFeedParse.h:151
MSFeedParse()
Default constructor.
static MSFeedParse * thisMSFParser
Definition: MSFeedParse.h:146
BaselineListType
Define the operator types (&&&, &&, and &).
Definition: MSFeedParse.h:94
MeasurementSet * ms()
Get ms object.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42