casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableMeasValueDesc.h
Go to the documentation of this file.
1 //# TableMeasValueDesc.h: Definition of a MeasValue 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: aips2-request@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 //# $Id$
27 
28 #ifndef MEASURES_TABLEMEASVALUEDESC_H
29 #define MEASURES_TABLEMEASVALUEDESC_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 class ColumnDesc;
39 class Table;
40 class TableDesc;
41 class TableRecord;
42 
43 
44 // <summary>
45 // Definition of a Measure Value in a Table.
46 // </summary>
47 
48 // <use visibility=export>
49 
50 // <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> <linkto module=Measures>Measures</linkto>
56 // <li> <linkto module=Tables>Tables</linkto>
57 // <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto>
58 // </prerequisite>
59 
60 // <synopsis>
61 // TableMeasValueDesc is a class for setting up the Measure value
62 // component of the TableMeasDesc in the TableMeasures system. Its purpose
63 // it to specify the Table column to be used as a Measure column through
64 // which Measures are subsequently written to and read from via
65 // either an <linkto class="ArrayMeasColumn">ArrayMeasColumn</linkto>
66 // or <linkto class="ScalarMeasColumn">ScalarMeasColumn</linkto> object.
67 //
68 // The column used as the Measure column is always an ArrayColumn<Double>
69 // irrespective of whether it is to store scalars or arrays of Measures and
70 // irrespective of the type of Measure.
71 // </synopsis>
72 
73 // <example>
74 //<ol>
75 // <li>
76 // <srcblock>
77 // // Add a column to the table. This column is to be used to store
78 // // MPositions. Measure columns are alway ArrayColumn<Double>
79 // ArrayColumnDesc<Double> cdPosCol("MPosColumn", "MPosition column");
80 // td.addColumn(cdPosCol);
81 // ...
82 // // create the TableMeasValueDesc object
83 // TableMeasValueDesc valueDesc(td, "MPosColumn");
84 // </srcblock>
85 //</ol>
86 // For an example of the use of the TableMeasValueDesc class in the context
87 // of a full TableMeasDesc declaration see class
88 // <linkto class="TableMeasDesc">TableMeasDesc</linkto>.
89 // </example>
90 
91 // <motivation>
92 // Creating the required keyword for the definition of a Measure
93 // in a Table is somewhat complicated. This class assists in that
94 // process.
95 // </motivation>
96 //
97 // <thrown>
98 // <li>AipsError if the specified column doesn't exist or it isn't
99 // an ArrayColumn or its type is not Double.
100 // </thrown>
101 //
102 //# <todo asof="$DATE:$">
103 //# A List of bugs, limitations, extensions or planned refinements.
104 //# </todo>
105 
106 
108 {
109 public:
110  // Null constructor
112 
113  // Construct the MeasValue column descriptor for the given column.
114  // The column must be a column of type Double and should exist in
115  // the TableDesc.
117 
118  // Construct the MeasValue column descriptor for the given column.
119  // Checking if the column exists is done in the write function.
120  // <group>
121  TableMeasValueDesc (const String& columnName)
122  : itsColumn (columnName) {}
123  TableMeasValueDesc (const Char* columnName)
124  : itsColumn (columnName) {}
125  // </group>
126 
127  // Copy constructor.
129 
131 
132  // Assignment operator.
134 
135  // Write the type, unit, and MEASINFO record into the column keywords.
136  // It checks if the column exists in the given table description.
137  // <group>
138  void write (TableDesc&, const TableRecord& measInfo);
139  void write (Table&, const TableRecord& measInfo);
140  // </group>
141 
142  // Get the name of the underlying column.
143  const String& columnName() const
144  { return itsColumn; }
145 
146 private:
147  String itsColumn; //# MeasValue column name.
148 
149 
150  // Write the actual keywords.
151  void writeKeys (TableRecord& columnKeyset,
152  const TableRecord& measInfo);
153 
154  // Throw an exception if the quantum column doesn't exist or is of the
155  // wrong type.
156  void checkColumn (const TableDesc& td) const;
157 };
158 
159 
160 
161 } //# NAMESPACE CASACORE - END
162 
163 #endif
void checkColumn(const TableDesc &td) const
Throw an exception if the quantum column doesn&#39;t exist or is of the wrong type.
TableMeasValueDesc & operator=(const TableMeasValueDesc &that)
Assignment operator.
Main interface class to a read/write table.
Definition: Table.h:157
void write(TableDesc &, const TableRecord &measInfo)
Write the type, unit, and MEASINFO record into the column keywords.
char Char
Definition: aipstype.h:46
TableMeasValueDesc(const String &columnName)
Construct the MeasValue column descriptor for the given column.
void writeKeys(TableRecord &columnKeyset, const TableRecord &measInfo)
Write the actual keywords.
TableMeasValueDesc(const Char *columnName)
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:185
const String & columnName() const
Get the name of the underlying column.
Definition of a Measure Value in a Table.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Define the structure of a Casacore table.
Definition: TableDesc.h:190
TableMeasValueDesc()
Null constructor.