casacore
Loading...
Searching...
No Matches
TableMeasColumn.h
Go to the documentation of this file.
1// # TableMeasColumn.h: Access to Measure Columns in Tables
2// # Copyright (C) 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: casa-feedback@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#ifndef MEASURES_TABLEMEASCOLUMN_H
27#define MEASURES_TABLEMEASCOLUMN_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/Tables/TableColumn.h>
32#include <memory>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
37class String;
38class Table;
40
41// <summary>
42// Read only access to table scalar Measure columns.
43// </summary>
44
45// <use visibility=export>
46
47// <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc">
48// </reviewed>
49
50// <prerequisite>
51// # Classes you should understand before using this one.
52// <li> <linkto module=Measures>Measures</linkto>
53// <li> <linkto module=Tables>Tables</linkto>
54// <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto>
55// </prerequisite>
56
57// <synopsis>
58// TableMeasColumn is the base class for the templated classes
59// <linkto class=ScalarMeasColumn>ScalarMeasColumn</linkto> and
60// <linkto class=ArrayMeasColumn>ArrayMeasColumn</linkto>
61// which give access to table columns containing
62// <linkto module=Measures>measures</linkto>.
63//
64// This base class offers some common functionality like getting
65// the column name and testing if a row of the column contains a value.
66// Its main function is <src>measDesc()</src>, which gives access
67// to the <linkto class=TableMeasDescBase>TableMeasDescBase</linkto>
68// object containing a description of the measure column.
69// </synopsis>
70
71// <example>
72// <srcblock>
73// // Create the object for measure column Time1.
74// TableMeasColumn timeCol(tab, "Time1");
75//
76// // print some details about the column
77// if (timeCol.measDesc().isRefCodeVariable()) {
78// cout << "The column has variable references." << endl;
79// } else {
80// cout << "The fixed MeasRef for the column is: "
81// << timeCol.getMeasRef() << endl;
82// }
83// </srcblock>
84// </example>
85
86// <motivation>
87// This class contains the common functionality for the templated
88// derived classes.
89// </motivation>
90
91// # <todo asof="$DATE:$">
92// # </todo>
93
95 public:
96 // The default constructor creates a null object. Useful for creating
97 // arrays of ScalarMeasColumn objects. Attempting to use a null object
98 // will produce a segmentation fault so care needs to be taken to
99 // initialise the objects first by using attach().
100 // An ScalarMeasColumn object can be tested if it is null by using the
101 // isNull() member.
103
104 // Create the ScalarMeasColumn from the table and column Name.
106
107 // Copy constructor (copy semantics).
109
111
112 // Change the reference to another column.
113 void reference(const TableMeasColumn& that);
114
115 // Attach another column to the object.
116 void attach(const Table& tab, const String& columnName);
117
118 // Tests if a row contains a Measure (i.e., if the row has a defined
119 // value).
120 Bool isDefined(rownr_t rownr) const;
121
122 // Get access to the TableMeasDescBase describing the column.
123 // <group>
124 const TableMeasDescBase& measDesc() const { return *itsDescPtr; }
126 // </group>
127
128 // Test if the object is null.
129 Bool isNull() const { return !itsDescPtr; }
130
131 // Throw an exception if the object is null.
132 void throwIfNull() const;
133
134 // Get the name of the column.
135 const String& columnName() const;
136
137 // Get the Table object this column belongs to.
138 Table table() const;
139
140 // Is the column a scalar measures column?
141 // It is if the underlying column is a scalar column or an array
142 // column with a fixed 1-dimensional shape.
143 // <br>Otherwise it is an array measures column.
144 // <note role=caution>
145 // It is not 100% determined if a measure column is an array or a scalar.
146 // If the underlying table column is an array with a variable shape,
147 // this function will see it as an array measure column. However,
148 // it might be accessible as a scalar measure column.
149 // </note>
150 Bool isScalar() const;
151
152 protected:
153 // # The measure's value is represented by this many data components.
155 // # The Measure Column description.
156 std::shared_ptr<TableMeasDescBase> itsDescPtr;
157 // # The data column.
159 // # Does the measure column have a variable reference or offset?
162
163 private:
164 // Assignment makes no sense in a readonly class.
165 // Declaring this operator private makes it unusable.
167};
168
169// For backwards compatibility:
170
171#define ROTableMeasColumn TableMeasColumn
172
173} // namespace casacore
174
175#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
Table table() const
Get the Table object this column belongs to.
TableMeasColumn & operator=(const TableMeasColumn &that)
Assignment makes no sense in a readonly class.
const String & columnName() const
Get the name of the column.
const TableMeasDescBase & measDesc() const
Get access to the TableMeasDescBase describing the column.
std::shared_ptr< TableMeasDescBase > itsDescPtr
Bool isDefined(rownr_t rownr) const
Tests if a row contains a Measure (i.e., if the row has a defined value).
void reference(const TableMeasColumn &that)
Change the reference to another column.
TableMeasColumn(const TableMeasColumn &that)
Copy constructor (copy semantics).
TableMeasColumn(const Table &tab, const String &columnName)
Create the ScalarMeasColumn from the table and column Name.
void throwIfNull() const
Throw an exception if the object is null.
Bool isNull() const
Test if the object is null.
TableMeasColumn()
The default constructor creates a null object.
void attach(const Table &tab, const String &columnName)
Attach another column to the object.
TableMeasDescBase & measDesc()
Bool isScalar() const
Is the column a scalar measures column?
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44