casacore
Loading...
Searching...
No Matches
TableMeasOffsetDesc.h
Go to the documentation of this file.
1//# TableMeasOffseDesc.h: Definition of an Offset 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_TABLEMEASOFFSETDESC_H
27#define MEASURES_TABLEMEASOFFSETDESC_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicSL/String.h>
32#include <casacore/measures/Measures/MeasureHolder.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37class TableMeasDescBase;
38class Measure;
39class Table;
40class TableDesc;
41class TableRecord;
42class String;
43
44
45// <summary>
46// Definition of a Measure Offset in a Table.
47// </summary>
48
49// <use visibility=export>
50
51// <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc">
52// </reviewed>
53
54// <prerequisite>
55//# Classes you should understand before using this one.
56// <li> <linkto module=Measures>Measures</linkto>
57// <li> <linkto module=Tables>Tables</linkto>
58// <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto>
59// </prerequisite>
60
61// <synopsis>
62// This class assists in the definition of the offset component of a
63// TableMeasDesc
64// in the TableMeasures system. Four possibilities exist for specifying the
65// handling of measure offsets in a Measure column. These are:
66//
67// <ul>
68// <li> an offset is not used
69// <li> all measures in the column have the same offset
70// <li> a unique (and probably different) offset is stored for each row
71// <li> a unique offset is stored in each array element per (Array)column
72// row
73// </ul>
74//
75// Note that this last option is only relevant when using ArrayMeasColumns.
76//
77// Examples of each of these follow.
78// </synopsis>
79
80// <example>
81//<ol>
82// <li>Specifying a single fixed offset. Note that a Measure offset is itself
83// a measure
84// <srcblock>
85// // create an MEpoch to use as the offset in an MEpoch column
86// MEpoch offset(MVEpoch(MVTime(1996, 5, 17, (8+18./60.)/24.)), MEpoch::UTC);
87// TableMeasOffsetDesc offsetDesc(offset);
88// </srcblock>
89//
90// <li>Storing an offset per row needs an offset column. Measure offsets are
91// Measures so a Measure column is needed:
92// <srcblock>
93// // Need a column for the offsets. This is to be a Measure column,
94// // so the rules for creating a Measure column apply.
95// ArrayColumnDesc<Double> cdOffset("OffsetCol", "Variable Offset col");
96// ...
97// // add the column to the table
98// td.addColumn(cdOffset);
99// ...
100// // Create the Measure column to be used as the measure offset column
101// TableMeasValueDesc valDesc(td, "OffsetCol");
102// TableMeasDesc<MEpoch> offset(valDesc);
103// // Create the offset descriptor
104// TableMeasOffsetDesc offsetDesc(offset);
105//
106// </srcblock>
107//
108// <li>Storing an offset per array element per row requires one change in the
109// constructor used in the previous example:
110// <srcblock>
111// ...
112// // set up column and TableMeasDesc as before
113// ...
114// // Setting the asArray parameter to True in the constructor specifies
115// // per element offset storage
116// TableMeasOffsetDesc offsetDesc(offset, True);
117// </srcblock>
118// </ol>
119//
120// For an example of the use of the TableMeasOffsetDesc class in the context
121// of a full TableMeasDesc declaration see class
122// <linkto class="TableMeasDesc">TableMeasDesc</linkto>.
123// </example>
124
125// <motivation>
126// Creating the required keyword for the definition of a Measure
127// in a Table is somewhat complicated. This class assists in that
128// process.
129// </motivation>
130//
131// <thrown>
132// <li>AipsError during reconstruction of non-variable offset if a
133// component of the offset measure is missing in the column keywords or
134// is corrupt in some way.
135// <li>AipsError if getOffset() called on a variable offset object.
136// <li>AipsError during a reconstruct if the column doesn't have a Unit.
137// </thrown>
138//
139//# <todo asof="$DATE:$">
140//# A List of bugs, limitations, extensions or planned refinements.
141//# </todo>
142
144{
145public:
146 // Constructor which defines a constant (non-variable) offset. All
147 // measures in the columns will have the same offset.
149
150 // Constructor for defining a variable offset. If asArray is True then
151 // the offset is stored per array element. The default is for the
152 // offset to be stored (and hence variable) per row.
154 Bool asArray=False);
155
156 // Copy constructor (copy semantics).
158
160
161 // Assignment operator (copy semantics).
163
164 // Reconstructs the TableMeasOffsetDesc from the measInfo TableRecord.
166 const String& prefix,
167 const Table& tab);
168
169 // Get the (non-variable) measure offset for this column. If it doesn't
170 // exist (thus if the offset is variable), an exception is thrown.
171 const Measure& getOffset() const;
172
173 // Returns True if the offset varies per row.
175 { return (itsTMDesc != 0); }
176
177 // Returns True if the offset varies per array element.
178 Bool isArray() const
179 { return (isVariable() && itsVarPerArr); }
180
181 // Gets the name of the column which stores the variable offset.
182 // "" is returned if the offset is not variable.
183 const String& columnName() const
184 { return itsVarColName; }
185
186 // Reset the offset.
187 // It overwrites the value used when defining the TableMeasDesc.
188 // It is only possible if it was defined as fixed for the entire column.
189 void resetOffset (const Measure& offset);
190
191 // Write the information into the record.
192 // <group>
193 void write (TableDesc&, TableRecord& measInfo, const String& prefix);
194 void write (Table&, TableRecord& measInfo, const String& prefix);
195 // </group>
196
197private:
198 TableMeasDescBase* itsTMDesc; //# Stores variable offset if applicable
199 MeasureHolder itsMeasure; //# The offset if non-variable.
200 String itsVarColName; //# "" if offset non-variable.
201 Bool itsVarPerArr; //# Is variable per array element.
202
203
204 // Constructor which uses the measInfo TableRecord.
205 TableMeasOffsetDesc (const TableRecord& measInfo, const String& prefix,
206 const Table&);
207
208 // Write the actual keywords.
209 void writeKeys (TableRecord& measInfo, const String& prefix);
210};
211
212
213
214} //# NAMESPACE CASACORE - END
215
216#endif
String: the storage and methods of handling collections of characters.
Definition String.h:223
TableMeasOffsetDesc(const TableMeasDescBase &offsetColumn, Bool asArray=False)
Constructor for defining a variable offset.
void resetOffset(const Measure &offset)
Reset the offset.
const String & columnName() const
Gets the name of the column which stores the variable offset.
void write(Table &, TableRecord &measInfo, const String &prefix)
const Measure & getOffset() const
Get the (non-variable) measure offset for this column.
void writeKeys(TableRecord &measInfo, const String &prefix)
Write the actual keywords.
TableMeasOffsetDesc(const TableMeasOffsetDesc &that)
Copy constructor (copy semantics).
TableMeasOffsetDesc(const TableRecord &measInfo, const String &prefix, const Table &)
Constructor which uses the measInfo TableRecord.
Bool isArray() const
Returns True if the offset varies per array element.
void write(TableDesc &, TableRecord &measInfo, const String &prefix)
Write the information into the record.
static TableMeasOffsetDesc * reconstruct(const TableRecord &measInfo, const String &prefix, const Table &tab)
Reconstructs the TableMeasOffsetDesc from the measInfo TableRecord.
TableMeasOffsetDesc & operator=(const TableMeasOffsetDesc &that)
Assignment operator (copy semantics).
Bool isVariable() const
Returns True if the offset varies per row.
TableMeasOffsetDesc(const Measure &offset)
Constructor which defines a constant (non-variable) offset.
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40