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