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