casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TSMDataColumn.h
Go to the documentation of this file.
1 //# TSMDataColumn.h: A data column in Tiled Storage Manager
2 //# Copyright (C) 1995,1996,1997,1999,2002
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_TSMDATACOLUMN_H
29 #define TABLES_TSMDATACOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
40 
41 namespace casacore { //# NAMESPACE CASACORE - BEGIN
42 
43 //# Forward Declarations
44 class Slicer;
45 
46 
47 // <summary>
48 // A data column in Tiled Storage Manager.
49 // </summary>
50 
51 // <use visibility=local>
52 
53 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
54 // </reviewed>
55 
56 // <prerequisite>
57 //# Classes you should understand before using this one.
58 // <li> <linkto class=TSMColumn>TSMColumn</linkto>
59 // <li> <linkto class=TSMCube>TSMCube</linkto>
60 // </prerequisite>
61 
62 // <etymology>
63 // TSMDataColumn handles a data column for a Tiled
64 // Storage Manager.
65 // </etymology>
66 
67 // <synopsis>
68 // TSMDataColumn is used by
69 // <linkto class=TiledStMan>TiledStMan</linkto>
70 // to handle the access to
71 // a table column containing data of a tiled hypercube axis.
72 // The data in a cell can be a scalar or an array (depending on its
73 // definition in the table column description).
74 // The shapes of the coordinates and the data are related. Therefore
75 // the function setShape checks if the data shape matches the coordinates
76 // shape.
77 // <p>
78 // The data are held in a TSMCube object. The row number
79 // determines which TSMCube object has to be accessed.
80 // <p>
81 // The creation of a TSMDataColumn object is done by a TSMColumn object.
82 // This process is described in more detail in the class
83 // <linkto class=TSMColumn>TSMColumn</linkto>.
84 // </synopsis>
85 
86 // <motivation>
87 // Handling data columns in the Tiled Storage Manager is
88 // different from other columns.
89 // </motivation>
90 
91 //# <todo asof="$DATE:$">
92 //# A List of bugs, limitations, extensions or planned refinements.
93 //# </todo>
94 
95 
96 class TSMDataColumn : public TSMColumn
97 {
98 public:
99 
100  // Create a data column from the given column.
101  TSMDataColumn (const TSMColumn& column);
102 
103  // Frees up the storage.
104  virtual ~TSMDataColumn();
105 
106  // Return the size of a pixel in the tile in external format.
107  uInt tilePixelSize() const;
108 
109  // Return the size of a pixel in the tile in local format.
110  uInt localPixelSize() const;
111 
112  // Determine the length to store the given number of pixels.
113  uInt64 dataLength (uInt64 nrPixels) const;
114 
115  // Set column sequence number.
116  void setColumnNumber (uInt colnr);
117 
118  // Changing array shapes for non-FixedShape columns when the
119  // parent tiled storage manager can handle it.
120  Bool canChangeShape() const;
121 
122  // Set the shape of the data array in the given row.
123  // It will check if it matches already defined data and coordinates shapes.
124  // It will define undefined data and coordinates shapes.
125  void setShape (rownr_t rownr, const IPosition& shape);
126 
127  // Set the shape and tile shape of the array in the given row.
128  // It will check if it matches already defined data and coordinates shapes.
129  // It will define undefined data and coordinates shapes.
130  // The tile shape is adjusted to the array shape (size 0 gets set to 1;
131  // size > cubesize gets set to the cubesize).
132  void setShapeTiled (rownr_t rownr, const IPosition& shape,
133  const IPosition& tileShape);
134 
135  // Is the value shape defined in the given row?
136  Bool isShapeDefined (rownr_t rownr);
137 
138  // Get the shape of the item in the given row.
139  IPosition shape (rownr_t rownr);
140 
141  // Get the tile shape of the item in the given row.
142  IPosition tileShape (rownr_t rownr);
143 
144  // Get a scalar value in the given row.
145  // The buffer pointed to by dataPtr has to have the correct length
146  // (which is guaranteed by the Scalar/ArrayColumn get function).
147  // <group>
148  virtual void getBool (rownr_t rownr, Bool* dataPtr);
149  virtual void getuChar (rownr_t rownr, uChar* dataPtr);
150  virtual void getShort (rownr_t rownr, Short* dataPtr);
151  virtual void getuShort (rownr_t rownr, uShort* dataPtr);
152  virtual void getInt (rownr_t rownr, Int* dataPtr);
153  virtual void getuInt (rownr_t rownr, uInt* dataPtr);
154  virtual void getInt64 (rownr_t rownr, Int64* dataPtr);
155  virtual void getfloat (rownr_t rownr, float* dataPtr);
156  virtual void getdouble (rownr_t rownr, double* dataPtr);
157  virtual void getComplex (rownr_t rownr, Complex* dataPtr);
158  virtual void getDComplex (rownr_t rownr, DComplex* dataPtr);
159  // </group>
160 
161  // Put a scalar value into the given row.
162  // The buffer pointed to by dataPtr has to have the correct length
163  // (which is guaranteed by the Scalar/ArrayColumn put function).
164  // <group>
165  virtual void putBool (rownr_t rownr, const Bool* dataPtr);
166  virtual void putuChar (rownr_t rownr, const uChar* dataPtr);
167  virtual void putShort (rownr_t rownr, const Short* dataPtr);
168  virtual void putuShort (rownr_t rownr, const uShort* dataPtr);
169  virtual void putInt (rownr_t rownr, const Int* dataPtr);
170  virtual void putuInt (rownr_t rownr, const uInt* dataPtr);
171  virtual void putInt64 (rownr_t rownr, const Int64* dataPtr);
172  virtual void putfloat (rownr_t rownr, const float* dataPtr);
173  virtual void putdouble (rownr_t rownr, const double* dataPtr);
174  virtual void putComplex (rownr_t rownr, const Complex* dataPtr);
175  virtual void putDComplex (rownr_t rownr, const DComplex* dataPtr);
176  // </group>
177 
178  // Get the array value in the given row.
179  // The array given in <src>data</src> has to have the correct shape
180  // (which is guaranteed by the ArrayColumn get function).
181  virtual void getArrayV (rownr_t rownr, ArrayBase& data);
182 
183  // Put the array value into the given row.
184  // The array given in <src>data</src> has to have the correct shape
185  // (which is guaranteed by the ArrayColumn put function).
186  virtual void putArrayV (rownr_t rownr, const ArrayBase& data);
187 
188  // Get into a section of the array in the given row.
189  // The array given in <src>data</src> has to have the correct shape
190  // (which is guaranteed by the ArrayColumn putSlice function).
191  virtual void getSliceV (rownr_t rownr, const Slicer& slicer,
192  ArrayBase& dataPtr);
193 
194  // Put into a section of the array in the given row.
195  // The array given in <src>data</src> has to have the correct shape
196  // (which is guaranteed by the ArrayColumn putSlice function).
197  virtual void putSliceV (rownr_t rownr, const Slicer& slicer,
198  const ArrayBase& data);
199 
200  // Get all array values in the column.
201  // The array given in <src>data</src> has to have the correct shape
202  // (which is guaranteed by the ArrayColumn getColumn function).
203  virtual void getArrayColumnV (ArrayBase& arr);
204 
205  // Put all array values in the column.
206  // The array given in <src>data</src> has to have the correct shape
207  // (which is guaranteed by the ArrayColumn getColumn function).
208  virtual void putArrayColumnV (const ArrayBase& arr);
209 
210  // Get the array values in some cells of the column.
211  // The array given in <src>data</src> has to have the correct shape
212  // (which is guaranteed by the ArrayColumn getColumnCells function).
213  virtual void getArrayColumnCellsV (const RefRows& rownrs,
214  ArrayBase& data);
215 
216  // Put the array values into some cells of the column.
217  // The array given in <src>data</src> has to have the correct shape
218  // (which is guaranteed by the ArrayColumn getColumn function).
219  virtual void putArrayColumnCellsV (const RefRows& rownrs,
220  const ArrayBase& dataPtr);
221 
222  // Get a section of all arrays in the column.
223  // The array given in <src>data</src> has to have the correct shape
224  // (which is guaranteed by the ArrayColumn getColumn function).
225  virtual void getColumnSliceV (const Slicer& slicer, ArrayBase& arr);
226 
227  // Put a section into all array values in the column.
228  // The array given in <src>data</src> has to have the correct shape
229  // (which is guaranteed by the ArrayColumn getColumn function).
230  virtual void putColumnSliceV (const Slicer& slicer,
231  const ArrayBase& data);
232 
233  // Get a section from some cells of the column.
234  // The array given in <src>data</src> has to have the correct shape
235  // (which is guaranteed by the ArrayColumn getColumnCells function).
236  virtual void getColumnSliceCellsV (const RefRows& rownrs,
237  const Slicer& ns,
238  ArrayBase& data);
239 
240  // Put into a section of some cells of the column.
241  // The array given in <src>data</src> has to have the correct shape
242  // (which is guaranteed by the ArrayColumn putColumnSlice function).
243  virtual void putColumnSliceCellsV (const RefRows& rownrs,
244  const Slicer& ns,
245  const ArrayBase& data);
246 
247  // Read the data of the column from a tile.
248  // (I.e. convert from external to local format).
249  void readTile (void* to, const void* from, uInt nrPixels);
250 
251  // Write the data of the column into a tile.
252  // (I.e. convert from local to external format).
253  void writeTile (void* to, const void* from, uInt nrPixels);
254 
255  // Get the function to convert from external to local format
256  // (or vice-versa if <src>writeFlag=True</src>).
258  { return writeFlag ? writeFunc_p : readFunc_p; }
259 
260  // Get nr of elements in a value to convert (usually 1, but 2 for Complex).
261  size_t getNrConvert() const
262  { return convPixelSize_p; }
263 
264  // Does a conversion (byte swap) needs to be done?
266  { return mustConvert_p; }
267 
268 private:
269  // The (canonical) size of a pixel in a tile.
271  // The local size of a pixel.
273  // The multiplication factor for a conversion operation.
274  // This is the pixel size when a memcpy can be used, otherwise it is 1.
276  // Is a conversion necessary?
278  // The column sequence number.
280  // The conversion function needed when reading.
282  // The conversion function needed when writing.
284 
285 
286  // Forbid copy constructor.
287  TSMDataColumn (const TSMDataColumn&);
288 
289  // Forbid assignment.
291 
292  // Read or write a data cell in the cube.
293  // A cell can contain a scalar or an array (depending on the
294  // column definition).
295  void accessCell (rownr_t rownr,
296  const void* dataPtr, Bool writeFlag);
297 
298  // Read or write a slice of a data cell in the cube.
299  void accessCellSlice (rownr_t rownr, const Slicer& ns,
300  const void* dataPtr, Bool writeFlag);
301 
302  // Read or write an entire column.
303  // This can only be done if one hypercube is used.
304  void accessColumn (const void* dataPtr, Bool writeFlag);
305 
306  // Read or write a slice from the entire column.
307  // This can only be done if one hypercube is used.
308  void accessColumnSlice (const Slicer& ns,
309  const void* dataPtr, Bool writeFlag);
310 
311  // Read or write some cells in a column.
312  // It tries to optimize by looking for regular row strides.
313  void accessColumnCells (const RefRows& rownrs, const IPosition& shape,
314  const void* dataPtr, Bool writeFlag);
315 
316  // Read or write some cells in a column.
317  // It tries to optimize by looking for regular row strides.
318  void accessColumnSliceCells (const RefRows& rownrs, const Slicer& ns,
319  const IPosition& shape,
320  const void* dataPtr, Bool writeFlag);
321 
322  // Read or write the full cells given by start,end,incr.
323  void accessFullCells (TSMCube* hypercube,
324  char* dataPtr, Bool writeFlag,
325  const IPosition& start,
326  const IPosition& end,
327  const IPosition& incr);
328 
329  // Read or write the sliced cells given by start,end,incr.
330  void accessSlicedCells (TSMCube* hypercube,
331  char* dataPtr, Bool writeFlag,
332  const IPosition& start,
333  const IPosition& end,
334  const IPosition& incr);
335 };
336 
337 
339 {
340  return tilePixelSize_p;
341 }
343 {
344  return localPixelSize_p;
345 }
347 {
348  colnr_p = colnr;
349 }
350 inline void TSMDataColumn::readTile (void* to, const void* from,
351  uInt nrPixels)
352 {
353  readFunc_p (to, from, nrPixels * convPixelSize_p);
354 }
355 inline void TSMDataColumn::writeTile (void* to, const void* from,
356  uInt nrPixels)
357 {
358  writeFunc_p (to, from, nrPixels * convPixelSize_p);
359 }
360 
361 
362 
363 } //# NAMESPACE CASACORE - END
364 
365 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
virtual void putuInt(rownr_t rownr, const uInt *dataPtr)
void accessColumnSlice(const Slicer &ns, const void *dataPtr, Bool writeFlag)
Read or write a slice from the entire column.
virtual void getSliceV(rownr_t rownr, const Slicer &slicer, ArrayBase &dataPtr)
Get into a section of the array in the given row.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
virtual void putInt64(rownr_t rownr, const Int64 *dataPtr)
int Int
Definition: aipstype.h:50
Non-templated base class for templated Array class.
Definition: ArrayBase.h:72
Conversion::ValueFunction * getConvertFunction(Bool writeFlag) const
Get the function to convert from external to local format (or vice-versa if writeFlag=True).
virtual void getArrayColumnV(ArrayBase &arr)
Get all array values in the column.
virtual void getuShort(rownr_t rownr, uShort *dataPtr)
TSMDataColumn & operator=(const TSMDataColumn &)
Forbid assignment.
Tiled hypercube in a table.
Definition: TSMCube.h:105
virtual void putuChar(rownr_t rownr, const uChar *dataPtr)
void writeTile(void *to, const void *from, uInt nrPixels)
Write the data of the column into a tile.
unsigned long long uInt64
Definition: aipsxtype.h:39
virtual void putColumnSliceCellsV(const RefRows &rownrs, const Slicer &ns, const ArrayBase &data)
Put into a section of some cells of the column.
virtual void putdouble(rownr_t rownr, const double *dataPtr)
unsigned char uChar
Definition: aipstype.h:47
virtual void putuShort(rownr_t rownr, const uShort *dataPtr)
virtual void getuChar(rownr_t rownr, uChar *dataPtr)
virtual void getInt64(rownr_t rownr, Int64 *dataPtr)
virtual void putArrayColumnCellsV(const RefRows &rownrs, const ArrayBase &dataPtr)
Put the array values into some cells of the column.
uInt tilePixelSize() const
Return the size of a pixel in the tile in external format.
void accessColumn(const void *dataPtr, Bool writeFlag)
Read or write an entire column.
void setColumnNumber(uInt colnr)
Set column sequence number.
virtual void putShort(rownr_t rownr, const Short *dataPtr)
virtual void putDComplex(rownr_t rownr, const DComplex *dataPtr)
Bool isConversionNeeded() const
Does a conversion (byte swap) needs to be done?
virtual void putComplex(rownr_t rownr, const Complex *dataPtr)
short Short
Definition: aipstype.h:48
A data column in Tiled Storage Manager.
Definition: TSMDataColumn.h:96
void readTile(void *to, const void *from, uInt nrPixels)
Read the data of the column from a tile.
virtual void getInt(rownr_t rownr, Int *dataPtr)
virtual void putInt(rownr_t rownr, const Int *dataPtr)
Bool isShapeDefined(rownr_t rownr)
Is the value shape defined in the given row?
size_t getNrConvert() const
Get nr of elements in a value to convert (usually 1, but 2 for Complex).
uInt localPixelSize() const
Return the size of a pixel in the tile in local format.
virtual void getColumnSliceCellsV(const RefRows &rownrs, const Slicer &ns, ArrayBase &data)
Get a section from some cells of the column.
void accessColumnCells(const RefRows &rownrs, const IPosition &shape, const void *dataPtr, Bool writeFlag)
Read or write some cells in a column.
void setShapeTiled(rownr_t rownr, const IPosition &shape, const IPosition &tileShape)
Set the shape and tile shape of the array in the given row.
virtual void putSliceV(rownr_t rownr, const Slicer &slicer, const ArrayBase &data)
Put into a section of the array in the given row.
virtual void getArrayV(rownr_t rownr, ArrayBase &data)
Get the array value in the given row.
TSMDataColumn(const TSMColumn &column)
Create a data column from the given column.
virtual void putArrayV(rownr_t rownr, const ArrayBase &data)
Put the array value into the given row.
virtual void getColumnSliceV(const Slicer &slicer, ArrayBase &arr)
Get a section of all arrays in the column.
Bool mustConvert_p
Is a conversion necessary?
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
IPosition shape(rownr_t rownr)
Get the shape of the item in the given row.
virtual void putfloat(rownr_t rownr, const float *dataPtr)
void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of the data array in the given row.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
uInt tilePixelSize_p
The (canonical) size of a pixel in a tile.
A column in the Tiled Storage Manager.
Definition: TSMColumn.h:97
virtual void getdouble(rownr_t rownr, double *dataPtr)
virtual void getDComplex(rownr_t rownr, DComplex *dataPtr)
Conversion::ValueFunction * writeFunc_p
The conversion function needed when writing.
virtual void getfloat(rownr_t rownr, float *dataPtr)
uInt localPixelSize_p
The local size of a pixel.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:288
virtual void getuInt(rownr_t rownr, uInt *dataPtr)
uInt convPixelSize_p
The multiplication factor for a conversion operation.
void accessCellSlice(rownr_t rownr, const Slicer &ns, const void *dataPtr, Bool writeFlag)
Read or write a slice of a data cell in the cube.
virtual void getArrayColumnCellsV(const RefRows &rownrs, ArrayBase &data)
Get the array values in some cells of the column.
Conversion::ValueFunction * readFunc_p
The conversion function needed when reading.
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
virtual void putColumnSliceV(const Slicer &slicer, const ArrayBase &data)
Put a section into all array values in the column.
void accessFullCells(TSMCube *hypercube, char *dataPtr, Bool writeFlag, const IPosition &start, const IPosition &end, const IPosition &incr)
Read or write the full cells given by start,end,incr.
Bool canChangeShape() const
Changing array shapes for non-FixedShape columns when the parent tiled storage manager can handle it...
uInt colnr_p
The column sequence number.
virtual void getShort(rownr_t rownr, Short *dataPtr)
virtual void getBool(rownr_t rownr, Bool *dataPtr)
Get a scalar value in the given row.
void accessCell(rownr_t rownr, const void *dataPtr, Bool writeFlag)
Read or write a data cell in the cube.
IPosition tileShape(rownr_t rownr)
Get the tile shape of the item in the given row.
uInt64 dataLength(uInt64 nrPixels) const
Determine the length to store the given number of pixels.
virtual void putBool(rownr_t rownr, const Bool *dataPtr)
Put a scalar value into the given row.
void accessSlicedCells(TSMCube *hypercube, char *dataPtr, Bool writeFlag, const IPosition &start, const IPosition &end, const IPosition &incr)
Read or write the sliced cells given by start,end,incr.
virtual void getComplex(rownr_t rownr, Complex *dataPtr)
unsigned int uInt
Definition: aipstype.h:51
virtual ~TSMDataColumn()
Frees up the storage.
size_t ValueFunction(void *to, const void *from, size_t nvalues)
Define the signature of a function converting nvalues values from internal to external format or vice...
Definition: Conversion.h:100
void accessColumnSliceCells(const RefRows &rownrs, const Slicer &ns, const IPosition &shape, const void *dataPtr, Bool writeFlag)
Read or write some cells in a column.
virtual void putArrayColumnV(const ArrayBase &arr)
Put all array values in the column.
unsigned short uShort
Definition: aipstype.h:49