casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSValidIds.h
Go to the documentation of this file.
1 //# MSValidIds: ensures that required MS Ids are valid or -1 by row number
2 //# Copyright (C) 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 //#
27 //# $Id$
28 
29 #ifndef MS_MSVALIDIDS_H
30 #define MS_MSVALIDIDS_H
31 
32 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward declarations
38 class MSColumns;
39 
40 // <summary>
41 // </summary>
42 
43 // <use visibility=export>
44 
45 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> MeasurementSet
50 // </prerequisite>
51 //
52 // <etymology>
53 // </etymology>
54 //
55 // <synopsis>
56 // </synopsis>
57 //
58 // <example>
59 // </example>
60 //
61 // <motivation>
62 // </motivation>
63 //
64 // <thrown>
65 // <li>
66 // <li>
67 // </thrown>
68 
70 {
71 public:
72  // Construct one unattached to a MeasurementSet. All functions return -1.
73  // Use the attach function to attach this to a MeasurementSet after construction.
74  MSValidIds();
75 
76  // Construct one attached to the indicated MeasurementSet
77  MSValidIds(const MeasurementSet &ms);
78 
79  // Construct one from another
80  MSValidIds(const MSValidIds &other);
81 
82  // The destructor
83  ~MSValidIds();
84 
85  // Assignment operator, reference semantics.
86  MSValidIds &operator=(const MSValidIds &other);
87 
88  // Attach this one to a MeasurementSet. This can also be used to
89  // re-attach to the same MeasurementSet when additional optional
90  // subtables have been added since this object was constructed.
91  void attach(const MeasurementSet &ms);
92 
93  // These functions check on the validity of the appropriate value in
94  // the main table or sub-tables in the case of some Ids. The actual
95  // value stored is returned unless the sub-table does not exist (for
96  // optional subtables) or the indicated row number does not exist
97  // in that sub-table where appropriate.
98  // <group>
99  Int antenna1(rownr_t rownr) const;
100  Int antenna2(rownr_t rownr) const;
101  Int dataDescId(rownr_t rownr) const;
102  Int fieldId(rownr_t rownr) const;
103  Int observationId(rownr_t rownr) const;
104  Int processorId(rownr_t rownr) const;
105  Int stateId(rownr_t rownr) const;
106  // The polarizationId comes from the DATA_DESCRIPTION subtable, so dataDescId must
107  // first be valid in order for this to also be valid.
108  Int polarizationId(rownr_t rownr) const;
109  // The spectralWindowId comes from the DATA_DESCRIPTION subtable, so dataDescId must
110  // first be valid in order for this to also be valid.
111  Int spectralWindowId(rownr_t rownr) const;
112  // the dopplerId comes from the SPECTRAL_WINDOW subtable so spectralWindowId must
113  // first be valid in order for this to also be valid. Since the DOPPLER subtable
114  // is not simply indexed by DOPPLER_ID, the DOPPLER subtable exists and a dopplerId
115  // can be found in the SPECTRAL_WINDOW subtable, that value will be returned, whatever
116  // it is.
117  Int dopplerId(rownr_t rownr) const;
118  // The sourceId comes from the FIELD subtable so fieldId must first be valid
119  // in order for this to also be valid. Since the SOURCE table is also
120  // indexed by TIME, the only additional check is that a SOURCE table must
121  // exist in order for this to be valid.
122  Int sourceId(rownr_t rownr) const;
123  // </group>
124 private:
127 
129 
130  void clear();
131  Int checkResult(Int testResult, const Table &mstable) const
132  { return (testResult < 0 || rownr_t(testResult) >= mstable.nrow()) ? -1 : testResult;}
133 
134  Bool checkRow(rownr_t rownr) const {return rownr < ms_p.nrow();}
135 };
136 
137 
138 } //# NAMESPACE CASACORE - END
139 
140 #endif
int Int
Definition: aipstype.h:50
Main interface class to a read/write table.
Definition: Table.h:157
Int checkResult(Int testResult, const Table &mstable) const
Definition: MSValidIds.h:131
MeasurementSet ms_p
Definition: MSValidIds.h:125
Int sourceId(rownr_t rownr) const
The sourceId comes from the FIELD subtable so fieldId must first be valid in order for this to also b...
rownr_t nrow() const
Get the number of rows.
Definition: Table.h:1171
Int processorId(rownr_t rownr) const
Int antenna2(rownr_t rownr) const
Int dataDescId(rownr_t rownr) const
Int antenna1(rownr_t rownr) const
These functions check on the validity of the appropriate value in the main table or sub-tables in the...
Int observationId(rownr_t rownr) const
Int spectralWindowId(rownr_t rownr) const
The spectralWindowId comes from the DATA_DESCRIPTION subtable, so dataDescId must first be valid in o...
MSValidIds()
Construct one unattached to a MeasurementSet.
Int polarizationId(rownr_t rownr) const
The polarizationId comes from the DATA_DESCRIPTION subtable, so dataDescId must first be valid in ord...
~MSValidIds()
The destructor.
MSColumns * romsCols_p
Definition: MSValidIds.h:126
Int stateId(rownr_t rownr) const
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Int dopplerId(rownr_t rownr) const
the dopplerId comes from the SPECTRAL_WINDOW subtable so spectralWindowId must first be valid in orde...
A Table intended to hold astronomical data (a set of Measurements).
Int fieldId(rownr_t rownr) const
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
MSValidIds & operator=(const MSValidIds &other)
Assignment operator, reference semantics.
A class to provide easy access to MeasurementSet columns.
Definition: MSColumns.h:116
void attach(const MeasurementSet &ms)
Attach this one to a MeasurementSet.
Bool checkRow(rownr_t rownr) const
Definition: MSValidIds.h:134