casacore
Loading...
Searching...
No Matches
ScaColDesc.h
Go to the documentation of this file.
1//# ScaColDesc.h: Templated class for description of table scalar columns
2//# Copyright (C) 1994,1995,1996,1997,1998,2000
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 TABLES_SCACOLDESC_H
27#define TABLES_SCACOLDESC_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/Tables/BaseColDesc.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37class PlainColumn;
38class ColumnSet;
39
40
41// <summary>
42// Templated class to define columns of scalars in tables
43// </summary>
44
45// <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
46// </reviewed>
47
48// <use visibility=export>
49
50// <prerequisite>
51// <li> BaseColumnDesc
52// <li> TableDesc
53// </prerequisite>
54
55// <etymology>
56// This class builds descriptions of table columns where each cell (which
57// may also be called a row) will hold a scalar value.
58// </etymology>
59
60// <synopsis>
61// ScalarColumnDesc is a templated class for defining a
62// table column containing scalar values.
63// Note that class
64// <linkto class=ScalarRecordColumnDesc>ScalarRecordColumnDesc</linkto>
65// has to be used to define the description of a column containing records.
66// <p>
67// The table values are handled by a data manager. This can be
68// a storage manager to store the values in a file or it can be
69// a virtual column engine to calculate them on-the-fly.
70// Only the basic data types are allowed when storing in a file. These are:
71// Bool, uChar, Short, uShort, Int, uInt, Int64, float, double,
72// Complex, DComplex and String.
73// <p>
74// At table creation time (when a table gets created from a table
75// description), each column needs to be bound to a data manager.
76// If not done explicitly, the table system will bind a column to the
77// default data manager defined in the column description.
78// <p>
79// A scalar column description consists of the following attributes:
80// <ul>
81// <li> Name, which has to be unique and must also be different
82// from possible table keyword names.
83// <li> Data type, which is determined by the template parameter
84// (e.g. ArrayColumnDesc<Int>).
85// <li> A data type id, which tells the unique name of non-standard
86// data types (i.e. for data type == TpOther).
87// <li> Comment, which defaults to an empty string.
88// This serves purely as an informational string for the user.
89// <li> Default value, which is only possible for the standard data types.
90// It defaults to the undefined value defined in ValType.h.
91// When a row gets added to a table, it is possible to
92// initialize the column fields in the row with this default value.
93// <li> Default data manager, which will be used if a column
94// for a newly created table is not explicitly bound to a
95// data manager.
96// <li> Data manager group, which serves 2 purposes.
97// Firstly it can be used in class SetupNewTable to bind a group
98// of columns.
99// Secondly, when the default data managers are used, it
100// allows, for example, to have 2 StandardStMan storage managers.
101// One for one group of columns and one for another group of columns.
102// <li> Options. These are defined in ColumnDesc.h and can be combined
103// by or-ing them.
104// Currently only the Undefined flag applies to scalars.
105// <li> Default keyword set, which defaults to an empty set.
106// When a table column gets created from the description, it gets
107// a copy of this keyword set as its initial keyword set.
108// </ul>
109//
110// There are several constructors, which allow to define most
111// of the above mentioned attributes. Others, like the default keyword
112// set, have to be defined explicitly.
113// <p>
114// This class is derived from BaseColumnDesc, thus the functions
115// in there also apply to this class.
116// <br>
117// Once a column description is setup satisfactorily, it must be added
118// to a table description before it can be used by the table system.
119// </synopsis>
120
121// <example>
122// <srcblock>
123// TableDesc tabDesc("tTableDesc", "1", TableDesc::New);
124//
125// // Add a scalar integer column ac, define keywords for it
126// // and define a default value 0.
127// ScalarColumnDesc<Int> acColumn("ac");
128// acColumn.rwKeywordSet().define ("scale", Complex(0));
129// acColumn.rwKeywordSet().define ("unit", "");
130// acColumn.setDefault (0);
131// tabDesc.addColumn (acColumn);
132//
133// // Add another column, now with data type String..
134// // This can be added directly, because no special things like
135// // keywords or default values have to be set.
136// tabDesc.addColumn (ScalarColumnDesc<String>("name", "comments"));
137// </srcblock>
138// </example>
139
140// <motivation>
141// Several column description classes are needed to allow the user
142// to define attributes which are special for each column type.
143// For scalars the special attribute is the default value.
144// They all have to be templated to support arbitrary data types.
145// </motivation>
146
147// <templating arg=T>
148// <li> Default constructor
149// <li> Copy constructor
150// <li> Assignment operator
151// <li> <src>static String dataTypeId(); // (not needed for builtin types)</src>
152// This should return the unique "name" of the class.
153// </templating>
154
155// <todo asof="$DATE:$">
156//# A List of bugs, limitations, extensions or planned refinements.
157// </todo>
158
159
160template<class T>
162{
163friend class ColumnDesc;
164
165public:
166 // Construct the column with the given name.
167 // The data manager type defaults to the StandardStMan storage manager.
168 // The data manager group defaults to the data manager type.
169 // The possible options are defined in ColumnDesc.h.
170 explicit ScalarColumnDesc (const String& name, int options = 0);
171
172 // Construct the column with the given name and comment.
173 // The data manager type defaults to the StandardStMan storage manager.
174 // The data manager group defaults to the data manager type.
175 // The possible options are defined in ColumnDesc.h.
177 int options = 0);
178
179 // Construct the column with the given name, comment, and
180 // default data manager type and group.
181 // A blank data manager group defaults to the data manager type.
182 // The possible options are defined in ColumnDesc.h.
184 const String& dataManName, const String& dataManGroup,
185 int options = 0);
186
187 // Construct the column with the given name, comment, default
188 // data manager type and group, and default value.
189 // A blank data manager group defaults to the data manager type.
190 // The possible options are defined in ColumnDesc.h.
192 const String& dataManName, const String& dataManGroup,
193 const T& defaultValue, int options = 0);
194
195 // Copy constructor (copy semantics);
197
199
200 // Assignment (copy semantics);
202
203 // Clone this column description.
205
206 // Get the name of this class. It is used by the registration process.
207 // The template argument gets part of the name.
209
210 // Set the default value.
213
214 // Get the default value.
215 const T& defaultValue() const
216 { return defaultVal_p; }
217
218 // Create a Column object out of this.
219 // This is used by class ColumnSet to construct a table column object.
221
222 // Make a ConcatColumn object out of the description.
224
225 // Show the column.
226 void show (ostream& os) const;
227
228 // Register the construction function of this class.
229 void registerClass() const;
230
231 // Create the object from AipsIO (this function is registered).
233
234private:
235 T defaultVal_p; //# default value
236
237 // Put the object.
238 virtual void putDesc (AipsIO&) const;
239
240 // Get the object.
241 virtual void getDesc (AipsIO&);
242};
243
244
245//# Explicitly instantiate these templates in ScaColDesc_tmpl.cc
246 extern template class ScalarColumnDesc<Bool>;
247 extern template class ScalarColumnDesc<Char>;
248 extern template class ScalarColumnDesc<Short>;
249 extern template class ScalarColumnDesc<uShort>;
250 extern template class ScalarColumnDesc<Int>;
251 extern template class ScalarColumnDesc<uInt>;
252 extern template class ScalarColumnDesc<Int64>;
253 extern template class ScalarColumnDesc<Float>;
254 extern template class ScalarColumnDesc<Double>;
255 extern template class ScalarColumnDesc<Complex>;
256 extern template class ScalarColumnDesc<DComplex>;
257 extern template class ScalarColumnDesc<String>;
258
259
260} //# NAMESPACE CASACORE - END
261
262#ifndef CASACORE_NO_AUTO_TEMPLATES
263#include <casacore/tables/Tables/ScaColDesc.tcc>
264#endif //# CASACORE_NO_AUTO_TEMPLATES
265#endif
Int options() const
Get the options.
const String & comment() const
Get comment string.
const String & name() const
Get the name of the column.
ScalarColumnDesc(const String &name, int options=0)
Construct the column with the given name.
virtual void putDesc(AipsIO &) const
Put the object.
String className() const
Get the name of this class.
const T & defaultValue() const
Get the default value.
Definition ScaColDesc.h:215
ScalarColumnDesc< T > & operator=(const ScalarColumnDesc< T > &)
Assignment (copy semantics);.
void registerClass() const
Register the construction function of this class.
void setDefault(const T &defaultValue)
Set the default value.
Definition ScaColDesc.h:211
virtual void getDesc(AipsIO &)
Get the object.
ScalarColumnDesc(const String &name, const String &comment, const String &dataManName, const String &dataManGroup, int options=0)
Construct the column with the given name, comment, and default data manager type and group.
virtual ConcatColumn * makeConcatColumn(ConcatTable *) const
Make a ConcatColumn object out of the description.
ScalarColumnDesc(const ScalarColumnDesc< T > &)
Copy constructor (copy semantics);.
ScalarColumnDesc(const String &name, const String &comment, const String &dataManName, const String &dataManGroup, const T &defaultValue, int options=0)
Construct the column with the given name, comment, default data manager type and group,...
BaseColumnDesc * clone() const
Clone this column description.
void show(ostream &os) const
Show the column.
virtual PlainColumn * makeColumn(ColumnSet *) const
Create a Column object out of this.
ScalarColumnDesc(const String &name, const String &comment, int options=0)
Construct the column with the given name and comment.
static BaseColumnDesc * makeDesc(const String &name)
Create the object from AipsIO (this function is registered).
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28