casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TSMDataColumn.h
Go to the documentation of this file.
00001 //# TSMDataColumn.h: A data column in Tiled Storage Manager
00002 //# Copyright (C) 1995,1996,1997,1999,2002
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: TSMDataColumn.h 20859 2010-02-03 13:14:15Z gervandiepen $
00027 
00028 #ifndef TABLES_TSMDATACOLUMN_H
00029 #define TABLES_TSMDATACOLUMN_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/TSMColumn.h>
00035 #include <tables/Tables/TSMCube.h>
00036 #include <casa/BasicSL/Complex.h>
00037 #include <casa/Arrays/IPosition.h>
00038 #include <casa/BasicSL/String.h>
00039 #include <casa/OS/Conversion.h>
00040 
00041 namespace casa { //# NAMESPACE CASA - BEGIN
00042 
00043 //# Forward Declarations
00044 class Slicer;
00045 
00046 
00047 // <summary>
00048 // A data column in Tiled Storage Manager.
00049 // </summary>
00050 
00051 // <use visibility=local>
00052 
00053 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00054 // </reviewed>
00055 
00056 // <prerequisite>
00057 //# Classes you should understand before using this one.
00058 //   <li> <linkto class=TSMColumn>TSMColumn</linkto>
00059 //   <li> <linkto class=TSMCube>TSMCube</linkto>
00060 // </prerequisite>
00061 
00062 // <etymology>
00063 // TSMDataColumn handles a data column for a Tiled
00064 // Storage Manager.
00065 // </etymology>
00066 
00067 // <synopsis> 
00068 // TSMDataColumn is used by 
00069 // <linkto class=TiledStMan>TiledStMan</linkto>
00070 // to handle the access to
00071 // a table column containing data of a tiled hypercube axis.
00072 // The data in a cell can be a scalar or an array (depending on its
00073 // definition in the table column description).
00074 // The shapes of the coordinates and the data are related. Therefore
00075 // the function setShape checks if the data shape matches the coordinates
00076 // shape.
00077 // <p>
00078 // The data are held in a TSMCube object. The row number
00079 // determines which TSMCube object has to be accessed.
00080 // <p>
00081 // The creation of a TSMDataColumn object is done by a TSMColumn object.
00082 // This process is described in more detail in the class
00083 // <linkto class=TSMColumn>TSMColumn</linkto>.
00084 // </synopsis> 
00085 
00086 // <motivation>
00087 // Handling data columns in the Tiled Storage Manager is
00088 // different from other columns.
00089 // </motivation>
00090 
00091 //# <todo asof="$DATE:$">
00092 //# A List of bugs, limitations, extensions or planned refinements.
00093 //# </todo>
00094 
00095 
00096 class TSMDataColumn : public TSMColumn
00097 {
00098 public:
00099 
00100     // Create a data column from the given column.
00101     TSMDataColumn (const TSMColumn& column);
00102 
00103     // Frees up the storage.
00104     virtual ~TSMDataColumn();
00105 
00106     // Return the size of a pixel in the tile in external format.
00107     uInt tilePixelSize() const;
00108 
00109     // Return the size of a pixel in the tile in local format.
00110     uInt localPixelSize() const;
00111 
00112     // Determine the length to store the given number of pixels.
00113     uInt dataLength (uInt nrPixels) const;
00114 
00115     // Set column sequence number.
00116     void setColumnNumber (uInt colnr);
00117 
00118     // It can handle access to a scalar column if there is one hypercube.
00119     Bool canAccessScalarColumn (Bool& reask) const;
00120 
00121     // It can handle access to an array column if there is one hypercube.
00122     Bool canAccessArrayColumn (Bool& reask) const;
00123 
00124     // It can handle access to a slice in a cell.
00125     Bool canAccessSlice (Bool& reask) const;
00126 
00127     // It can handle access to a slice in column if there is one hypercube.
00128     Bool canAccessColumnSlice (Bool& reask) const;
00129 
00130     // Changing array shapes for non-FixedShape columns when the
00131     // parent tiled storage manager can handle it.
00132     Bool canChangeShape() const;
00133 
00134     // Set the shape of the data array in the given row.
00135     // It will check if it matches already defined data and coordinates shapes.
00136     // It will define undefined data and coordinates shapes.
00137     void setShape (uInt rownr, const IPosition& shape);
00138 
00139     // Set the shape and tile shape of the array in the given row.
00140     // It will check if it matches already defined data and coordinates shapes.
00141     // It will define undefined data and coordinates shapes.
00142     // The tile shape is adjusted to the array shape (size 0 gets set to 1;
00143     // size > cubesize gets set to the cubesize).
00144     void setShapeTiled (uInt rownr, const IPosition& shape,
00145                         const IPosition& tileShape);
00146 
00147     // Is the value shape defined in the given row?
00148     Bool isShapeDefined (uInt rownr);
00149 
00150     // Get the shape of the item in the given row.
00151     IPosition shape (uInt rownr);
00152 
00153     // Get a scalar value in the given row.
00154     // The buffer pointed to by dataPtr has to have the correct length
00155     // (which is guaranteed by the Scalar/ArrayColumn get function).
00156     // <group>
00157     void getBoolV     (uInt rownr, Bool* dataPtr);
00158     void getuCharV    (uInt rownr, uChar* dataPtr);
00159     void getShortV    (uInt rownr, Short* dataPtr);
00160     void getuShortV   (uInt rownr, uShort* dataPtr);
00161     void getIntV      (uInt rownr, Int* dataPtr);
00162     void getuIntV     (uInt rownr, uInt* dataPtr);
00163     void getfloatV    (uInt rownr, float* dataPtr);
00164     void getdoubleV   (uInt rownr, double* dataPtr);
00165     void getComplexV  (uInt rownr, Complex* dataPtr);
00166     void getDComplexV (uInt rownr, DComplex* dataPtr);
00167     // </group>
00168 
00169     // Put a scalar value into the given row.
00170     // The buffer pointed to by dataPtr has to have the correct length
00171     // (which is guaranteed by the Scalar/ArrayColumn put function).
00172     // <group>
00173     void putBoolV     (uInt rownr, const Bool* dataPtr);
00174     void putuCharV    (uInt rownr, const uChar* dataPtr);
00175     void putShortV    (uInt rownr, const Short* dataPtr);
00176     void putuShortV   (uInt rownr, const uShort* dataPtr);
00177     void putIntV      (uInt rownr, const Int* dataPtr);
00178     void putuIntV     (uInt rownr, const uInt* dataPtr);
00179     void putfloatV    (uInt rownr, const float* dataPtr);
00180     void putdoubleV   (uInt rownr, const double* dataPtr);
00181     void putComplexV  (uInt rownr, const Complex* dataPtr);
00182     void putDComplexV (uInt rownr, const DComplex* dataPtr);
00183     // </group>
00184 
00185     // Get the array value in the given row.
00186     // The array pointed to by dataPtr has to have the correct length
00187     // (which is guaranteed by the ArrayColumn get function).
00188     // The default implementation thrown an "invalid operation exception".
00189     // <group>
00190     void getArrayBoolV     (uInt rownr, Array<Bool>* dataPtr);
00191     void getArrayuCharV    (uInt rownr, Array<uChar>* dataPtr);
00192     void getArrayShortV    (uInt rownr, Array<Short>* dataPtr);
00193     void getArrayuShortV   (uInt rownr, Array<uShort>* dataPtr);
00194     void getArrayIntV      (uInt rownr, Array<Int>* dataPtr);
00195     void getArrayuIntV     (uInt rownr, Array<uInt>* dataPtr);
00196     void getArrayfloatV    (uInt rownr, Array<float>* dataPtr);
00197     void getArraydoubleV   (uInt rownr, Array<double>* dataPtr);
00198     void getArrayComplexV  (uInt rownr, Array<Complex>* dataPtr);
00199     void getArrayDComplexV (uInt rownr, Array<DComplex>* dataPtr);
00200     // </group>
00201 
00202     // Put the array value into the given row.
00203     // The buffer pointed to by dataPtr has to have the correct length
00204     // (which is guaranteed by the ArrayColumn put function).
00205     // The default implementation thrown an "invalid operation exception".
00206     // <group>
00207     void putArrayBoolV     (uInt rownr, const Array<Bool>* dataPtr);
00208     void putArrayuCharV    (uInt rownr, const Array<uChar>* dataPtr);
00209     void putArrayShortV    (uInt rownr, const Array<Short>* dataPtr);
00210     void putArrayuShortV   (uInt rownr, const Array<uShort>* dataPtr);
00211     void putArrayIntV      (uInt rownr, const Array<Int>* dataPtr);
00212     void putArrayuIntV     (uInt rownr, const Array<uInt>* dataPtr);
00213     void putArrayfloatV    (uInt rownr, const Array<float>* dataPtr);
00214     void putArraydoubleV   (uInt rownr, const Array<double>* dataPtr);
00215     void putArrayComplexV  (uInt rownr, const Array<Complex>* dataPtr);
00216     void putArrayDComplexV (uInt rownr, const Array<DComplex>* dataPtr);
00217     // </group>
00218 
00219     void getSliceBoolV     (uInt rownr, const Slicer& slicer,
00220                             Array<Bool>* dataPtr);
00221     void getSliceuCharV    (uInt rownr, const Slicer& slicer,
00222                             Array<uChar>* dataPtr);
00223     void getSliceShortV    (uInt rownr, const Slicer& slicer,
00224                             Array<Short>* dataPtr);
00225     void getSliceuShortV   (uInt rownr, const Slicer& slicer,
00226                             Array<uShort>* dataPtr);
00227     void getSliceIntV      (uInt rownr, const Slicer& slicer,
00228                             Array<Int>* dataPtr);
00229     void getSliceuIntV     (uInt rownr, const Slicer& slicer,
00230                             Array<uInt>* dataPtr);
00231     void getSlicefloatV    (uInt rownr, const Slicer& slicer,
00232                             Array<float>* dataPtr);
00233     void getSlicedoubleV   (uInt rownr, const Slicer& slicer,
00234                             Array<double>* dataPtr);
00235     void getSliceComplexV  (uInt rownr, const Slicer& slicer,
00236                             Array<Complex>* dataPtr);
00237     void getSliceDComplexV (uInt rownr, const Slicer& slicer,
00238                             Array<DComplex>* dataPtr);
00239 
00240     void putSliceBoolV     (uInt rownr, const Slicer& slicer,
00241                             const Array<Bool>* dataPtr);
00242     void putSliceuCharV    (uInt rownr, const Slicer& slicer,
00243                             const Array<uChar>* dataPtr);
00244     void putSliceShortV    (uInt rownr, const Slicer& slicer,
00245                             const Array<Short>* dataPtr);
00246     void putSliceuShortV   (uInt rownr, const Slicer& slicer,
00247                             const Array<uShort>* dataPtr);
00248     void putSliceIntV      (uInt rownr, const Slicer& slicer,
00249                             const Array<Int>* dataPtr);
00250     void putSliceuIntV     (uInt rownr, const Slicer& slicer,
00251                             const Array<uInt>* dataPtr);
00252     void putSlicefloatV    (uInt rownr, const Slicer& slicer,
00253                             const Array<float>* dataPtr);
00254     void putSlicedoubleV   (uInt rownr, const Slicer& slicer,
00255                             const Array<double>* dataPtr);
00256     void putSliceComplexV  (uInt rownr, const Slicer& slicer,
00257                             const Array<Complex>* dataPtr);
00258     void putSliceDComplexV (uInt rownr, const Slicer& slicer,
00259                             const Array<DComplex>* dataPtr);
00260 
00261     void getScalarColumnBoolV     (Vector<Bool>* arr);
00262     void getScalarColumnuCharV    (Vector<uChar>* arr);
00263     void getScalarColumnShortV    (Vector<Short>* arr);
00264     void getScalarColumnuShortV   (Vector<uShort>* arr);
00265     void getScalarColumnIntV      (Vector<Int>* arr);
00266     void getScalarColumnuIntV     (Vector<uInt>* arr);
00267     void getScalarColumnfloatV    (Vector<float>* arr);
00268     void getScalarColumndoubleV   (Vector<double>* arr);
00269     void getScalarColumnComplexV  (Vector<Complex>* arr);
00270     void getScalarColumnDComplexV (Vector<DComplex>* arr);
00271 
00272     void putScalarColumnBoolV     (const Vector<Bool>* arr);
00273     void putScalarColumnuCharV    (const Vector<uChar>* arr);
00274     void putScalarColumnShortV    (const Vector<Short>* arr);
00275     void putScalarColumnuShortV   (const Vector<uShort>* arr);
00276     void putScalarColumnIntV      (const Vector<Int>* arr);
00277     void putScalarColumnuIntV     (const Vector<uInt>* arr);
00278     void putScalarColumnfloatV    (const Vector<float>* arr);
00279     void putScalarColumndoubleV   (const Vector<double>* arr);
00280     void putScalarColumnComplexV  (const Vector<Complex>* arr);
00281     void putScalarColumnDComplexV (const Vector<DComplex>* arr);
00282 
00283     // Get the scalar values in some cells of the column.
00284     // The buffer pointed to by dataPtr has to have the correct length.
00285     // (which is guaranteed by the ScalarColumn getColumnCells function).
00286     // The default implementation loops through all rows.
00287     // <group>
00288     virtual void getScalarColumnCellsBoolV     (const RefRows& rownrs,
00289                                                 Vector<Bool>* dataPtr);
00290     virtual void getScalarColumnCellsuCharV    (const RefRows& rownrs,
00291                                                 Vector<uChar>* dataPtr);
00292     virtual void getScalarColumnCellsShortV    (const RefRows& rownrs,
00293                                                 Vector<Short>* dataPtr);
00294     virtual void getScalarColumnCellsuShortV   (const RefRows& rownrs,
00295                                                 Vector<uShort>* dataPtr);
00296     virtual void getScalarColumnCellsIntV      (const RefRows& rownrs,
00297                                                 Vector<Int>* dataPtr);
00298     virtual void getScalarColumnCellsuIntV     (const RefRows& rownrs,
00299                                                 Vector<uInt>* dataPtr);
00300     virtual void getScalarColumnCellsfloatV    (const RefRows& rownrs,
00301                                                 Vector<float>* dataPtr);
00302     virtual void getScalarColumnCellsdoubleV   (const RefRows& rownrs,
00303                                                 Vector<double>* dataPtr);
00304     virtual void getScalarColumnCellsComplexV  (const RefRows& rownrs,
00305                                                 Vector<Complex>* dataPtr);
00306     virtual void getScalarColumnCellsDComplexV (const RefRows& rownrs,
00307                                                 Vector<DComplex>* dataPtr);
00308     // </group>
00309 
00310     // Put the scalar values into some cells of the column.
00311     // The buffer pointed to by dataPtr has to have the correct length.
00312     // (which is guaranteed by the ScalarColumn putColumnCells function).
00313     // The default implementation loops through all rows.
00314     // <group>
00315     virtual void putScalarColumnCellsBoolV     (const RefRows& rownrs,
00316                                                 const Vector<Bool>* dataPtr);
00317     virtual void putScalarColumnCellsuCharV    (const RefRows& rownrs,
00318                                                 const Vector<uChar>* dataPtr);
00319     virtual void putScalarColumnCellsShortV    (const RefRows& rownrs,
00320                                                 const Vector<Short>* dataPtr);
00321     virtual void putScalarColumnCellsuShortV   (const RefRows& rownrs,
00322                                                 const Vector<uShort>* dataPtr);
00323     virtual void putScalarColumnCellsIntV      (const RefRows& rownrs,
00324                                                 const Vector<Int>* dataPtr);
00325     virtual void putScalarColumnCellsuIntV     (const RefRows& rownrs,
00326                                                 const Vector<uInt>* dataPtr);
00327     virtual void putScalarColumnCellsfloatV    (const RefRows& rownrs,
00328                                                 const Vector<float>* dataPtr);
00329     virtual void putScalarColumnCellsdoubleV   (const RefRows& rownrs,
00330                                                 const Vector<double>* dataPtr);
00331     virtual void putScalarColumnCellsComplexV  (const RefRows& rownrs,
00332                                                 const Vector<Complex>* dataPtr);
00333     virtual void putScalarColumnCellsDComplexV (const RefRows& rownrs,
00334                                                const Vector<DComplex>* dataPtr);
00335     // </group>
00336 
00337     void getArrayColumnBoolV     (Array<Bool>* arr);
00338     void getArrayColumnuCharV    (Array<uChar>* arr);
00339     void getArrayColumnShortV    (Array<Short>* arr);
00340     void getArrayColumnuShortV   (Array<uShort>* arr);
00341     void getArrayColumnIntV      (Array<Int>* arr);
00342     void getArrayColumnuIntV     (Array<uInt>* arr);
00343     void getArrayColumnfloatV    (Array<float>* arr);
00344     void getArrayColumndoubleV   (Array<double>* arr);
00345     void getArrayColumnComplexV  (Array<Complex>* arr);
00346     void getArrayColumnDComplexV (Array<DComplex>* arr);
00347 
00348     void putArrayColumnBoolV     (const Array<Bool>* arr);
00349     void putArrayColumnuCharV    (const Array<uChar>* arr);
00350     void putArrayColumnShortV    (const Array<Short>* arr);
00351     void putArrayColumnuShortV   (const Array<uShort>* arr);
00352     void putArrayColumnIntV      (const Array<Int>* arr);
00353     void putArrayColumnuIntV     (const Array<uInt>* arr);
00354     void putArrayColumnfloatV    (const Array<float>* arr);
00355     void putArrayColumndoubleV   (const Array<double>* arr);
00356     void putArrayColumnComplexV  (const Array<Complex>* arr);
00357     void putArrayColumnDComplexV (const Array<DComplex>* arr);
00358 
00359     // Get the array values in some cells of the column.
00360     // The buffer pointed to by dataPtr has to have the correct length.
00361     // (which is guaranteed by the ArrayColumn getColumnCells function).
00362     // The default implementation throws an "invalid operation exception".
00363     // <group>
00364     virtual void getArrayColumnCellsBoolV     (const RefRows& rownrs,
00365                                                Array<Bool>* dataPtr);
00366     virtual void getArrayColumnCellsuCharV    (const RefRows& rownrs,
00367                                                Array<uChar>* dataPtr);
00368     virtual void getArrayColumnCellsShortV    (const RefRows& rownrs,
00369                                                Array<Short>* dataPtr);
00370     virtual void getArrayColumnCellsuShortV   (const RefRows& rownrs,
00371                                                Array<uShort>* dataPtr);
00372     virtual void getArrayColumnCellsIntV      (const RefRows& rownrs,
00373                                                Array<Int>* dataPtr);
00374     virtual void getArrayColumnCellsuIntV     (const RefRows& rownrs,
00375                                                Array<uInt>* dataPtr);
00376     virtual void getArrayColumnCellsfloatV    (const RefRows& rownrs,
00377                                                Array<float>* dataPtr);
00378     virtual void getArrayColumnCellsdoubleV   (const RefRows& rownrs,
00379                                                Array<double>* dataPtr);
00380     virtual void getArrayColumnCellsComplexV  (const RefRows& rownrs,
00381                                                Array<Complex>* dataPtr);
00382     virtual void getArrayColumnCellsDComplexV (const RefRows& rownrs,
00383                                                Array<DComplex>* dataPtr);
00384     // </group>
00385 
00386     // Put the array values into some cells of the column.
00387     // The buffer pointed to by dataPtr has to have the correct length.
00388     // (which is guaranteed by the ArrayColumn putColumnCells function).
00389     // The default implementation throws an "invalid operation exception".
00390     // <group>
00391     virtual void putArrayColumnCellsBoolV     (const RefRows& rownrs,
00392                                                const Array<Bool>* dataPtr);
00393     virtual void putArrayColumnCellsuCharV    (const RefRows& rownrs,
00394                                                const Array<uChar>* dataPtr);
00395     virtual void putArrayColumnCellsShortV    (const RefRows& rownrs,
00396                                                const Array<Short>* dataPtr);
00397     virtual void putArrayColumnCellsuShortV   (const RefRows& rownrs,
00398                                                const Array<uShort>* dataPtr);
00399     virtual void putArrayColumnCellsIntV      (const RefRows& rownrs,
00400                                                const Array<Int>* dataPtr);
00401     virtual void putArrayColumnCellsuIntV     (const RefRows& rownrs,
00402                                                const Array<uInt>* dataPtr);
00403     virtual void putArrayColumnCellsfloatV    (const RefRows& rownrs,
00404                                                const Array<float>* dataPtr);
00405     virtual void putArrayColumnCellsdoubleV   (const RefRows& rownrs,
00406                                                const Array<double>* dataPtr);
00407     virtual void putArrayColumnCellsComplexV  (const RefRows& rownrs,
00408                                                const Array<Complex>* dataPtr);
00409     virtual void putArrayColumnCellsDComplexV (const RefRows& rownrs,
00410                                                const Array<DComplex>* dataPtr);
00411     // </group>
00412 
00413     void getColumnSliceBoolV     (const Slicer& slicer, Array<Bool>* arr);
00414     void getColumnSliceuCharV    (const Slicer& slicer, Array<uChar>* arr);
00415     void getColumnSliceShortV    (const Slicer& slicer, Array<Short>* arr);
00416     void getColumnSliceuShortV   (const Slicer& slicer, Array<uShort>* arr);
00417     void getColumnSliceIntV      (const Slicer& slicer, Array<Int>* arr);
00418     void getColumnSliceuIntV     (const Slicer& slicer, Array<uInt>* arr);
00419     void getColumnSlicefloatV    (const Slicer& slicer, Array<float>* arr);
00420     void getColumnSlicedoubleV   (const Slicer& slicer, Array<double>* arr);
00421     void getColumnSliceComplexV  (const Slicer& slicer, Array<Complex>* arr);
00422     void getColumnSliceDComplexV (const Slicer& slicer, Array<DComplex>* arr);
00423 
00424     void putColumnSliceBoolV     (const Slicer& slicer,
00425                                   const Array<Bool>* dataPtr);
00426     void putColumnSliceuCharV    (const Slicer& slicer,
00427                                   const Array<uChar>* dataPtr);
00428     void putColumnSliceShortV    (const Slicer& slicer,
00429                                   const Array<Short>* dataPtr);
00430     void putColumnSliceuShortV   (const Slicer& slicer,
00431                                   const Array<uShort>* dataPtr);
00432     void putColumnSliceIntV      (const Slicer& slicer,
00433                                   const Array<Int>* dataPtr);
00434     void putColumnSliceuIntV     (const Slicer& slicer,
00435                                   const Array<uInt>* dataPtr);
00436     void putColumnSlicefloatV    (const Slicer& slicer,
00437                                   const Array<float>* dataPtr);
00438     void putColumnSlicedoubleV   (const Slicer& slicer,
00439                                   const Array<double>* dataPtr);
00440     void putColumnSliceComplexV  (const Slicer& slicer,
00441                                   const Array<Complex>* dataPtr);
00442     void putColumnSliceDComplexV (const Slicer& slicer,
00443                                   const Array<DComplex>* dataPtr);
00444  
00445     // Get the array values in some cells of the column.
00446     // The buffer pointed to by dataPtr has to have the correct length.
00447     // (which is guaranteed by the ArrayColumn getColumnCells function).
00448     // The default implementation throws an "invalid operation exception".
00449     // <group>
00450     virtual void getColumnSliceCellsBoolV     (const RefRows& rownrs,
00451                                                const Slicer& ns,
00452                                                Array<Bool>* dataPtr);
00453     virtual void getColumnSliceCellsuCharV    (const RefRows& rownrs,
00454                                                const Slicer& ns,
00455                                                Array<uChar>* dataPtr);
00456     virtual void getColumnSliceCellsShortV    (const RefRows& rownrs,
00457                                                const Slicer& ns,
00458                                                Array<Short>* dataPtr);
00459     virtual void getColumnSliceCellsuShortV   (const RefRows& rownrs,
00460                                                const Slicer& ns,
00461                                                Array<uShort>* dataPtr);
00462     virtual void getColumnSliceCellsIntV      (const RefRows& rownrs,
00463                                                const Slicer& ns,
00464                                                Array<Int>* dataPtr);
00465     virtual void getColumnSliceCellsuIntV     (const RefRows& rownrs,
00466                                                const Slicer& ns,
00467                                                Array<uInt>* dataPtr);
00468     virtual void getColumnSliceCellsfloatV    (const RefRows& rownrs,
00469                                                const Slicer& ns,
00470                                                Array<float>* dataPtr);
00471     virtual void getColumnSliceCellsdoubleV   (const RefRows& rownrs,
00472                                                const Slicer& ns,
00473                                                Array<double>* dataPtr);
00474     virtual void getColumnSliceCellsComplexV  (const RefRows& rownrs,
00475                                                const Slicer& ns,
00476                                                Array<Complex>* dataPtr);
00477     virtual void getColumnSliceCellsDComplexV (const RefRows& rownrs,
00478                                                const Slicer& ns,
00479                                                Array<DComplex>* dataPtr);
00480     // </group>
00481 
00482     // Put the array values into some cells of the column.
00483     // The buffer pointed to by dataPtr has to have the correct length.
00484     // (which is guaranteed by the ArrayColumn putColumnSlice function).
00485     // The default implementation throws an "invalid operation exception".
00486     // <group>
00487     virtual void putColumnSliceCellsBoolV     (const RefRows& rownrs,
00488                                                const Slicer& ns,
00489                                                const Array<Bool>* dataPtr);
00490     virtual void putColumnSliceCellsuCharV    (const RefRows& rownrs,
00491                                                const Slicer& ns,
00492                                                const Array<uChar>* dataPtr);
00493     virtual void putColumnSliceCellsShortV    (const RefRows& rownrs,
00494                                                const Slicer& ns,
00495                                                const Array<Short>* dataPtr);
00496     virtual void putColumnSliceCellsuShortV   (const RefRows& rownrs,
00497                                                const Slicer& ns,
00498                                                const Array<uShort>* dataPtr);
00499     virtual void putColumnSliceCellsIntV      (const RefRows& rownrs,
00500                                                const Slicer& ns,
00501                                                const Array<Int>* dataPtr);
00502     virtual void putColumnSliceCellsuIntV     (const RefRows& rownrs,
00503                                                const Slicer& ns,
00504                                                const Array<uInt>* dataPtr);
00505     virtual void putColumnSliceCellsfloatV    (const RefRows& rownrs,
00506                                                const Slicer& ns,
00507                                                const Array<float>* dataPtr);
00508     virtual void putColumnSliceCellsdoubleV   (const RefRows& rownrs,
00509                                                const Slicer& ns,
00510                                                const Array<double>* dataPtr);
00511     virtual void putColumnSliceCellsComplexV  (const RefRows& rownrs,
00512                                                const Slicer& ns,
00513                                                const Array<Complex>* dataPtr);
00514     virtual void putColumnSliceCellsDComplexV (const RefRows& rownrs,
00515                                                const Slicer& ns,
00516                                                const Array<DComplex>* dataPtr);
00517     // </group>
00518 
00519     // Read the data of the column from a tile.
00520     // (I.e. convert from external to local format).
00521     void readTile (void* to, const void* from, uInt nrPixels);
00522 
00523     // Write the data of the column into a tile.
00524     // (I.e. convert from local to external format).
00525     void writeTile (void* to, const void* from, uInt nrPixels);
00526 
00527     // Get the function to convert from external to local format
00528     // (or vice-versa if <src>writeFlag=True</src>).
00529     Conversion::ValueFunction* getConvertFunction (Bool writeFlag) const
00530       { return writeFlag ?  writeFunc_p : readFunc_p; }
00531 
00532     // Get nr of elements in a value to convert (usually 1, but 2 for Complex).
00533     size_t getNrConvert() const
00534       { return convPixelSize_p; }
00535 
00536     // Does a conversion (byte swap) needs to be done?
00537     Bool isConversionNeeded() const
00538       { return mustConvert_p; }
00539 
00540 private:
00541     // The (canonical) size of a pixel in a tile.
00542     uInt tilePixelSize_p;
00543     // The local size of a pixel.
00544     uInt localPixelSize_p;
00545     // The multiplication factor for a conversion operation.
00546     // This is the pixel size when a memcpy can be used, otherwise it is 1.
00547     uInt convPixelSize_p;
00548     // Is a conversion necessary?
00549     Bool mustConvert_p;
00550     // The column sequence number.
00551     uInt colnr_p;
00552     // The conversion function needed when reading.
00553     Conversion::ValueFunction* readFunc_p;
00554     // The conversion function needed when writing.
00555     Conversion::ValueFunction* writeFunc_p;
00556 
00557 
00558     // Forbid copy constructor.
00559     TSMDataColumn (const TSMDataColumn&);
00560 
00561     // Forbid assignment.
00562     TSMDataColumn& operator= (const TSMDataColumn&);
00563 
00564     // Read or write a data cell in the cube.
00565     // A cell can contain a scalar or an array (depending on the
00566     // column definition).
00567     void accessCell (uInt rownr,
00568                      const void* dataPtr, Bool writeFlag);
00569 
00570     // Read or write a slice of a data cell in the cube.
00571     void accessCellSlice (uInt rownr, const Slicer& ns,
00572                           const void* dataPtr, Bool writeFlag);
00573 
00574     // Read or write an entire column.
00575     // This can only be done if one hypercube is used.
00576     void accessColumn (const void* dataPtr, Bool writeFlag);
00577 
00578     // Read or write a slice from the entire column.
00579     // This can only be done if one hypercube is used.
00580     void accessColumnSlice (const Slicer& ns,
00581                             const void* dataPtr, Bool writeFlag);
00582 
00583     // Read or write some cells in a column.
00584     // It tries to optimize by looking for regular row strides.
00585     void accessColumnCells (const RefRows& rownrs,  const IPosition& shape,
00586                             const void* dataPtr, Bool writeFlag);
00587 
00588     // Read or write some cells in a column.
00589     // It tries to optimize by looking for regular row strides.
00590     void accessColumnSliceCells (const RefRows& rownrs, const Slicer& ns,
00591                                  const IPosition& shape,
00592                                  const void* dataPtr, Bool writeFlag);
00593 
00594     // Read or write the full cells given by start,end,incr.
00595     void accessFullCells (TSMCube* hypercube,
00596                           char* dataPtr, Bool writeFlag,
00597                           const IPosition& start,
00598                           const IPosition& end,
00599                           const IPosition& incr);
00600 
00601     // Read or write the sliced cells given by start,end,incr.
00602     void accessSlicedCells (TSMCube* hypercube,
00603                             char* dataPtr, Bool writeFlag,
00604                             const IPosition& start,
00605                             const IPosition& end,
00606                             const IPosition& incr);
00607 };
00608 
00609 
00610 inline uInt TSMDataColumn::tilePixelSize() const
00611 {
00612     return tilePixelSize_p;
00613 }
00614 inline uInt TSMDataColumn::localPixelSize() const
00615 {
00616     return localPixelSize_p;
00617 }
00618 inline void TSMDataColumn::setColumnNumber (uInt colnr)
00619 {
00620     colnr_p = colnr;
00621 }
00622 inline void TSMDataColumn::readTile (void* to, const void* from,
00623                                      uInt nrPixels)
00624 {
00625     readFunc_p (to, from, nrPixels * convPixelSize_p);
00626 }
00627 inline void TSMDataColumn::writeTile (void* to, const void* from,
00628                                       uInt nrPixels)
00629 {
00630     writeFunc_p (to, from, nrPixels * convPixelSize_p);
00631 }
00632 
00633 
00634 
00635 } //# NAMESPACE CASA - END
00636 
00637 #endif