casacore
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>
34 #include <casacore/casa/BasicSL/String.h>
35 #include <casacore/casa/Arrays/Vector.h>
36 #include <casacore/casa/Arrays/Matrix.h>
37 #include <casacore/casa/Arrays/Cube.h>
38 #include <casacore/casa/Containers/OrderedMap.h>
39 #include <casacore/casa/Containers/MapIO.h>
40 #include <casacore/tables/TaQL/ExprNode.h>
41 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
42 #include <casacore/ms/MeasurementSets/MSMainEnums.h>
43 #include <casacore/ms/MSSel/MSSelectionError.h>
44 #include <casacore/ms/MSSel/MSSelectableMainColumn.h>
45 namespace casacore { //# NAMESPACE CASACORE - BEGIN
46 
47 // <summary>
48 //
49 // MSSelectableTable: An interface class used by MSSelection module to
50 // access the sub-tables and main-table columns of MS-like tables.
51 //
52 // </summary>
53 
54 // <use visibility=export>
55 
56 // <reviewed reviewer="" date="" tests="" demos="">
57 
58 // <prerequisite>
59 // </prerequisite>
60 //
61 // <etymology>
62 // From "msselection" and "table".
63 // </etymology>
64 //
65 //<synopsis>
66 //
67 // This is a pure virtual base-class to provide a table-type agnostic
68 // interface to the <linkto
69 // module="MeasurementSets:description">MSSelection</linkto> module to
70 // access sub-tables and main-table columns of MS-like tables.
71 //
72 // </synopsis>
73 //
74 // <example>
75 // <srcblock>
76 // </srcblock>
77 // </example>
78 //
79 // <motivation>
80 //
81 // To allow use of the <linkto
82 // module="MeasurementSets:description">MSSelection</linkto> module
83 // for selection on any table that follows the general structure of the
84 // MS database. Via this class, minor differences in the database
85 // layout can be hidden from the MSSelection module. This also keeps
86 // MeasurementSet module from depending on other MS-like database
87 // implemention which may use the MSSelection module. Such usage will
88 // need to implement a specialization of <linkto
89 // module="MeasurementSets:description">MSSelectableTable</linkto> and
90 // use it to instantiate the <linkto
91 // module="MeasurementSets:description">MSSelection</linkto> object.
92 //
93 // </motivation>
94 //
95 // <todo asof="19/03/13">
96 // </todo>
97 
99  {
100  public:
102 
105  virtual ~MSSelectableTable() {}
106 
107  virtual void setTable(const Table& table) {table_p = &table;}
108  const Table* table() {return table_p;}
109  TableExprNode col(const String& colName) {return table()->col(colName);}
110 
111  virtual Bool isMS() = 0;
112  virtual MSSDataType dataType() = 0;
113  virtual const MSAntenna& antenna() = 0;
114  virtual const MSField& field() = 0;
115  virtual const MSSpectralWindow& spectralWindow() = 0;
116  virtual const MSDataDescription& dataDescription() = 0;
117  virtual const MSObservation& observation() = 0;
118 
119  virtual String columnName(MSMainEnums::PredefinedColumns nameEnum) = 0;
120  virtual const MeasurementSet* asMS() = 0;
121 
122  virtual MSSelectableMainColumn* mainColumns() = 0;
123 
124  protected:
125  const Table *table_p;
126  };
127 
128 // <summary>
129 //
130 // MSInterface: A specialization of MSSelectableTable for accessing
131 // MS.
132 //
133 // </summary>
134 
135 // <use visibility=export>
136 
137 // <reviewed reviewer="" date="" tests="" demos="">
138 
139 // <prerequisite>
140 // </prerequisite>
141 //
142 // <etymology>
143 //
144 // From "ms" and "interface".
145 //
146 // </etymology>
147 //
148 //<synopsis>
149 //
150 // A class that can be passed around as MSSelectableTable, with most of
151 // the methods overloaded to work with the underlaying MS.
152 //
153 //</synopsis>
154 //
155 // <example>
156 // <srcblock>
157 //
158 // //
159 // // Fill in the expression in the various strings that are passed for
160 // // parsing to the MSSelection object later.
161 // //
162 // String fieldStr,timeStr,spwStr,baselineStr,
163 // uvdistStr,taqlStr,scanStr,arrayStr, polnStr,stateObsModeStr,
164 // observationStr;
165 // baselineStr="1&2";
166 // timeStr="*+0:10:0";
167 // fieldStr="CygA*";
168 // //
169 // // Instantiate the MS and the MSInterface objects.
170 // //
171 // MS ms(MSName),selectedMS(ms);
172 // MSInterface msInterface(ms);
173 // //
174 // // Setup the MSSelection thingi
175 // //
176 // MSSelection msSelection;
177 //
178 // msSelection.reset(msInterface,MSSelection::PARSE_NOW,
179 // timeStr,baselineStr,fieldStr,spwStr,
180 // uvdistStr,taqlStr,polnStr,scanStr,arrayStr,
181 // stateObsModeStr,observationStr);
182 // if (msSelection.getSelectedMS(selectedMS))
183 // cerr << "Got the selected MS!" << endl;
184 // else
185 // cerr << "The set of expressions resulted into null-selection";
186 // </srcblock>
187 // </example>
188 //
189 // <motivation>
190 //
191 // To generalize the implementation of the MSSelection parsers.
192 //
193 // </motivation>
194 //
195 // <todo asof="19/03/13">
196 // </todo>
197 
199  {
200  public:
201  MSInterface():msMainCols_p(NULL) {}
202  MSInterface(const Table& table);
203  virtual ~MSInterface() {if (msMainCols_p) delete msMainCols_p;}
204  virtual const MSAntenna& antenna() {return asMS()->antenna();}
205  virtual const MSField& field() {return asMS()->field();}
206  virtual const MSSpectralWindow& spectralWindow() {return asMS()->spectralWindow();}
207  virtual const MSDataDescription& dataDescription() {return asMS()->dataDescription();}
208  virtual const MSObservation& observation() {return asMS()->observation();}
209  virtual String columnName(MSMainEnums::PredefinedColumns nameEnum) {return MS::columnName(nameEnum);}
210  virtual Bool isMS() {return True;}
212 
213  virtual const MeasurementSet *asMS(){return static_cast<const MeasurementSet *>(table());}
215  {msMainCols_p = new MSMainColInterface(*table_p); return msMainCols_p;}
216  private:
218  };
219 } //# NAMESPACE CASACORE - END
220 
221 #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:149
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:578
virtual MSSDataType dataType()
virtual void setTable(const Table &table)
static const String & columnName(MSMainEnums::PredefinedColumns which)
Convert a ColEnum to the actual column name.
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:39
virtual const MSField & field()
MSAntenna & antenna()
Access functions for the subtables, using the MS-like interface for each.
MSDataDescription & dataDescription()
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).
TableExprNode col(const String &columnName) const
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:223
virtual String columnName(MSMainEnums::PredefinedColumns nameEnum)
MSInterface: A specialization of MSSelectableTable for accessing MS.
const Bool True
Definition: aipstype.h:40
virtual const MSObservation & observation()=0
this file contains all the compiler specific defines
Definition: mainpage.dox:28
virtual MSSelectableMainColumn * mainColumns()
virtual const MSObservation & observation()
A Table intended to hold a MeasurementSet SPECTRAL_WINDOW table.