casacore
Loading...
Searching...
No Matches
TableMeasDesc.h
Go to the documentation of this file.
1//# TableMeasDesc.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_TABLEMEASDESC_H
27#define MEASURES_TABLEMEASDESC_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/measures/TableMeasures/TableMeasDescBase.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37class String;
38class Table;
39class TableMeasRefDesc;
40class TableMeasValueDesc;
41
42// <summary>
43// Definition of a Measure column in a Table.
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// </prerequisite>
56
57// <synopsis>
58// The TableMeasures system was created to add support for Measure
59// columns to the Casacore Table system.
60// Measures are not a fundamental type of the Tables system and hence
61// cannot be represented directly. Instead a Measure column can be created
62// with the aid of
63// the TableMeasDesc class hierarchy. The TableMeasDesc class hierarchy
64// creates a Measure column by associating some number of fundamental data
65// type Table
66// columns into a unit. The associations between these columns
67// is represented in the column keywords of each of
68// the columns which make up a specific Measure column.
69//
70// Creating and using Measure columns
71// is a three step process:
72// <ol>
73// <li> For each Measure column some number of columns are defined and added
74// to the Table descriptor.
75// <li> A TableMeasDesc object is used to define a (empty) Measure column
76// from the columns created in the first step.
77// <li> <linkto class="ScalarMeasColumn">(RO)ScalarMeasColumns</linkto> or
78// <linkto class="ArrayMeasColumn">(RO)ArrayMeasColumns</linkto> objects
79// are used to access the Measure column for the reading and writing
80// of Measures.
81// </ol>
82//
83// Defining a Measure column (that is, steps 1 and 2 above) is the more complex
84// operation. However, for each Measure column it is a once only operation.
85// After a Measure column has been created its subsequent use is not
86// much different to using "ordinary" Table columns. For information
87// on how to use a Measure column see the
88// <linkto class="ScalarMeasColumn">(RO)ScalarMeasColumns</linkto> and
89// <linkto class="ArrayMeasColumn">(RO)ArrayMeasColumns</linkto> classes.
90// <p>
91// The TableMeasDesc class hierarchy contains classes for defining each
92// component of the Measures to be contained in column. A
93// <linkto class="TableMeasOffsetDesc">TableMeasOffsetDesc</linkto> is used
94// to specify the offset component, a
95// <linkto class="TableMeasRefDesc">TableMeasRefDesc</linkto> to set up
96// the reference code component and a
97// <linkto class="TableMeasValueDesc">TableMeasValueDesc</linkto> names the
98// column used as the main Measure column through which the
99// Measure column is subsequently accessed.
100// <br>
101// The final step needed to create a Measure column is the creation of a
102// TableMeasDesc object whose
103// constructor takes a TableMeasValueDesc and (optionally) a
104// TableMeasRefDesc. After construction the TableMeasDesc object's
105// write() member is used to make the
106// the Measure column persistent within the Table.
107// <p>
108// The following examples demonstrate the creation of Measure columns using
109// the above components. Further details about each of these components
110// is available with each class description.
111// <br>
112// All examples write the measure description into a TableDesc object,
113// i.e. the argument used in the TableMeasDesc::write function is a
114// TableDesc object. It is, however, also possible to write them
115// into a Table object which is useful if measure columns are added
116// to an already existing table (see example 2).
117// </synopsis>
118
119// <example>
120//<ol>
121// <li> The following creates a MEpoch column with a fixed reference.
122// <srcblock>
123// // Need a table to work with.
124// TableDesc td("measureTable_desc", "1", TableDesc::New);
125// td.comment() = "A test of TableMeasures class.";
126//
127// // Define a column and add it to the table
128// // The main measure column is always an Array column of type Double
129// ArrayColumnDesc<Double> cdTime("Time", "An MEpoch column");
130// td.addColumn(cdtime);
131//
132// // Create the Measure column for an MEpoch. The MEpoch in
133// // the column has reference code MEpoch::TAI
134// TableMeasRefDesc measRef(MEpoch::TAI);
135// TableMeasValueDesc measVal(td, "Time");
136// TableMeasDesc<MEpoch> mepochCol(measVal, measRef);
137// // write makes the Measure column persistent.
138// mepochCol.write(td);
139//
140// // create the table with 5 rows
141// SetupNewTable newtab("MeasuresTable", td, Table::New);
142// Table tab(newtab, 5);
143// </srcblock>
144
145// <li> Same as example above, but for an already existing table.
146// <srcblock>
147// // Need a table to work with.
148// TableDesc td("measureTable_desc", "1", TableDesc::New);
149// td.comment() = "A test of TableMeasures class.";
150//
151// // Define a column and add it to the table
152// // The main measure column is always an Array column of type Double
153// ArrayColumnDesc<Double> cdTime("Time", "An MEpoch column");
154// td.addColumn(cdtime);
155//
156// // create the table with 5 rows
157// SetupNewTable newtab("MeasuresTable", td, Table::New);
158// Table tab(newtab, 5);
159//
160// // Create the Measure column for an MEpoch. The MEpoch in
161// // the column has reference code MEpoch::TAI
162// TableMeasRefDesc measRef(MEpoch::TAI);
163// TableMeasValueDesc measVal(tab.tableDesc(), "Time");
164// TableMeasDesc<MEpoch> mepochCol(measVal, measRef);
165// // write makes the Measure column persistent.
166// mepochCol.write(tab);
167// </srcblock>
168
169// <li> An MEpoch column with a variable reference code with a fixed offset:
170// <srcblock>
171// // The following three columns will be used to set up a Scalar MEpoch
172// // column with variable references and offsets. 3 columns are needed.
173// // The "main" column where the MEpoch will be stored
174// ArrayColumnDesc<Double> cdTime("Time", "An MEpoch column");
175
176// // Variable (i.e., per row) reference code storage needs a column.
177// // The column type is either Int or String (Int is faster but String
178// // may be useful when browsing the table). Either a Scalar column or
179// // Array column can be used here dependent on whether a Scalar or
180// // Array Measure column is used and whether in case of an Array Measure
181// // column the reference code has to be variable per array element.
182// ScalarColumnDesc<Int> cdRef("TimeRef", "Reference column for Time");
183//
184// // add the columns to the Table decriptor
185// td.addColumn(cdTime);
186// td.addColumn(cdRef);
187//
188// // now create the MEpoch column.
189// // want a fixed offset. Offsets are Measures
190// MEpoch offset(MVEpoch(MVTime(1996, 5, 17), MEpoch::UTC);
191// TableMeasOffsetDesc offsetDesc(offset);
192// // the reference
193// TableMeasRefDesc measRef(td, "TimeRef", offsetDesc);
194// // the value descriptor, create and write the column
195// TableMeasValueDesc measVal(td, "Time");
196// TableMeasDesc<MEpoch> mepochCol(measVal, measRef);
197// mepochCol.write();
198//
199// // create the table, etc
200// ...
201// </srcblock>
202//
203// <li> An MEpoch column with a variable reference code and offset
204// <srcblock>
205// // Variable (per row storage of) offsets needs its own column. Measure
206// // offsets are Measures therefore a Measure column is needed.
207// ArrayColumnDesc<Double> cdOffset("OffsetCol", "Variable Offset col");
208//
209// // A column for the variable reference code
210// ScalarColumnDesc<String> cdRef("RefCol", "Variable reference column");
211//
212// // The main (value) column for the Measure column
213// ArrayColumnDesc<Double> cdTime("Time", "MEpoch column");
214//
215// // add the column descriptors to the table
216// td.addColumn(cdOffset);
217// td.addColumn(cdRef);
218// td.addColumn(cdTime);
219//
220// // Create the Measure column
221//
222// // The offset column is itself a Measure column, but write() is not
223// // called
224// TableMeasValueDesc offsetVal(td, "OffsetCol");
225// TableMeasDesc<MEpoch> offset(offsetVal);
226// TableMeasOffsetDesc offsetDesc(offset);
227//
228// // the reference
229// TableMeasRefDesc ref(td, "RefCol", offsetDesc);
230//
231// // create the Measure column
232// TableMeasValueDesc val(td, "Time");
233// TableMeasDesc<MEpoch> mepochCol(val, ref);
234// mepochCol.write();
235
236// // create the table, etc
237// ...
238// </srcblock>
239//</ol>
240// </example>
241
242// <motivation>
243// Creating the required keyword for the definition of a Measure
244// in a Table is somewhat complicated. This class assists in that
245// process.
246// </motivation>
247//
248// <thrown>
249// <li>AipsError if a reference code string is invalid.
250// </thrown>
251//
252//# <todo asof="$DATE:$">
253//# A List of bugs, limitations, extensions or planned refinements.
254//# </todo>
255
256
257template<class M> class TableMeasDesc : public TableMeasDescBase
258{
259public:
260 // Constructor with measure value descriptor. The Measure reference for
261 // the column will be the default reference code for M. Units for the
262 // column will be the default for the Measure type.
264
265 // Constructor with measure value descriptor and Vector of Units.
266 // The Measure reference for the column will be the default reference
267 // code for the Measure type. Number of Units must be compatible
268 // with the Measure.
270
271 // Constructor with value and reference descriptors. Units for the
272 // column will be the default for Measure type.
274
275 // Constructor with value and reference descriptors and Vector of
276 // Units. Number of Units must be compatible with the Measure.
278 const Vector<Unit>&);
279
280 // Clone the object.
281 virtual TableMeasDescBase* clone() const;
282
283 // Copy constructor (copy semantics).
285
287
288 // Assignment operator (copy semantics)
290};
291
292
293
294} //# NAMESPACE CASACORE - END
295
296#ifndef CASACORE_NO_AUTO_TEMPLATES
297#include <casacore/measures/TableMeasures/TableMeasDesc.tcc>
298#endif //# CASACORE_NO_AUTO_TEMPLATES
299#endif
TableMeasDesc< M > & operator=(const TableMeasDesc< M > &that)
Assignment operator (copy semantics)
TableMeasDesc(const TableMeasDesc< M > &that)
Copy constructor (copy semantics).
TableMeasDesc(const TableMeasValueDesc &)
Constructor with measure value descriptor.
TableMeasDesc(const TableMeasValueDesc &, const TableMeasRefDesc &, const Vector< Unit > &)
Constructor with value and reference descriptors and Vector of Units.
TableMeasDesc(const TableMeasValueDesc &, const TableMeasRefDesc &)
Constructor with value and reference descriptors.
virtual TableMeasDescBase * clone() const
Clone the object.
TableMeasDesc(const TableMeasValueDesc &, const Vector< Unit > &)
Constructor with measure value descriptor and Vector of Units.
this file contains all the compiler specific defines
Definition mainpage.dox:28