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