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