casacore
Loading...
Searching...
No Matches
MSSelectableTable.h
Go to the documentation of this file.
1// -*- C++ -*-
2// # MSSelectableTable.h: The generic interface for tables that can be used with MSSelection
3// # Copyright (C) 1996,1997,1998,1999,2001
4// # Associated Universities, Inc. Washington DC, USA.
5// #
6// # This library is free software; you can redistribute it and/or modify it
7// # under the terms of the GNU Library General Public License as published by
8// # the Free Software Foundation; either version 2 of the License, or (at your
9// # option) any later version.
10// #
11// # This library is distributed in the hope that it will be useful, but WITHOUT
12// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14// # License for more details.
15// #
16// # You should have received a copy of the GNU Library General Public License
17// # along with this library; if not, write to the Free Software Foundation,
18// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19// #
20// # Correspondence concerning AIPS++ should be addressed as follows:
21// # Internet email: casa-feedback@nrao.edu.
22// # Postal address: AIPS++ Project Office
23// # National Radio Astronomy Observatory
24// # 520 Edgemont Road
25// # Charlottesville, VA 22903-2475 USA
26
27#ifndef MS_MSSELECTABLETABLE_H
28#define MS_MSSELECTABLETABLE_H
29
30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicSL/String.h>
32#include <casacore/casa/Arrays/Vector.h>
33#include <casacore/casa/Arrays/Matrix.h>
34#include <casacore/casa/Arrays/Cube.h>
35#include <casacore/tables/TaQL/ExprNode.h>
36#include <casacore/ms/MeasurementSets/MeasurementSet.h>
37#include <casacore/ms/MeasurementSets/MSMainEnums.h>
38#include <casacore/ms/MSSel/MSSelectionError.h>
39#include <casacore/ms/MSSel/MSSelectableMainColumn.h>
40namespace casacore { // # NAMESPACE CASACORE - BEGIN
41
42// <summary>
43//
44// MSSelectableTable: An interface class used by MSSelection module to
45// access the sub-tables and main-table columns of MS-like tables.
46//
47// </summary>
48
49// <use visibility=export>
50
51// <reviewed reviewer="" date="" tests="" demos="">
52
53// <prerequisite>
54// </prerequisite>
55//
56// <etymology>
57// From "msselection" and "table".
58// </etymology>
59//
60//<synopsis>
61//
62// This is a pure virtual base-class to provide a table-type agnostic
63// interface to the <linkto
64// module="MeasurementSets:description">MSSelection</linkto> module to
65// access sub-tables and main-table columns of MS-like tables.
66//
67// </synopsis>
68//
69// <example>
70// <srcblock>
71// </srcblock>
72// </example>
73//
74// <motivation>
75//
76// To allow use of the <linkto
77// module="MeasurementSets:description">MSSelection</linkto> module
78// for selection on any table that follows the general structure of the
79// MS database. Via this class, minor differences in the database
80// layout can be hidden from the MSSelection module. This also keeps
81// MeasurementSet module from depending on other MS-like database
82// implemention which may use the MSSelection module. Such usage will
83// need to implement a specialization of <linkto
84// module="MeasurementSets:description">MSSelectableTable</linkto> and
85// use it to instantiate the <linkto
86// module="MeasurementSets:description">MSSelection</linkto> object.
87//
88// </motivation>
89//
90// <todo asof="19/03/13">
91// </todo>
92
94 public:
96
99 virtual ~MSSelectableTable() {}
100
101 virtual void setTable(const Table& table) { table_p = &table; }
102 const Table* table() { return table_p; }
103 TableExprNode col(const String& colName) { return table()->col(colName); }
104
105 virtual Bool isMS() = 0;
106 virtual MSSDataType dataType() = 0;
107 virtual const MSAntenna& antenna() = 0;
108 virtual const MSField& field() = 0;
109 virtual const MSSpectralWindow& spectralWindow() = 0;
110 virtual const MSDataDescription& dataDescription() = 0;
111 virtual const MSObservation& observation() = 0;
112
114 virtual const MeasurementSet* asMS() = 0;
115
117
118 protected:
120};
121
122// <summary>
123//
124// MSInterface: A specialization of MSSelectableTable for accessing
125// MS.
126//
127// </summary>
128
129// <use visibility=export>
130
131// <reviewed reviewer="" date="" tests="" demos="">
132
133// <prerequisite>
134// </prerequisite>
135//
136// <etymology>
137//
138// From "ms" and "interface".
139//
140// </etymology>
141//
142//<synopsis>
143//
144// A class that can be passed around as MSSelectableTable, with most of
145// the methods overloaded to work with the underlaying MS.
146//
147//</synopsis>
148//
149// <example>
150// <srcblock>
151//
152// //
153// // Fill in the expression in the various strings that are passed for
154// // parsing to the MSSelection object later.
155// //
156// String fieldStr,timeStr,spwStr,baselineStr,
157// uvdistStr,taqlStr,scanStr,arrayStr, polnStr,stateObsModeStr,
158// observationStr;
159// baselineStr="1&2";
160// timeStr="*+0:10:0";
161// fieldStr="CygA*";
162// //
163// // Instantiate the MS and the MSInterface objects.
164// //
165// MS ms(MSName),selectedMS(ms);
166// MSInterface msInterface(ms);
167// //
168// // Setup the MSSelection thingi
169// //
170// MSSelection msSelection;
171//
172// msSelection.reset(msInterface,MSSelection::PARSE_NOW,
173// timeStr,baselineStr,fieldStr,spwStr,
174// uvdistStr,taqlStr,polnStr,scanStr,arrayStr,
175// stateObsModeStr,observationStr);
176// if (msSelection.getSelectedMS(selectedMS))
177// cerr << "Got the selected MS!" << std::endl;
178// else
179// cerr << "The set of expressions resulted into null-selection";
180// </srcblock>
181// </example>
182//
183// <motivation>
184//
185// To generalize the implementation of the MSSelection parsers.
186//
187// </motivation>
188//
189// <todo asof="19/03/13">
190// </todo>
191
193 public:
196 virtual ~MSInterface() {
197 if (msMainCols_p) delete msMainCols_p;
198 }
199 virtual const MSAntenna& antenna() { return asMS()->antenna(); }
200 virtual const MSField& field() { return asMS()->field(); }
201 virtual const MSSpectralWindow& spectralWindow() { return asMS()->spectralWindow(); }
202 virtual const MSDataDescription& dataDescription() { return asMS()->dataDescription(); }
203 virtual const MSObservation& observation() { return asMS()->observation(); }
205 return MS::columnName(nameEnum);
206 }
207 virtual Bool isMS() { return True; }
209
210 virtual const MeasurementSet* asMS() { return static_cast<const MeasurementSet*>(table()); }
215
216 private:
218};
219} // namespace casacore
220
221#endif
virtual const MSDataDescription & dataDescription()
MSMainColInterface * msMainCols_p
virtual const MSAntenna & antenna()
MSInterface(const Table &table)
virtual const MSObservation & observation()
virtual const MeasurementSet * asMS()
virtual MSSDataType dataType()
virtual MSSelectableMainColumn * mainColumns()
virtual const MSField & field()
virtual const MSSpectralWindow & spectralWindow()
virtual String columnName(MSMainEnums::PredefinedColumns nameEnum)
PredefinedColumns
The Main table colums with predefined meaning.
Definition MSMainEnums.h:62
virtual const MSField & field()=0
virtual const MeasurementSet * asMS()=0
TableExprNode col(const String &colName)
virtual const MSObservation & observation()=0
virtual const MSSpectralWindow & spectralWindow()=0
MSSelectableTable(const Table &table)
virtual void setTable(const Table &table)
virtual const MSAntenna & antenna()=0
virtual String columnName(MSMainEnums::PredefinedColumns nameEnum)=0
virtual MSSDataType dataType()=0
virtual MSSelectableMainColumn * mainColumns()=0
virtual const MSDataDescription & dataDescription()=0
static const String & columnName(ColEnum which)
MSAntenna & antenna()
Access functions for the subtables, using the MS-like interface for each.
MSObservation & observation()
MSSpectralWindow & spectralWindow()
MSDataDescription & dataDescription()
String: the storage and methods of handling collections of characters.
Definition String.h:355
TableExprNode col(const String &columnName) const
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41