casacore
Loading...
Searching...
No Matches
ArrColDesc.h
Go to the documentation of this file.
1//# ArrColDesc.h: Templated class to describe columns of arrays in tables
2//# Copyright (C) 1994,1995,1996,1997,1999,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_ARRCOLDESC_H
27#define TABLES_ARRCOLDESC_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/Tables/BaseColDesc.h>
32#include <casacore/casa/Arrays/IPosition.h>
33#include <casacore/casa/Arrays/ArrayFwd.h>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37//# Forward Declarations
38class PlainColumn;
39class ColumnSet;
40
41
42// <summary>
43// Abstract base class for description of table array columns
44// </summary>
45
46// <use visibility=local>
47
48// <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
49// </reviewed>
50
51// <prerequisite>
52// <li> BaseColumnDesc (and its prerequisites)
53// <li> TableDesc
54// </prerequisite>
55
56// <synopsis>
57// This class contains the common functionality for the templated class
58// ArrayColumnDesc which describes an array column.
59// </synopsis>
60
62{
63public:
64 // Construct with given parameters.
68 DataType, const String& dataTypeId,
70
71 // Copy constructor (copy semantics);
73
75
76 // Assignment (copy semantics);
78
79 // Get the name of this class. It is used by the registration process.
80 // The template argument gets part of the name.
82
83 // Create a Column object out of this.
84 // This is used by class ColumnSet to construct a table column object.
85 virtual PlainColumn* makeColumn (ColumnSet*) const;
86
87 // Show the column.
88 void show (ostream& os) const;
89
90protected:
91 // Put the object.
92 virtual void putDesc (AipsIO&) const;
93
94 // Get the object.
95 virtual void getDesc (AipsIO&);
96};
97
98
99// <summary>
100// Templated class for description of table array columns
101// </summary>
102
103// <use visibility=export>
104
105// <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
106// </reviewed>
107
108// <prerequisite>
109// <li> ArrayColumnDescBase (and its prerequisites)
110// <li> TableDesc
111// </prerequisite>
112
113// <etymology>
114// This class builds descriptions of table columns where each cell (which
115// may also be called a row) will hold an array.
116// </etymology>
117
118// <synopsis>
119// ArrayColumnDesc is a templated class for defining a table column
120// containing arrays.
121//
122// The table values are handled by a data manager. This can be
123// a storage manager to store the values in a file or it can be
124// a virtual column engine to calculate them on-the-fly.
125// Only the basic data types are allowed when storing in a file. These are:
126// Bool, uChar, Short, uShort, Int, uInt, Int64, float, double,
127// Complex, DComplex and String.
128//
129// At table creation time (when a table gets created from a table
130// description), each column needs to be bound to a data manager.
131// If not done explicitly, the table system will bind a column to the
132// default manager defined in the column description.
133//
134// An array column description consists of the following attributes:
135// <ul>
136// <li> Name, which has to be unique and must also be different
137// from possible table keyword names.
138// <li> Data type, which is determined by the template parameter
139// (e.g. ArrayColumnDesc<Int>).
140// <li> A data type id, which tells the unique name of non-standard
141// data types (i.e. for data type == TpOther).
142// <li> Comment, which defaults to the empty string.
143// This serves purely as an informational string for the user.
144// <li> Dimensionality. If given, all arrays in the column need
145// to have that dimensionality.
146// <li> Shape. If given, all arrays in the column need to have
147// that shape.
148// <li> Default data manager, which will be used if a column
149// for a newly created table is not explicitly bound to a
150// datamanager.
151// <li> Data manager group, which serves 2 purposes.
152// Firstly it can be used in class SetupNewTable to bind a group
153// of columns.
154// Secondly, when the default data managers are used, it
155// allows, for example, to have 2 AipsIO storage managers.
156// One for one group of columns and one for another group of columns.
157// <li> Options. These are defined in ColumnDesc.h and can be combined
158// by logically or-ing them.
159// <ol>
160// <li>
161// ColumnDesc::FixedShape says that the arrays in all cells
162// of a column have the same shape. This shape must be defined
163// before a table is created. It does not tell if
164// the array is direct or indirect.
165// A FixedShape array is defined in every cell, while for
166// non-FixedShape arrays a cell can be empty.
167// <li>
168// ColumnDesc::Direct determines if an array is directly
169// stored in the table or if it is stored indirectly in a separate
170// file. Direct arrays enforce the FixedShape option.
171// Usually indirect arrays are only read in on command, while
172// direct arrays are held in memory. So the size of the
173// arrays is an important factor.
174// </ol>
175// <li> Default keyword set, which defaults to an empty set.
176// When a table column gets created from the description, it gets
177// a copy of this keyword set as its initial keyword set.
178// </ul>
179//
180// There are several constructors, which allow the definition of most
181// of the above mentioned attributes. Others, like the default keyword
182// set, have to be defined explicitly.
183//
184// This class is derived from ArrayColumnDescBase, thus the functions
185// in there also apply to this class.
186//
187// Once a column description is set up satisfactorily, it must be added
188// to a table description before it can be used by the table system.
189// </synopsis>
190
191// <example>
192// <srcblock>
193// TableDesc tabDesc("tTableDesc", "1", TableDesc::New);
194//
195// // Now define array columns.
196// // This one is indirect and has no dimensionality mentioned yet.
197// // Define the keyword UNIT in it.
198// ArrayColumnDesc<Complex> arr1Column("Arr1", "comment for Arr1");
199// arr1Column.rwKeywordSet().define ("UNIT", "Jy");
200// tabDesc.addColumn (arr1Column);
201//
202// // This one is indirect and has 3-dim arrays.
203// tabDesc.addColumn (ArrayColumnDesc<Int>("Arr2",
204// "comment for Arr2",
205// 3));
206// // This one is direct and has 2-dim arrays with axis lengths 4 and 7.
207// tabDesc.addColumn (ArrayColumnDesc<uInt>("Arr3",
208// "comment for Arr1",
209// IPosition(2,4,7),
210// ColumnDesc::Direct));
211// </srcblock>
212// </example>
213
214// <motivation>
215// Several column description classes are needed to allow the user
216// to define attributes which are special for each column type.
217// For scalars the special attribute is the default value.
218// They all have to be templated to support arbitrary data types.
219// </motivation>
220
221// <templating arg=T>
222// <li> Default constructor
223// <li> Copy constructor
224// <li> Assignment operator
225// <li> <src>static String dataTypeId(); // (not needed for builtin types)</src>
226// This should return the unique "name" of the class.
227// </templating>
228
229//# <todo asof="$DATE:$">
230//# A List of bugs, limitations, extensions or planned refinements.
231//# </todo>
232
233template<class T>
235{
236friend class ColumnDesc;
237
238public:
239 // Construct the column with the given name and dimensionality.
240 // The data manager type defaults to the StandardStman storage manager.
241 // The data manager group defaults to the data manager type.
242 // Ndim <=0 means that the number of dimensions is free and will
243 // be defined when creating the table (rows). Ndim>0 means that
244 // the arrays in this column must have the given dimensionality.
245 // The possible options are defined in ColumnDesc.h.
246 explicit ArrayColumnDesc (const String& name, Int ndim = -1,
247 int options = 0);
248
249 // Construct the column with the given name, dimensionality, and comment.
250 // The data manager type defaults to the StandardStman storage manager.
251 // The data manager group defaults to the data manager type.
252 // Ndim <=0 means that the number of dimensions is free and will
253 // be defined when creating the table (rows). Ndim>0 means that
254 // the arrays in this column must have the given dimensionality.
255 // The possible options are defined in ColumnDesc.h.
257 Int ndim = -1, int options = 0);
258
259 // Construct the column with the given name, dimensionality, comment,
260 // and default data manager type and group.
261 // A blank data manager group defaults to the data manager type.
262 // Ndim <=0 means that the number of dimensions is free and will
263 // be defined when creating the table (rows). Ndim>0 means that
264 // the arrays in this column must have the given dimensionality.
265 // The possible options are defined in ColumnDesc.h.
267 const String& dataManName, const String& dataManGroup,
268 Int ndim = -1, int options = 0);
269
270 // Construct the column with the given name and shape.
271 // The data manager type defaults to the StandardStman storage manager.
272 // The data manager group defaults to the data manager type.
273 // The possible options are defined in ColumnDesc.h.
274 // This constructor can only be used for FixedShape arrays, because the
275 // shape of other arrays can only be set per row.
277 const IPosition& shape, int options = 0);
278
279 // Construct the column with the given name, shape, and comment.
280 // The data manager type defaults to the StandardStman storage manager.
281 // The data manager group defaults to the data manager type.
282 // The possible options are defined in ColumnDesc.h.
283 // This constructor can only be used for FixedShape arrays, because the
284 // shape of other arrays can only be set per row.
286 const IPosition& shape, int options = 0);
287
288 // Construct the column with the given name, shape, comment,
289 // and default data manager type and group.
290 // A blank data manager group defaults to the data manager type.
291 // The possible options are defined in ColumnDesc.h.
292 // This constructor can only be used for FixedShape arrays, because the
293 // shape of other arrays can only be set per row.
294 // If both ndim and shape are given as > 0, ndim should match the length
295 // of shape.
297 const String& dataManName, const String& dataManGroup,
298 const IPosition& shape, int options = 0, int ndim=-1);
299
300 // Copy constructor (copy semantics);
302
304
305 // Assignment (copy semantics);
307
308 // Clone this column description to another.
310
311 // Register the construction function of this class.
312 void registerClass() const;
313
314 // Create the object from AipsIO (this function is registered).
316};
317
318
319//# Explicitly instantiate these templates in ArrColDesc_tmpl.cc
320 extern template class ArrayColumnDesc<Bool>;
321 extern template class ArrayColumnDesc<Char>;
322 extern template class ArrayColumnDesc<Short>;
323 extern template class ArrayColumnDesc<uShort>;
324 extern template class ArrayColumnDesc<Int>;
325 extern template class ArrayColumnDesc<uInt>;
326 extern template class ArrayColumnDesc<Int64>;
327 extern template class ArrayColumnDesc<Float>;
328 extern template class ArrayColumnDesc<Double>;
329 extern template class ArrayColumnDesc<Complex>;
330 extern template class ArrayColumnDesc<DComplex>;
331 extern template class ArrayColumnDesc<String>;
332
333
334} //# NAMESPACE CASACORE - END
335
336#ifndef CASACORE_NO_AUTO_TEMPLATES
337#include <casacore/tables/Tables/ArrColDesc.tcc>
338#endif //# CASACORE_NO_AUTO_TEMPLATES
339#endif
virtual PlainColumn * makeColumn(ColumnSet *) const
Create a Column object out of this.
virtual void putDesc(AipsIO &) const
Put the object.
ArrayColumnDescBase(const String &name, const String &comment, const String &dataManagerType, const String &dataManagerGroup, DataType, const String &dataTypeId, Int options, uInt ndim, const IPosition &shape)
Construct with given parameters.
void show(ostream &os) const
Show the column.
virtual void getDesc(AipsIO &)
Get the object.
ArrayColumnDescBase & operator=(const ArrayColumnDescBase &)
Assignment (copy semantics);.
ArrayColumnDescBase(const ArrayColumnDescBase &)
Copy constructor (copy semantics);.
String className() const
Get the name of this class.
Templated class for description of table array columns.
Definition ArrColDesc.h:235
ArrayColumnDesc(const String &name, const String &comment, const IPosition &shape, int options=0)
Construct the column with the given name, shape, and comment.
ArrayColumnDesc(const String &name, const String &comment, Int ndim=-1, int options=0)
Construct the column with the given name, dimensionality, and comment.
BaseColumnDesc * clone() const
Clone this column description to another.
void registerClass() const
Register the construction function of this class.
ArrayColumnDesc(const String &name, const String &comment, const String &dataManName, const String &dataManGroup, Int ndim=-1, int options=0)
Construct the column with the given name, dimensionality, comment, and default data manager type and ...
ArrayColumnDesc< T > & operator=(const ArrayColumnDesc< T > &)
Assignment (copy semantics);.
ArrayColumnDesc(const String &name, const IPosition &shape, int options=0)
Construct the column with the given name and shape.
ArrayColumnDesc(const ArrayColumnDesc< T > &)
Copy constructor (copy semantics);.
static BaseColumnDesc * makeDesc(const String &name)
Create the object from AipsIO (this function is registered).
ArrayColumnDesc(const String &name, const String &comment, const String &dataManName, const String &dataManGroup, const IPosition &shape, int options=0, int ndim=-1)
Construct the column with the given name, shape, comment, and default data manager type and group.
ArrayColumnDesc(const String &name, Int ndim=-1, int options=0)
Construct the column with the given name and dimensionality.
const String & dataManagerGroup() const
Get the data manager group.
const IPosition & shape() const
Get the predefined shape.
Int options() const
Get the options.
const String & comment() const
Get comment string.
const String & dataTypeId() const
Get the type id for non-standard data types (i.e.
const String & name() const
Get the name of the column.
Int ndim() const
Get the number of dimensions.
const String & dataManagerType() const
Get the type name of the default data manager.
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
unsigned int uInt
Definition aipstype.h:49
int Int
Definition aipstype.h:48