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