casa  5.7.0-16
 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>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 template<class T> class Array;
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 a void* 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 void* 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. For this purpose the function canAccessSlice has
92 // also been implemented.
93 // By default the get/putArray functions thrown an "invalid operation"
94 // exception, so they have to be implemented in the derived class.
95 // <li>
96 // Similarly the functions get/putArrayColumnV and get/putColumnSliceV
97 // have been templated to get/putArrayColumn and get/putColumnSlice.
98 // The default implementation of these latter functions handle a
99 // column by looping through its individual cells.
100 // For this purpose the functions canAccessArrayColumn and
101 // canAccessColumnSlice have also been implemented.
102 // <li>
103 // Similarly the functions get/putArrayColumnCellsV and
104 // get/putColumnSliceCells have been templated to
105 // get/putArrayColumnCells and get/putColumnSliceCells.
106 // However, their implementations throw an exception and the function
107 // canAccessArrayColumnCells has not implemented (so defaults to False).
108 // However, it makes it possible that a derived class
109 // (like <linkto class=ScaledComplexData>ScaledComplexData</linkto>)
110 // can implement these functions.
111 // </ul>
112 // An example of a virtual array column class is ScaledComplexData. Note that
113 // this class is (indirectly) multiple derived from VirtualColumnEngine and
114 // VirtualArrayColumn, so it combines the functionality of DataManager
115 // and DataManagerColumn.
116 // This is possible, because one ScaledComplexData engine can handle only one
117 // column.
118 // </synopsis>
119 
120 // <motivation>
121 // This class reimplements some virtual functions implemented by
122 // DataManagerColumn and types the data argument. In that way they are
123 // easier to implement in derived classes. Furthermore they allow
124 // default implementations.
125 // </motivation>
126 
127 // <templating arg=T>
128 // <li> default constructor
129 // <li> copy constructor
130 // <li> assignment operator
131 // <li> <src>static String dataTypeId(); // unique name of the class</src>
132 // </templating>
133 
134 // <todo asof="$DATE:$">
135 //# A List of bugs, limitations, extensions or planned refinements.
136 // </todo>
137 
138 
139 template<class T>
141 {
142 public:
143 
144  // Create a column.
146  {;}
147 
148  // Frees up the storage.
149  virtual ~VirtualArrayColumn();
150 
151  // Return the data type of the column.
152  virtual int dataType() const;
153 
154  // Return the data type Id of the column.
155  virtual String dataTypeId() const;
156 
157  // By default no data can be put in a virtual column.
158  virtual Bool isWritable() const;
159 
160  // The class can handle a get/putSlice.
161  virtual Bool canAccessSlice (Bool& reask) const;
162 
163  // The class can handle a get/putArrayColumn.
164  virtual Bool canAccessArrayColumn (Bool& reask) const;
165 
166  // The class can handle a get/putColumnSlice.
167  virtual Bool canAccessColumnSlice (Bool& reask) const;
168 
169 protected:
170  // Set the shape of all arrays in the column.
171  // It is only called if the column contains direct arrays.
172  // By default it throws a "not possible" exception.
173  virtual void setShapeColumn (const IPosition& shape);
174 
175  // Set the shape of an array in the given row.
176  // It is only called if the column contains indirect arrays.
177  // By default it throws a "not possible" exception.
178  virtual void setShape (uInt rownr, const IPosition& shape);
179 
180  // Is the value shape defined in the given row?
181  // By default it throws a "not possible" exception.
182  virtual Bool isShapeDefined (uInt rownr);
183 
184  // Get the dimensionality of the item in the given row.
185  // By default it returns the length of the shape of that row.
186  virtual uInt ndim (uInt rownr);
187 
188  // Get the shape of the item in the given row.
189  // By default it throws a "not possible" exception.
190  virtual IPosition shape (uInt rownr);
191 
192  // Get the array value in the given row.
193  // The data array has to have the correct shape
194  // (which is guaranteed by the ArrayColumn::get function).
195  virtual void getArray (uInt rownr, Array<T>& data) = 0;
196 
197  // Put the array value into the given row.
198  // The data array has to have the correct shape
199  // (which is guaranteed by the ArrayColumn::put function).
200  // By default it throws a "not possible" exception.
201  virtual void putArray (uInt rownr, const Array<T>& data);
202 
203  // Get a section of the array in the given row.
204  // The data array has to have the correct shape
205  // (which is guaranteed by the ArrayColumn::getSlice function).
206  // The default implementation gets the slice by getting the full
207  // array first.
208  virtual void getSlice (uInt rownr, const Slicer& slicer, Array<T>& data);
209 
210  // Put into 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::putSlice function).
213  // The default implementation gets the slice by accessing the full
214  // array.
215  virtual void putSlice (uInt rownr, const Slicer& slicer,
216  const Array<T>& data);
217 
218  // Get an entire column.
219  // The data array has to have the correct shape
220  // (which is guaranteed by the ArrayColum::getColumn function).
221  // The default implementation gets the column row by row.
222  virtual void getArrayColumn (Array<T>& data);
223 
224  // Put an entire column.
225  // The data array has to have the correct shape
226  // (which is guaranteed by the ArrayColumn::putColumn function).
227  // The default implementation puts the column row by row.
228  virtual void putArrayColumn (const Array<T>& data);
229 
230  // Get some array values in the column.
231  // The data array has to have the correct length
232  // (which is guaranteed by the ArrayColumn::getColumn function).
233  // By default it throws a "not possible" exception.
234  virtual void getArrayColumnCells (const RefRows& rownrs, Array<T>& data);
235 
236  // Put some array values in the column.
237  // The data array has to have the correct length
238  // (which is guaranteed by the ArrayColumn::putColumn function).
239  // By default it throws a "not possible" exception.
240  virtual void putArrayColumnCells (const RefRows& rownrs,
241  const Array<T>& data);
242 
243  // Get a section of all arrays in the column.
244  // The data array has to have the correct shape
245  // (which is guaranteed by the ArrayColumn::getColumn function).
246  // The default implementation gets the column row by row.
247  virtual void getColumnSlice (const Slicer& slicer, Array<T>& data);
248 
249  // Put a section of all arrays in the column.
250  // The data array has to have the correct shape
251  // (which is guaranteed by the ArrayColumn putColumn function).
252  // The default implementation puts the column row by row.
253  virtual void putColumnSlice (const Slicer& slicer, const Array<T>& data);
254 
255  // Get a section of some arrays in the column.
256  // The data array has to have the correct shape
257  // (which is guaranteed by the ArrayColumn::getColumn function).
258  // By default it throws a "not possible" exception.
259  virtual void getColumnSliceCells (const RefRows& rownrs,
260  const Slicer& slicer, Array<T>& data);
261 
262  // Put into 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::putColumn function).
265  // By default it throws a "not possible" exception.
266  virtual void putColumnSliceCells (const RefRows& rownrs,
267  const Slicer& slicer,
268  const Array<T>& data);
269 
270 private:
271  // Implement the virtual functions defined in DataManagerColumn.
272  // Get the array value in the given row.
273  void getArrayV (uInt rownr, void* dataPtr);
274 
275  // Implement the virtual functions defined in DataManagerColumn.
276  // Put the array value into the given row.
277  void putArrayV (uInt rownr, const void* dataPtr);
278 
279  // Implement the virtual functions defined in DataManagerColumn.
280  // Get some array values in the column.
281  void getArrayColumnCellsV (const RefRows& rownrs, void* dataPtr);
282 
283  // Implement the virtual functions defined in DataManagerColumn.
284  // Put some array values in the column.
285  void putArrayColumnCellsV (const RefRows& rownrs, const void* dataPtr);
286 
287  // Implement the virtual functions defined in DataManagerColumn.
288  // Get a section of the array in the given row.
289  void getSliceV (uInt rownr, const Slicer& slicer, void* dataPtr);
290 
291  // Implement the virtual functions defined in DataManagerColumn.
292  // Put into a section of the array in the given row.
293  void putSliceV (uInt rownr, const Slicer& slicer, const void* dataPtr);
294 
295  // Implement the virtual functions defined in DataManagerColumn.
296  // Get an entire column.
297  void getArrayColumnV (void* dataPtr);
298 
299  // Implement the virtual functions defined in DataManagerColumn.
300  // Put an entire column.
301  void putArrayColumnV (const void* dataPtr);
302 
303  // Implement the virtual functions defined in DataManagerColumn.
304  // Get a section of all arrays in the column.
305  void getColumnSliceV (const Slicer& slicer, void* dataPtr);
306 
307  // Implement the virtual functions defined in DataManagerColumn.
308  // Put into section of all arrays in the column.
309  void putColumnSliceV (const Slicer& slicer, const void* dataPtr);
310 
311  // Implement the virtual functions defined in DataManagerColumn.
312  // Get a section of some arrays in the column.
313  virtual void getColumnSliceCellsV (const RefRows& rownrs,
314  const Slicer& slicer, void* dataPtr);
315 
316  // Implement the virtual functions defined in DataManagerColumn.
317  // Put into a section of some arrays in the column.
318  virtual void putColumnSliceCellsV (const RefRows& rownrs,
319  const Slicer& slicer,
320  const void* dataPtr);
321 
322 
323 private:
324  // The object cannot be copied.
326 
327  // The object cannot be assigned to.
329 };
330 
331 
332 
333 
334 } //# NAMESPACE CASACORE - END
335 
336 #ifndef CASACORE_NO_AUTO_TEMPLATES
337 #include <casacore/tables/DataMan/VirtArrCol.tcc>
338 #endif //# CASACORE_NO_AUTO_TEMPLATES
339 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
void putSliceV(uInt rownr, const Slicer &slicer, const void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
void putArrayColumnCellsV(const RefRows &rownrs, const void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
void getArrayColumnCellsV(const RefRows &rownrs, void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
void getColumnSliceV(const Slicer &slicer, void *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:145
Abstract base class for a column in a data manager.
Definition: DataManager.h:611
Templated base class for virtual array column.
Definition: VirtArrCol.h:140
virtual String dataTypeId() const
Return the data type Id of the column.
virtual IPosition shape(uInt rownr)
Get the shape of the item in the given row.
void putColumnSliceV(const Slicer &slicer, const void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
void getArrayColumnV(void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
void getSliceV(uInt rownr, const Slicer &slicer, void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual int dataType() const
Return the data type of the column.
virtual void getColumnSlice(const Slicer &slicer, Array< T > &data)
Get a section of all arrays in the column.
virtual void putColumnSliceCellsV(const RefRows &rownrs, const Slicer &slicer, const void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual ~VirtualArrayColumn()
Frees up the storage.
virtual void putColumnSlice(const Slicer &slicer, const Array< T > &data)
Put a section of all arrays in the column.
virtual void setShapeColumn(const IPosition &shape)
Set the shape of all arrays in the column.
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
virtual void getColumnSliceCellsV(const RefRows &rownrs, const Slicer &slicer, void *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.
void getArrayV(uInt rownr, void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual Bool canAccessArrayColumn(Bool &reask) const
The class can handle a get/putArrayColumn.
virtual Bool canAccessSlice(Bool &reask) const
The class can handle a get/putSlice.
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
virtual uInt ndim(uInt rownr)
Get the dimensionality of the item in the given row.
virtual Bool canAccessColumnSlice(Bool &reask) const
The class can handle a get/putColumnSlice.
virtual void putArray(uInt rownr, const Array< T > &data)
Put the array value into the given row.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
VirtualArrayColumn< T > & operator=(const VirtualArrayColumn< T > &)
The object cannot be assigned to.
void putArrayV(uInt rownr, const void *dataPtr)
Implement the virtual functions defined in DataManagerColumn.
virtual Bool isShapeDefined(uInt rownr)
Is the value shape defined in the given row? By default it throws a &quot;not possible&quot; exception...
virtual void getArrayColumnCells(const RefRows &rownrs, Array< T > &data)
Get some array values in the column.
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
void putArrayColumnV(const void *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.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
virtual void getArray(uInt rownr, Array< T > &data)=0
Get the array value in the given row.
virtual void putSlice(uInt rownr, const Slicer &slicer, const Array< T > &data)
Put into a section of the array in the given row.
virtual void putArrayColumn(const Array< T > &data)
Put an entire column.
virtual Bool isWritable() const
By default no data can be put in a virtual column.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void setShape(uInt rownr, const IPosition &shape)
Set the shape of an array in the given row.
virtual void getSlice(uInt rownr, const Slicer &slicer, Array< T > &data)
Get a section of the array in the given row.
virtual void getColumnSliceCells(const RefRows &rownrs, const Slicer &slicer, Array< T > &data)
Get a section of some arrays in the column.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42