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