casacore
Loading...
Searching...
No Matches
TableMeasDescBase.h
Go to the documentation of this file.
1// # TableMeasDescBase.h: Definition of a Measure in a Table.
2// # Copyright (C) 1997,1999,2000,2001
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_TABLEMEASDESCBASE_H
27#define MEASURES_TABLEMEASDESCBASE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/measures/TableMeasures/TableMeasValueDesc.h>
32#include <casacore/measures/TableMeasures/TableMeasRefDesc.h>
33#include <casacore/measures/TableMeasures/TableMeasType.h>
34#include <casacore/casa/Quanta/Unit.h>
35#include <casacore/casa/Arrays/Vector.h>
36
37namespace casacore { // # NAMESPACE CASACORE - BEGIN
38
39// # Forward Declarations
40class String;
41class Table;
42class TableDesc;
43class TableRecord;
44class TableColumn;
45class Measure;
46template <class T>
47class Quantum;
48
49// <summary>
50// Definition of a Measure in a Table.
51// </summary>
52
53// <use visibility=local>
54
55// <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc">
56// </reviewed>
57
58// <prerequisite>
59// # Classes you should understand before using this one.
60// <li> <linkto module=Measures>Measures</linkto>
61// <li> <linkto module=Tables>Tables</linkto>
62// <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto>
63// </prerequisite>
64
65// <synopsis>
66// Abstract base class for TableMeasDesc.
67// </synopsis>
68
69// <example>
70// See class <linkto class="TableMeasDesc">TableMeasDesc</linkto>.
71// </example>
72
73// <motivation>
74// Creating the required keyword for the definition of a Measure
75// in a Table is somewhat complicated. This class assists in that
76// process.
77// </motivation>
78//
79// <thrown>
80// <li>AipsError during reconstruction if the column doesn't contain
81// a MEASINFO record.
82// <li>AipsError during reconstruction if the column has a MEASINFO
83// but it Measure type is invalid.
84// </thrown>
85//
86
87// # <todo asof="$DATE:$">
88// # A List of bugs, limitations, extensions or planned refinements.
89// # </todo>
90
92 public:
93 // Null constructor.
95
96 // Constructor with value and reference descriptors.
97 // Note that setMeasType is always called by the derived class.
99
100 // Copy constructor.
102
104
105 // Clone the object.
106 virtual TableMeasDescBase* clone() const;
107
108 // Assignment operator.
110
111 // Makes the descriptor persistent.
112 // <group>
114 void write(Table&);
115 // </group>
116
117 // Make the descriptor persistent if there was no refcode vector.
118 // This is only needed for old tables without such vectors.
119 void writeIfOld(const Table&);
120
121 // Get the name of the underlying column.
122 const String& columnName() const { return itsValue.columnName(); }
123
124 // Return the reference code.
125 uInt getRefCode() const { return itsRef.getRefCode(); }
126
127 // Returns True if the reference varies per row.
128 Bool isRefCodeVariable() const { return itsRef.isRefCodeVariable(); }
129
130 // Returns the name of the ref code column when the ref code is variable.
131 // The null string is returned if the ref code is not variable.
132 const String& refColumnName() const { return itsRef.columnName(); }
133
134 // Returns a reference to its measure reference descriptor.
135 const TableMeasRefDesc& getRefDesc() const { return itsRef; }
136
137 // Get the name of the offset column. Empty string is returned if no
138 // offset.
139 const String& offsetColumnName() const { return itsRef.offsetColumnName(); }
140
141 // Returns True if an offset has been defined.
142 Bool hasOffset() const { return itsRef.hasOffset(); }
143
144 // Returns True if the offset is variable.
145 Bool isOffsetVariable() const { return itsRef.isOffsetVariable(); }
146
147 // Returns True if the offset is variable and is stored in an
148 // ArrayMeasColumn, i.e., offsets are stored per element.
149 Bool isOffsetArray() const { return itsRef.isOffsetArray(); }
150
151 // Returns a reference to the offset.
152 const Measure& getOffset() const { return itsRef.getOffset(); }
153
154 // Returns the descriptors measure type as a String.
155 const String& type() const { return itsMeasType.type(); }
156
157 // Returns the reference code for this object given a string. Throws
158 // an exception if the refString is invalid for this object.
159 uInt refCode(const String& refString) const { return itsMeasType.refCode(refString); }
160
161 // Translates the refCode for the descriptors measure type.
162 const String& refType(uInt refCode) const { return itsMeasType.refType(refCode); }
163
164 // Return the Units of the Measure values
165 const Vector<Unit>& getUnits() const { return itsUnits; }
166
167 // Reset the refCode, offset, or units.
168 // It overwrites the value used when defining the TableMeasDesc.
169 // It is only possible if it was defined as fixed for the entire column.
170 // <group>
171 void resetRefCode(uInt refCode) { itsRef.resetRefCode(refCode); }
172 void resetOffset(const Measure& offset) { itsRef.resetOffset(offset); }
173 void resetUnits(const Vector<Unit>& units);
174 // </group>
175
176 // Reconstructs the object for the given table and column name.
178
179 // Does this column contain table measures?
180 static Bool hasMeasures(const TableColumn& column);
181
182 protected:
183 // Set the initial reference codes and types in the table.
184 void initTabRef(const MeasureHolder& measHolder);
185
186 // Set the measure and possible units.
187 void setMeasUnits(const Measure& meas, const Vector<Quantum<Double>>& val,
188 const Vector<Unit>& units);
189
190 private:
191 TableMeasValueDesc itsValue; // # The measure value column.
192 TableMeasRefDesc itsRef; // # The reference.
193 // # this gives access to the columns Measure type etc
196};
197
198} // namespace casacore
199
200#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
static TableMeasDescBase * reconstruct(const Table &tab, const String &columnName)
Reconstructs the object for the given table and column name.
const String & refType(uInt refCode) const
Translates the refCode for the descriptors measure type.
static Bool hasMeasures(const TableColumn &column)
Does this column contain table measures?
TableMeasDescBase(const TableMeasValueDesc &, const TableMeasRefDesc &)
Constructor with value and reference descriptors.
const String & offsetColumnName() const
Get the name of the offset column.
void initTabRef(const MeasureHolder &measHolder)
Set the initial reference codes and types in the table.
void resetOffset(const Measure &offset)
void setMeasUnits(const Measure &meas, const Vector< Quantum< Double > > &val, const Vector< Unit > &units)
Set the measure and possible units.
Bool isOffsetVariable() const
Returns True if the offset is variable.
virtual TableMeasDescBase * clone() const
Clone the object.
const Vector< Unit > & getUnits() const
Return the Units of the Measure values.
const String & refColumnName() const
Returns the name of the ref code column when the ref code is variable.
const Measure & getOffset() const
Returns a reference to the offset.
TableMeasDescBase()
Null constructor.
const TableMeasRefDesc & getRefDesc() const
Returns a reference to its measure reference descriptor.
Bool hasOffset() const
Returns True if an offset has been defined.
void write(TableDesc &)
Makes the descriptor persistent.
void resetRefCode(uInt refCode)
Reset the refCode, offset, or units.
const String & columnName() const
Get the name of the underlying column.
TableMeasDescBase(const TableMeasDescBase &that)
Copy constructor.
Bool isRefCodeVariable() const
Returns True if the reference varies per row.
TableMeasDescBase & operator=(const TableMeasDescBase &that)
Assignment operator.
Bool isOffsetArray() const
Returns True if the offset is variable and is stored in an ArrayMeasColumn, i.e., offsets are stored ...
const String & type() const
Returns the descriptors measure type as a String.
uInt refCode(const String &refString) const
Returns the reference code for this object given a string.
void writeIfOld(const Table &)
Make the descriptor persistent if there was no refcode vector.
uInt getRefCode() const
Return the reference code.
void resetUnits(const Vector< Unit > &units)
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
int offset(int, int) const
compute a linear offset from array indicies
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40