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