casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSDataDescColumns.h
Go to the documentation of this file.
1 //# MSDataDescColumns.h: provides easy access to MSDataDescription columns
2 //# Copyright (C) 1996,1999,2000
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_MSDATADESCCOLUMNS_H
29 #define MS_MSDATADESCCOLUMNS_H
30 
31 #include <casacore/casa/aips.h>
33 
34 namespace casacore { //# NAMESPACE CASACORE - BEGIN
35 
36 class MSDataDescription;
37 // <summary>
38 // A class to provide easy read-only access to MSDataDesc columns
39 // </summary>
40 
41 // <use visibility=export>
42 
43 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
44 // </reviewed>
45 
46 // <prerequisite>
47 // <li> MSDataDesc
48 // <li> ScalarColumn
49 // </prerequisite>
50 //
51 // <etymology>
52 // ROMSDataDescColumns stands for Read-Only MeasurementSet DataDesc Table
53 // columns.
54 // </etymology>
55 //
56 // <synopsis>
57 // This class provides read-only access to the columns in the MSDataDesc
58 // Table. It does the declaration of all the Scalar and ArrayColumns with the
59 // correct types, so the application programmer doesn't have to worry about
60 // getting those right. There is an access function for every predefined
61 // column. Access to non-predefined columns will still have to be done with
62 // explicit declarations. See <linkto class=ROMSColumns>
63 // ROMSColumns</linkto> for an example. <note role=warning> The Table that
64 // is used to construct this class must not be destroyed (or go out of scope)
65 // before this class does. Otherwise the scalar and array columns use by this
66 // class will be left dangling.</note>
67 
68 // </synopsis>
69 //
70 // <motivation>
71 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
72 // </motivation>
73 
75 {
76 public:
77  // Create a columns object that accesses the data in the specified Table
78  ROMSDataDescColumns(const MSDataDescription& msDataDesc);
79 
80  // The destructor does nothing special
82 
83  // Access to required columns
84  // <group>
85  const ROScalarColumn<Bool>& flagRow() const {return flagRow_p;}
86  const ROScalarColumn<Int>& polarizationId() const {return polarizationId_p;}
87  const ROScalarColumn<Int>& spectralWindowId() const {
88  return spectralWindowId_p;}
89  // </group>
90 
91  // Access to optional columns
92  // <group>
93  const ROScalarColumn<Int>& lagId() const {return lagId_p;}
94  // </group>
95 
96  // Convenience function that returns the number of rows in any of the columns
97  uInt nrow() const {return flagRow_p.nrow();}
98 
99  // returns the last row that contains the specified entries in the
100  // SPECTRAL_WINDOW_ID & POLARIZATION_ID columns. Returns -1 if no match could
101  // be found. Flagged rows can never match. If tryRow is non-negative, then
102  // that row is tested to see if it matches before any others are
103  // tested. Setting tryRow to a positive value greater than the table length
104  // will throw an exception (AipsError).
105  Int match(uInt spwId, uInt polId, Int tryRow=-1);
106 
107 protected:
108  //# default constructor creates a object that is not usable. Use the attach
109  //# function correct this.
111 
112  //# attach this object to the supplied table.
113  void attach(const MSDataDescription& msDataDesc);
114 
115 private:
116  //# Make the assignment operator and the copy constructor private to prevent
117  //# any compiler generated one from being used.
120 
121  //# Check if any optional columns exist and if so attach them.
122  void attachOptionalCols(const MSDataDescription& msDataDesc);
123 
124  //# required columns
125  ROScalarColumn<Bool> flagRow_p;
126  ROScalarColumn<Int> polarizationId_p;
127  ROScalarColumn<Int> spectralWindowId_p;
128  //# optional columns
129  ROScalarColumn<Int> lagId_p;
130 };
131 
132 // <summary>
133 // A class to provide easy read-write access to MSDataDescription columns
134 // </summary>
135 
136 // <use visibility=export>
137 
138 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
139 // </reviewed>
140 
141 // <prerequisite>
142 // <li> MSDataDesc
143 // <li> ScalarColumn
144 // </prerequisite>
145 //
146 // <etymology>
147 // MSDataDescColumns stands for MeasurementSet DataDescription Table
148 // columns.
149 // </etymology>
150 //
151 // <synopsis>
152 // This class provides access to the columns in the MSDataDesc Table,
153 // it does the declaration of all the Scalar and ArrayColumns with the
154 // correct types, so the application programmer doesn't have to
155 // worry about getting those right. There is an access function
156 // for every predefined column. Access to non-predefined columns will still
157 // have to be done with explicit declarations.
158 // See <linkto class=MSColumns> MSColumns</linkto> for an example.
159 // <note role=warning> The Table that is used to construct this class must not
160 // be destroyed (or go out of scope) before this class does. Otherwise the
161 // scalar and array columns use by this class will be left dangling.</note>
162 // </synopsis>
163 //
164 // <motivation>
165 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
166 // </motivation>
167 
169 {
170 public:
171  // Create a columns object that accesses the data in the specified Table
173 
174  // The destructor does nothing special
176 
177  // Read-write access to required columns
178  // <group>
182  // </group>
183 
184  // read-write access to optional columns
185  // <group>
187  // </group>
188 
189  // Read-only access to required columns
190  // <group>
191  const ROScalarColumn<Bool>& flagRow() const {
193  const ROScalarColumn<Int>& polarizationId() const {
195  const ROScalarColumn<Int>& spectralWindowId() const {
197  // </group>
198 
199  // Read-only access to optional columns
200  // <group>
201  const ROScalarColumn<Int>& lagId() const {
202  return ROMSDataDescColumns::lagId();}
203  // </group>
204 
205 protected:
206  //# default constructor creates a object that is not usable. Use the attach
207  //# function correct this.
209 
210  //# attach all the columns in the supplied table to this object
211  void attach(MSDataDescription& msDataDesc);
212 
213 private:
214  //# Make the assignment operator and the copy constructor private to prevent
215  //# any compiler generated one from being used.
218 
219  //# attach optional columns in the supplied Table (if they exist)
220  void attachOptionalCols(MSDataDescription& msDataDesc);
221 
222  //# required columns
226  //# optional columns
228 };
229 
230 } //# NAMESPACE CASACORE - END
231 
232 #endif
int Int
Definition: aipstype.h:50
void attach(MSDataDescription &msDataDesc)
~MSDataDescColumns()
The destructor does nothing special.
const ROScalarColumn< Int > & polarizationId() const
ScalarColumn< Int > spectralWindowId_p
const ROScalarColumn< Int > & lagId() const
Read-only access to optional columns.
ScalarColumn< Int > polarizationId_p
A Table intended to hold a MeasurementSet DATADESCRIPTION table.
const ROScalarColumn< Bool > & flagRow() const
Access to required columns.
ScalarColumn< Bool > flagRow_p
const ROScalarColumn< Int > & lagId() const
Access to optional columns.
const ROScalarColumn< Int > & spectralWindowId() const
const ROScalarColumn< Int > & spectralWindowId() const
ROMSDataDescColumns & operator=(const ROMSDataDescColumns &)
const ROScalarColumn< Int > & polarizationId() const
uInt nrow() const
Convenience function that returns the number of rows in any of the columns.
const ROScalarColumn< Bool > & flagRow() const
Read-only access to required columns.
A class to provide easy read-only access to MSDataDesc columns.
ScalarColumn< Int > & spectralWindowId()
ROScalarColumn< Bool > flagRow_p
ScalarColumn< Int > & polarizationId()
Int match(uInt spwId, uInt polId, Int tryRow=-1)
returns the last row that contains the specified entries in the SPECTRAL_WINDOW_ID &amp; POLARIZATION_ID ...
MSDataDescColumns & operator=(const MSDataDescColumns &)
ScalarColumn< Int > & lagId()
read-write access to optional columns
~ROMSDataDescColumns()
The destructor does nothing special.
ROScalarColumn< Int > spectralWindowId_p
ROScalarColumn< Int > lagId_p
void attach(const MSDataDescription &msDataDesc)
ScalarColumn< Bool > & flagRow()
Read-write access to required columns.
void attachOptionalCols(const MSDataDescription &msDataDesc)
void attachOptionalCols(MSDataDescription &msDataDesc)
unsigned int uInt
Definition: aipstype.h:51
A class to provide easy read-write access to MSDataDescription columns.
ROScalarColumn< Int > polarizationId_p
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42