casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //#
28 //# $Id$
29 
30 #ifndef MS_MSSELECTABLETABLE_H
31 #define MS_MSSELECTABLETABLE_H
32 
33 #include <casacore/casa/aips.h>
43 namespace casacore { //# NAMESPACE CASACORE - BEGIN
44 
45 // <summary>
46 //
47 // MSSelectableTable: An interface class used by MSSelection module to
48 // access the sub-tables and main-table columns of MS-like tables.
49 //
50 // </summary>
51 
52 // <use visibility=export>
53 
54 // <reviewed reviewer="" date="" tests="" demos="">
55 
56 // <prerequisite>
57 // </prerequisite>
58 //
59 // <etymology>
60 // From "msselection" and "table".
61 // </etymology>
62 //
63 //<synopsis>
64 //
65 // This is a pure virtual base-class to provide a table-type agnostic
66 // interface to the <linkto
67 // module="MeasurementSets:description">MSSelection</linkto> module to
68 // access sub-tables and main-table columns of MS-like tables.
69 //
70 // </synopsis>
71 //
72 // <example>
73 // <srcblock>
74 // </srcblock>
75 // </example>
76 //
77 // <motivation>
78 //
79 // To allow use of the <linkto
80 // module="MeasurementSets:description">MSSelection</linkto> module
81 // for selection on any table that follows the general structure of the
82 // MS database. Via this class, minor differences in the database
83 // layout can be hidden from the MSSelection module. This also keeps
84 // MeasurementSet module from depending on other MS-like database
85 // implemention which may use the MSSelection module. Such usage will
86 // need to implement a specialization of <linkto
87 // module="MeasurementSets:description">MSSelectableTable</linkto> and
88 // use it to instantiate the <linkto
89 // module="MeasurementSets:description">MSSelection</linkto> object.
90 //
91 // </motivation>
92 //
93 // <todo asof="19/03/13">
94 // </todo>
95 
97  {
98  public:
100 
103  virtual ~MSSelectableTable() {}
104 
105  virtual void setTable(const Table& table) {table_p = &table;}
106  const Table* table() {return table_p;}
107  TableExprNode col(const String& colName) {return table()->col(colName);}
108 
109  virtual Bool isMS() = 0;
110  virtual MSSDataType dataType() = 0;
111  virtual const MSAntenna& antenna() = 0;
112  virtual const MSField& field() = 0;
113  virtual const MSSpectralWindow& spectralWindow() = 0;
114  virtual const MSDataDescription& dataDescription() = 0;
115  virtual const MSObservation& observation() = 0;
116 
117  virtual String columnName(MSMainEnums::PredefinedColumns nameEnum) = 0;
118  virtual const MeasurementSet* asMS() = 0;
119 
120  virtual MSSelectableMainColumn* mainColumns() = 0;
121 
122  protected:
123  const Table *table_p;
124  };
125 
126 // <summary>
127 //
128 // MSInterface: A specialization of MSSelectableTable for accessing
129 // MS.
130 //
131 // </summary>
132 
133 // <use visibility=export>
134 
135 // <reviewed reviewer="" date="" tests="" demos="">
136 
137 // <prerequisite>
138 // </prerequisite>
139 //
140 // <etymology>
141 //
142 // From "ms" and "interface".
143 //
144 // </etymology>
145 //
146 //<synopsis>
147 //
148 // A class that can be passed around as MSSelectableTable, with most of
149 // the methods overloaded to work with the underlaying MS.
150 //
151 //</synopsis>
152 //
153 // <example>
154 // <srcblock>
155 //
156 // //
157 // // Fill in the expression in the various strings that are passed for
158 // // parsing to the MSSelection object later.
159 // //
160 // String fieldStr,timeStr,spwStr,baselineStr,
161 // uvdistStr,taqlStr,scanStr,arrayStr, polnStr,stateObsModeStr,
162 // observationStr;
163 // baselineStr="1&2";
164 // timeStr="*+0:10:0";
165 // fieldStr="CygA*";
166 // //
167 // // Instantiate the MS and the MSInterface objects.
168 // //
169 // MS ms(MSName),selectedMS(ms);
170 // MSInterface msInterface(ms);
171 // //
172 // // Setup the MSSelection thingi
173 // //
174 // MSSelection msSelection;
175 //
176 // msSelection.reset(msInterface,MSSelection::PARSE_NOW,
177 // timeStr,baselineStr,fieldStr,spwStr,
178 // uvdistStr,taqlStr,polnStr,scanStr,arrayStr,
179 // stateObsModeStr,observationStr);
180 // if (msSelection.getSelectedMS(selectedMS))
181 // cerr << "Got the selected MS!" << endl;
182 // else
183 // cerr << "The set of expressions resulted into null-selection";
184 // </srcblock>
185 // </example>
186 //
187 // <motivation>
188 //
189 // To generalize the implementation of the MSSelection parsers.
190 //
191 // </motivation>
192 //
193 // <todo asof="19/03/13">
194 // </todo>
195 
197  {
198  public:
200  MSInterface(const Table& table);
201  virtual ~MSInterface() {if (msMainCols_p) delete msMainCols_p;}
202  virtual const MSAntenna& antenna() {return asMS()->antenna();}
203  virtual const MSField& field() {return asMS()->field();}
204  virtual const MSSpectralWindow& spectralWindow() {return asMS()->spectralWindow();}
205  virtual const MSDataDescription& dataDescription() {return asMS()->dataDescription();}
206  virtual const MSObservation& observation() {return asMS()->observation();}
207  virtual String columnName(MSMainEnums::PredefinedColumns nameEnum) {return MS::columnName(nameEnum);}
208  virtual Bool isMS() {return True;}
210 
211  virtual const MeasurementSet *asMS(){return static_cast<const MeasurementSet *>(table());}
214  private:
216  };
217 } //# NAMESPACE CASACORE - END
218 
219 #endif
virtual MSSelectableMainColumn * mainColumns()=0
A Table intended to hold a MeasurementSet OBSERVATION table.
Definition: MSObservation.h:78
virtual const MSSpectralWindow & spectralWindow()
virtual const MSSpectralWindow & spectralWindow()=0
Main interface class to a read/write table.
Definition: Table.h:157
MSSpectralWindow & spectralWindow()
virtual const MeasurementSet * asMS()
A Table intended to hold a MeasurementSet DATADESCRIPTION table.
MSMainColInterface * msMainCols_p
Handle class for a table column expression tree.
Definition: ExprNode.h:156
virtual MSSDataType dataType()
virtual void setTable(const Table &table)
virtual const MSDataDescription & dataDescription()=0
PredefinedColumns
The Main table colums with predefined meaning.
Definition: MSMainEnums.h:65
A Table intended to hold a MeasurementSet ANTENNA table.
Definition: MSAntenna.h:79
MSObservation & observation()
TableExprNode col(const String &colName)
virtual const MSDataDescription & dataDescription()
virtual const MSField & field()=0
virtual const MeasurementSet * asMS()=0
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual const MSField & field()
MSAntenna & antenna()
Access functions for the subtables, using the MS-like interface for each.
static const String & columnName(ColEnum which)
Convert a ColEnum to the actual column name.
MSDataDescription & dataDescription()
TableExprNode col(const String &columnName) const
MSSelectableTable: An interface class used by MSSelection module to access the sub-tables and main-ta...
virtual const MSAntenna & antenna()
A Table intended to hold a MeasurementSet FIELD table.
Definition: MSField.h:78
A Table intended to hold astronomical data (a set of Measurements).
virtual const MSAntenna & antenna()=0
MSSelectableTable(const Table &table)
virtual String columnName(MSMainEnums::PredefinedColumns nameEnum)=0
virtual MSSDataType dataType()=0
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual String columnName(MSMainEnums::PredefinedColumns nameEnum)
MSInterface: A specialization of MSSelectableTable for accessing MS.
const Bool True
Definition: aipstype.h:43
virtual const MSObservation & observation()=0
virtual MSSelectableMainColumn * mainColumns()
virtual const MSObservation & observation()
A Table intended to hold a MeasurementSet SPECTRAL_WINDOW table.