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> class Quantum;
47
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{
93public:
94 // Null constructor.
96
97 // Constructor with value and reference descriptors.
98 // Note that setMeasType is always called by the derived class.
100
101 // Copy constructor.
103
105
106 // Clone the object.
107 virtual TableMeasDescBase* clone() const;
108
109 // Assignment operator.
111
112 // Makes the descriptor persistent.
113 // <group>
115 void write (Table&);
116 // </group>
117
118 // Make the descriptor persistent if there was no refcode vector.
119 // This is only needed for old tables without such vectors.
120 void writeIfOld (const Table&);
121
122 // Get the name of the underlying column.
123 const String& columnName() const
124 { return itsValue.columnName(); }
125
126 // Return the reference code.
128 { return itsRef.getRefCode(); }
129
130 // Returns True if the reference varies per row.
133
134 // Returns the name of the ref code column when the ref code is variable.
135 // The null string is returned if the ref code is not variable.
136 const String& refColumnName() const
137 { return itsRef.columnName(); }
138
139 // Returns a reference to its measure reference descriptor.
141 { return itsRef; }
142
143 // Get the name of the offset column. Empty string is returned if no
144 // offset.
146 { return itsRef.offsetColumnName(); }
147
148 // Returns True if an offset has been defined.
150 { return itsRef.hasOffset(); }
151
152 // Returns True if the offset is variable.
154 { return itsRef.isOffsetVariable(); }
155
156 // Returns True if the offset is variable and is stored in an
157 // ArrayMeasColumn, i.e., offsets are stored per element.
159 { return itsRef.isOffsetArray(); }
160
161 // Returns a reference to the offset.
162 const Measure& getOffset() const
163 { return itsRef.getOffset(); }
164
165 // Returns the descriptors measure type as a String.
166 const String& type() const
167 { return itsMeasType.type(); }
168
169 // Returns the reference code for this object given a string. Throws
170 // an exception if the refString is invalid for this object.
171 uInt refCode (const String& refString) const
172 { return itsMeasType.refCode(refString); }
173
174 // Translates the refCode for the descriptors measure type.
175 const String& refType (uInt refCode) const
176 { return itsMeasType.refType(refCode); }
177
178 // Return the Units of the Measure values
179 const Vector<Unit>& getUnits() const
180 { return itsUnits; }
181
182 // Reset the refCode, offset, or units.
183 // It overwrites the value used when defining the TableMeasDesc.
184 // It is only possible if it was defined as fixed for the entire column.
185 // <group>
188 void resetOffset (const Measure& offset)
189 { itsRef.resetOffset (offset); }
190 void resetUnits (const Vector<Unit>& units);
191 // </group>
192
193 // Reconstructs the object for the given table and column name.
195 const String& columnName);
196
197 // Does this column contain table measures?
198 static Bool hasMeasures (const TableColumn& column);
199
200protected:
201 // Set the initial reference codes and types in the table.
202 void initTabRef (const MeasureHolder& measHolder);
203
204 // Set the measure and possible units.
205 void setMeasUnits (const Measure& meas,
206 const Vector<Quantum<Double> >& val,
207 const Vector<Unit>& units);
208
209private:
210 TableMeasValueDesc itsValue; //# The measure value column.
211 TableMeasRefDesc itsRef; //# The reference.
212 //# this gives access to the columns Measure type etc
215};
216
217
218
219} //# NAMESPACE CASACORE - END
220
221#endif
String: the storage and methods of handling collections of characters.
Definition String.h:223
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)
Bool isRefCodeVariable() const
Is the reference variable?
const Measure & getOffset() const
Return the fixed Measure offset.
uInt getRefCode() const
Return the reference code.
Bool isOffsetArray() const
Returns True is the offset is variable and it is an ArrayMeasColumn.
const String & columnName() const
Return the name of its variable reference code column.
Bool isOffsetVariable() const
Returns True if the offset is variable.
const String & offsetColumnName() const
Return the name of the Measure offset column.
Bool hasOffset() const
Returns True if the reference has an offset.
void resetRefCode(uInt refCode)
Reset the refCode or offset.
void resetOffset(const Measure &offset)
const String & type() const
Returns the descriptor's measure type as a String.
uInt refCode(const String &refString) const
Returns the reference code for this object given a string.
const String & refType(uInt refCode) const
Translates the refCode for the descriptors measure type.
const String & columnName() const
Get the name of the underlying column.
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