casacore
Loading...
Searching...
No Matches
VirtArrCol.h
Go to the documentation of this file.
1//# VirtArrCol.h: Templated base class for virtual array column
2//# Copyright (C) 1994,1995,1996,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_VIRTARRCOL_H
27#define TABLES_VIRTARRCOL_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32#include <casacore/tables/DataMan/DataManager.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37class Slicer;
38
39
40// <summary>
41// Templated base class for virtual array column
42// </summary>
43
44// <use visibility=local>
45
46// <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
47// </reviewed>
48
49// <prerequisite>
50//# Classes you should understand before using this one.
51// <li> DataManagerColumn
52// <li> VirtualColumnEngine
53// </prerequisite>
54
55// <etymology>
56// VirtualArrayColumn handles a virtual column containing an array.
57// </etymology>
58
59// <synopsis>
60// VirtualArrayColumn is the abstract base class to handle an array column
61// for a virtual column engine (both direct and indirect arrays).
62// It is derived from DataManagerColumn and reimplements some
63// virtual functions to make life easier for the derived classes.
64// It does the following:
65// <ul>
66// <li>
67// It implements the dataType function, so it is not needed to implement
68// that in derived classes.
69// <li>
70// It has a default implementation of False for function isWritable.
71// Thus by default virtual scalar columns are not writable, which will
72// often be the case. Only if a virtual scalar column can be writable,
73// it has to be implemented in the derived class.
74// <li>
75// It has a default implementation for the functions dealing with
76// the array shapes. By default they throw an "invalid operation"
77// exception, so it is needed to implement them in the derived class.
78// <li>
79// In DataManagerColumn the functions get/putArrayV and get/putSliceV
80// are defined, which have an ArrayBase& data argument. This is necessary
81// to handle arbitrary data types in the non-templated base class
82// DataManagerColumn.
83// In this templated VirtualArrayColumn class, virtual functions
84// get/putArray, get/putSlice, etc. have been defined. They cast
85// the ArrayBase& data argument to Array<T>&, so in a derived class no care
86// has to be taken for that cast.
87// Furthermore a default implementation of the get/putSlice has been made.
88// They get/put the entire array (using get/putArray) and access the
89// required slice.
90// By default the get/putArray functions thrown an "invalid operation"
91// exception, so they have to be implemented in the derived class.
92// <li>
93// Similarly the functions get/putArrayColumnV and get/putColumnSliceV
94// have been templated to get/putArrayColumn and get/putColumnSlice.
95// The default implementation of these latter functions handle a
96// column by looping through its individual cells.
97// <li>
98// Similarly the functions get/putArrayColumnCellsV and
99// get/putColumnSliceCells have been templated to
100// get/putArrayColumnCells and get/putColumnSliceCells.
101// However, their implementations throw an exception.
102// However, it makes it possible that a derived class
103// (like <linkto class=ScaledComplexData>ScaledComplexData</linkto>)
104// can implement these functions.
105// </ul>
106// An example of a virtual array column class is ScaledComplexData. Note that
107// this class is (indirectly) multiple derived from VirtualColumnEngine and
108// VirtualArrayColumn, so it combines the functionality of DataManager
109// and DataManagerColumn.
110// This is possible, because one ScaledComplexData engine can handle only one
111// column.
112// </synopsis>
113
114// <motivation>
115// This class reimplements some virtual functions implemented by
116// DataManagerColumn and types the data argument. In that way they are
117// easier to implement in derived classes. Furthermore they allow
118// default implementations.
119// </motivation>
120
121// <templating arg=T>
122// <li> default constructor
123// <li> copy constructor
124// <li> assignment operator
125// <li> <src>static String dataTypeId(); // unique name of the class</src>
126// </templating>
127
128// <todo asof="$DATE:$">
129//# A List of bugs, limitations, extensions or planned refinements.
130// </todo>
131
132
134{
135public:
136 // Create a column.
139
141
142 // By default no data can be put in a virtual column.
143 virtual Bool isWritable() const;
144
145protected:
146 // Set the shape of all arrays in the column.
147 // It is only called if the column contains direct arrays.
148 // By default it throws a "not possible" exception.
149 virtual void setShapeColumn (const IPosition& shape);
150
151 // Set the shape of an array in the given row.
152 // It is only called if the column contains indirect arrays.
153 // By default it throws a "not possible" exception.
154 virtual void setShape (rownr_t rownr, const IPosition& shape);
155
156 // Is the value shape defined in the given row?
157 // By default it throws a "not possible" exception.
158 virtual Bool isShapeDefined (rownr_t rownr);
159
160 // Get the shape of the item in the given row.
161 // By default it throws a "not possible" exception.
162 virtual IPosition shape (rownr_t rownr);
163
164 // The scalar access functions throw an exception.
165 // <group>
166 virtual void getScalarColumnV (ArrayBase& dataPtr);
167 virtual void putScalarColumnV (const ArrayBase& dataPtr);
168 virtual void getScalarColumnCellsV (const RefRows& rownrs,
169 ArrayBase& dataPtr);
170 virtual void putScalarColumnCellsV (const RefRows& rownrs,
171 const ArrayBase& dataPtr);
172 // </group>
173};
174
175
176template<class T>
178{
179public:
180 // Create a column.
183
185
186 // The object cannot be copied.
188
189 // The object cannot be assigned to.
191
192 // Return the data type of the column.
193 virtual int dataType() const;
194
195 // Return the data type Id of the column.
196 virtual String dataTypeId() const;
197
198protected:
199 // Get the array value in the given row.
200 // The data array has to have the correct shape
201 // (which is guaranteed by the ArrayColumn::get function).
202 virtual void getArray (rownr_t rownr, Array<T>& data) = 0;
203
204 // Put the array value into the given row.
205 // The data array has to have the correct shape
206 // (which is guaranteed by the ArrayColumn::put function).
207 // By default it throws a "not possible" exception.
208 virtual void putArray (rownr_t rownr, const Array<T>& data);
209
210 // Get a section of the array in the given row.
211 // The data array has to have the correct shape
212 // (which is guaranteed by the ArrayColumn::getSlice function).
213 // The default implementation gets the slice by getting the full
214 // array first.
215 virtual void getSlice (rownr_t rownr, const Slicer& slicer, Array<T>& data);
216
217 // Put into a section of the array in the given row.
218 // The data array has to have the correct shape
219 // (which is guaranteed by the ArrayColumn::putSlice function).
220 // The default implementation gets the slice by accessing the full
221 // array.
222 virtual void putSlice (rownr_t rownr, const Slicer& slicer,
223 const Array<T>& data);
224
225 // Get an entire column.
226 // The data array has to have the correct shape
227 // (which is guaranteed by the ArrayColum::getColumn function).
228 // The default implementation gets the column row by row.
229 virtual void getArrayColumn (Array<T>& data);
230
231 // Put an entire column.
232 // The data array has to have the correct shape
233 // (which is guaranteed by the ArrayColumn::putColumn function).
234 // The default implementation puts the column row by row.
235 virtual void putArrayColumn (const Array<T>& data);
236
237 // Get some array values in the column.
238 // The data array has to have the correct length
239 // (which is guaranteed by the ArrayColumn::getColumn function).
240 // By default it throws a "not possible" exception.
241 virtual void getArrayColumnCells (const RefRows& rownrs, Array<T>& data);
242
243 // Put some array values in the column.
244 // The data array has to have the correct length
245 // (which is guaranteed by the ArrayColumn::putColumn function).
246 // By default it throws a "not possible" exception.
247 virtual void putArrayColumnCells (const RefRows& rownrs,
248 const Array<T>& data);
249
250 // Get a section of all arrays in the column.
251 // The data array has to have the correct shape
252 // (which is guaranteed by the ArrayColumn::getColumn function).
253 // The default implementation gets the column row by row.
254 virtual void getColumnSlice (const Slicer& slicer, Array<T>& data);
255
256 // Put a section of all arrays in the column.
257 // The data array has to have the correct shape
258 // (which is guaranteed by the ArrayColumn putColumn function).
259 // The default implementation puts the column row by row.
260 virtual void putColumnSlice (const Slicer& slicer, const Array<T>& data);
261
262 // Get a section of some arrays in the column.
263 // The data array has to have the correct shape
264 // (which is guaranteed by the ArrayColumn::getColumn function).
265 // By default it throws a "not possible" exception.
266 virtual void getColumnSliceCells (const RefRows& rownrs,
267 const Slicer& slicer, Array<T>& data);
268
269 // Put into a section of some arrays in the column.
270 // The data array has to have the correct shape
271 // (which is guaranteed by the ArrayColumn::putColumn function).
272 // By default it throws a "not possible" exception.
273 virtual void putColumnSliceCells (const RefRows& rownrs,
274 const Slicer& slicer,
275 const Array<T>& data);
276
277private:
278 // Implement the virtual functions defined in DataManagerColumn.
279 // Get the array value in the given row.
280 void getArrayV (rownr_t rownr, ArrayBase& dataPtr);
281
282 // Implement the virtual functions defined in DataManagerColumn.
283 // Put the array value into the given row.
284 void putArrayV (rownr_t rownr, const ArrayBase& dataPtr);
285
286 // Implement the virtual functions defined in DataManagerColumn.
287 // Get some array values in the column.
288 void getArrayColumnCellsV (const RefRows& rownrs, ArrayBase& dataPtr);
289
290 // Implement the virtual functions defined in DataManagerColumn.
291 // Put some array values in the column.
292 void putArrayColumnCellsV (const RefRows& rownrs, const ArrayBase& dataPtr);
293
294 // Implement the virtual functions defined in DataManagerColumn.
295 // Get a section of the array in the given row.
296 void getSliceV (rownr_t rownr, const Slicer& slicer, ArrayBase& dataPtr);
297
298 // Implement the virtual functions defined in DataManagerColumn.
299 // Put into a section of the array in the given row.
300 void putSliceV (rownr_t rownr, const Slicer& slicer, const ArrayBase& dataPtr);
301
302 // Implement the virtual functions defined in DataManagerColumn.
303 // Get an entire column.
304 void getArrayColumnV (ArrayBase& dataPtr);
305
306 // Implement the virtual functions defined in DataManagerColumn.
307 // Put an entire column.
308 void putArrayColumnV (const ArrayBase& dataPtr);
309
310 // Implement the virtual functions defined in DataManagerColumn.
311 // Get a section of all arrays in the column.
312 void getColumnSliceV (const Slicer& slicer, ArrayBase& dataPtr);
313
314 // Implement the virtual functions defined in DataManagerColumn.
315 // Put into section of all arrays in the column.
316 void putColumnSliceV (const Slicer& slicer, const ArrayBase& dataPtr);
317
318 // Implement the virtual functions defined in DataManagerColumn.
319 // Get a section of some arrays in the column.
320 virtual void getColumnSliceCellsV (const RefRows& rownrs,
321 const Slicer& slicer, ArrayBase& dataPtr);
322
323 // Implement the virtual functions defined in DataManagerColumn.
324 // Put into a section of some arrays in the column.
325 virtual void putColumnSliceCellsV (const RefRows& rownrs,
326 const Slicer& slicer,
327 const ArrayBase& dataPtr);
328};
329
330
331
332
333} //# NAMESPACE CASACORE - END
334
335#ifndef CASACORE_NO_AUTO_TEMPLATES
336#include <casacore/tables/DataMan/VirtArrCol.tcc>
337#endif //# CASACORE_NO_AUTO_TEMPLATES
338#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:71
String: the storage and methods of handling collections of characters.
Definition String.h:223
virtual void putScalarColumnV(const ArrayBase &dataPtr)
Put all scalar values in the column.
virtual void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of an array in the given row.
virtual void setShapeColumn(const IPosition &shape)
Set the shape of all arrays in the column.
virtual Bool isShapeDefined(rownr_t rownr)
Is the value shape defined in the given row? By default it throws a "not possible" exception.
virtual Bool isWritable() const
By default no data can be put in a virtual column.
virtual void getScalarColumnCellsV(const RefRows &rownrs, ArrayBase &dataPtr)
Get some scalar values in the column.
virtual void putScalarColumnCellsV(const RefRows &rownrs, const ArrayBase &dataPtr)
Put some scalar values in the column.
virtual IPosition shape(rownr_t rownr)
Get the shape of the item in the given row.
VirtualArrayColumnBase()
Create a column.
Definition VirtArrCol.h:137
virtual void getScalarColumnV(ArrayBase &dataPtr)
The scalar access functions throw an exception.
void putArrayColumnV(const ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual void putArrayColumn(const Array< T > &data)
Put an entire column.
void getArrayColumnCellsV(const RefRows &rownrs, ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual void getArray(rownr_t rownr, Array< T > &data)=0
Get the array value in the given row.
virtual void putArrayColumnCells(const RefRows &rownrs, const Array< T > &data)
Put some array values in the column.
virtual int dataType() const
Return the data type of the column.
void getArrayV(rownr_t rownr, ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual void putColumnSliceCells(const RefRows &rownrs, const Slicer &slicer, const Array< T > &data)
Put into a section of some arrays in the column.
virtual void putColumnSliceCellsV(const RefRows &rownrs, const Slicer &slicer, const ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
void getSliceV(rownr_t rownr, const Slicer &slicer, ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual void getArrayColumn(Array< T > &data)
Get an entire column.
void putColumnSliceV(const Slicer &slicer, const ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual void getColumnSliceCellsV(const RefRows &rownrs, const Slicer &slicer, ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual void putSlice(rownr_t rownr, const Slicer &slicer, const Array< T > &data)
Put into a section of the array in the given row.
virtual void putColumnSlice(const Slicer &slicer, const Array< T > &data)
Put a section of all arrays in the column.
virtual String dataTypeId() const
Return the data type Id of the column.
void putSliceV(rownr_t rownr, const Slicer &slicer, const ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
VirtualArrayColumn()
Create a column.
Definition VirtArrCol.h:181
virtual void getColumnSliceCells(const RefRows &rownrs, const Slicer &slicer, Array< T > &data)
Get a section of some arrays in the column.
void getColumnSliceV(const Slicer &slicer, ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
void putArrayColumnCellsV(const RefRows &rownrs, const ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
VirtualArrayColumn< T > & operator=(const VirtualArrayColumn< T > &)=delete
The object cannot be assigned to.
virtual void getColumnSlice(const Slicer &slicer, Array< T > &data)
Get a section of all arrays in the column.
virtual void getSlice(rownr_t rownr, const Slicer &slicer, Array< T > &data)
Get a section of the array in the given row.
virtual void getArrayColumnCells(const RefRows &rownrs, Array< T > &data)
Get some array values in the column.
void putArrayV(rownr_t rownr, const ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
void getArrayColumnV(ArrayBase &dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual void putArray(rownr_t rownr, const Array< T > &data)
Put the array value into the given row.
VirtualArrayColumn(const VirtualArrayColumn< T > &)=delete
The object cannot be copied.
this file contains all the compiler specific defines
Definition mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44