casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSMDirColumn.h
Go to the documentation of this file.
00001 //# MSMDirColumn.h: Memory storage manager for fixed shape table arrays
00002 //# Copyright (C) 2003
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: MSMDirColumn.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_MSMDIRCOLUMN_H
00029 #define TABLES_MSMDIRCOLUMN_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/MSMColumn.h>
00035 #include <casa/Arrays/IPosition.h>
00036 
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 // <summary>
00041 // Memory storage manager for table arrays
00042 // </summary>
00043 
00044 // <use visibility=local>
00045 
00046 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //# Classes you should understand before using this one.
00051 //   <li> MSMBase
00052 //   <li> MSMColumn
00053 // </prerequisite>
00054 
00055 // <synopsis> 
00056 // MSMDirColumn handles arrays in a table column.
00057 // It only keeps them in memory, so they are not persistent.
00058 // </synopsis> 
00059 
00060 //# <todo asof="$DATE:$">
00061 //# A List of bugs, limitations, extensions or planned refinements.
00062 //# </todo>
00063 
00064 
00065 class MSMDirColumn: public MSMColumn
00066 {
00067 public:
00068   // Create a column of the given type.
00069   MSMDirColumn (MSMBase* smptr, int dataType);
00070 
00071   // Frees up the storage.
00072   ~MSMDirColumn();
00073 
00074   // It can handle access to a slice in a cell.
00075   Bool canAccessSlice (Bool& reask) const;
00076 
00077   // It can handle access to an entire column.
00078   Bool canAccessArrayColumn (Bool& reask) const;
00079 
00080   // Set the (fixed) shape of the arrays in the entire column.
00081   void setShapeColumn (const IPosition& shape);
00082 
00083   // Add (newNrrow-oldNrrow) rows to the column.
00084   // Allocate the data arrays in these rows if the shape is fixed.
00085   void addRow (uInt newNrrow, uInt oldNrrow);
00086 
00087   // Get the dimensionality of the item in the given row.
00088   // 0 is returned if there is no array.
00089   uInt ndim (uInt rownr);
00090 
00091   // Get the shape of the array in the given row.
00092   // An zero-length IPosition is returned if there is no array.
00093   IPosition shape (uInt rownr);
00094 
00095   // Get an array value in the given row.
00096   // The buffer pointed to by dataPtr has to have the correct length
00097   // (which is guaranteed by the ArrayColumn get function).
00098   // <group>
00099   void getArrayBoolV     (uInt rownr, Array<Bool>* dataPtr);
00100   void getArrayuCharV    (uInt rownr, Array<uChar>* dataPtr);
00101   void getArrayShortV    (uInt rownr, Array<Short>* dataPtr);
00102   void getArrayuShortV   (uInt rownr, Array<uShort>* dataPtr);
00103   void getArrayIntV      (uInt rownr, Array<Int>* dataPtr);
00104   void getArrayuIntV     (uInt rownr, Array<uInt>* dataPtr);
00105   void getArrayfloatV    (uInt rownr, Array<float>* dataPtr);
00106   void getArraydoubleV   (uInt rownr, Array<double>* dataPtr);
00107   void getArrayComplexV  (uInt rownr, Array<Complex>* dataPtr);
00108   void getArrayDComplexV (uInt rownr, Array<DComplex>* dataPtr);
00109   void getArrayStringV   (uInt rownr, Array<String>* dataPtr);
00110   // </group>
00111 
00112   // Put an array value into the given row.
00113   // The buffer pointed to by dataPtr has to have the correct length
00114   // (which is guaranteed by the ArrayColumn put function).
00115   // <group>
00116   void putArrayBoolV     (uInt rownr, const Array<Bool>* dataPtr);
00117   void putArrayuCharV    (uInt rownr, const Array<uChar>* dataPtr);
00118   void putArrayShortV    (uInt rownr, const Array<Short>* dataPtr);
00119   void putArrayuShortV   (uInt rownr, const Array<uShort>* dataPtr);
00120   void putArrayIntV      (uInt rownr, const Array<Int>* dataPtr);
00121   void putArrayuIntV     (uInt rownr, const Array<uInt>* dataPtr);
00122   void putArrayfloatV    (uInt rownr, const Array<float>* dataPtr);
00123   void putArraydoubleV   (uInt rownr, const Array<double>* dataPtr);
00124   void putArrayComplexV  (uInt rownr, const Array<Complex>* dataPtr);
00125   void putArrayDComplexV (uInt rownr, const Array<DComplex>* dataPtr);
00126   void putArrayStringV   (uInt rownr, const Array<String>* dataPtr);
00127   // </group>
00128 
00129   // Get a section of the array in the given row.
00130   // The buffer pointed to by dataPtr has to have the correct length
00131   // (which is guaranteed by the ArrayColumn getSlice function).
00132   // <group>
00133   void getSliceBoolV     (uInt rownr, const Slicer&, Array<Bool>* dataPtr);
00134   void getSliceuCharV    (uInt rownr, const Slicer&, Array<uChar>* dataPtr);
00135   void getSliceShortV    (uInt rownr, const Slicer&, Array<Short>* dataPtr);
00136   void getSliceuShortV   (uInt rownr, const Slicer&, Array<uShort>* dataPtr);
00137   void getSliceIntV      (uInt rownr, const Slicer&, Array<Int>* dataPtr);
00138   void getSliceuIntV     (uInt rownr, const Slicer&, Array<uInt>* dataPtr);
00139   void getSlicefloatV    (uInt rownr, const Slicer&, Array<float>* dataPtr);
00140   void getSlicedoubleV   (uInt rownr, const Slicer&, Array<double>* dataPtr);
00141   void getSliceComplexV  (uInt rownr, const Slicer&, Array<Complex>* dataPtr);
00142   void getSliceDComplexV (uInt rownr, const Slicer&, Array<DComplex>* dataPtr);
00143   void getSliceStringV   (uInt rownr, const Slicer&, Array<String>* dataPtr);
00144   // </group>
00145 
00146   // Put into a section of the array in the given row.
00147   // The buffer pointed to by dataPtr has to have the correct length
00148   // (which is guaranteed by the ArrayColumn putSlice function).
00149   // <group>
00150   void putSliceBoolV     (uInt rownr, const Slicer&,
00151                           const Array<Bool>* dataPtr);
00152   void putSliceuCharV    (uInt rownr, const Slicer&,
00153                           const Array<uChar>* dataPtr);
00154   void putSliceShortV    (uInt rownr, const Slicer&,
00155                           const Array<Short>* dataPtr);
00156   void putSliceuShortV   (uInt rownr, const Slicer&,
00157                           const Array<uShort>* dataPtr);
00158   void putSliceIntV      (uInt rownr, const Slicer&,
00159                           const Array<Int>* dataPtr);
00160   void putSliceuIntV     (uInt rownr, const Slicer&,
00161                           const Array<uInt>* dataPtr);
00162   void putSlicefloatV    (uInt rownr, const Slicer&,
00163                           const Array<float>* dataPtr);
00164   void putSlicedoubleV   (uInt rownr, const Slicer&,
00165                           const Array<double>* dataPtr);
00166   void putSliceComplexV  (uInt rownr, const Slicer&,
00167                           const Array<Complex>* dataPtr);
00168   void putSliceDComplexV (uInt rownr, const Slicer&,
00169                           const Array<DComplex>* dataPtr);
00170   void putSliceStringV   (uInt rownr, const Slicer&,
00171                           const Array<String>* dataPtr);
00172   // </group>
00173 
00174   // Get all array values in the column.
00175   // The buffer pointed to by dataPtr has to have the correct length
00176   // (which is guaranteed by the ArrayColumn getColumn function).
00177   // <group>
00178   void getArrayColumnBoolV     (Array<Bool>* dataPtr);
00179   void getArrayColumnuCharV    (Array<uChar>* dataPtr);
00180   void getArrayColumnShortV    (Array<Short>* dataPtr);
00181   void getArrayColumnuShortV   (Array<uShort>* dataPtr);
00182   void getArrayColumnIntV      (Array<Int>* dataPtr);
00183   void getArrayColumnuIntV     (Array<uInt>* dataPtr);
00184   void getArrayColumnfloatV    (Array<float>* dataPtr);
00185   void getArrayColumndoubleV   (Array<double>* dataPtr);
00186   void getArrayColumnComplexV  (Array<Complex>* dataPtr);
00187   void getArrayColumnDComplexV (Array<DComplex>* dataPtr);
00188   void getArrayColumnStringV   (Array<String>* dataPtr);
00189   // </group>
00190 
00191   // Put all arrays in the column.
00192   // The buffer pointed to by dataPtr has to have the correct length
00193   // (which is guaranteed by the ArrayColumn putColumn function).
00194   // <group>
00195   void putArrayColumnBoolV     (const Array<Bool>* dataPtr);
00196   void putArrayColumnuCharV    (const Array<uChar>* dataPtr);
00197   void putArrayColumnShortV    (const Array<Short>* dataPtr);
00198   void putArrayColumnuShortV   (const Array<uShort>* dataPtr);
00199   void putArrayColumnIntV      (const Array<Int>* dataPtr);
00200   void putArrayColumnuIntV     (const Array<uInt>* dataPtr);
00201   void putArrayColumnfloatV    (const Array<float>* dataPtr);
00202   void putArrayColumndoubleV   (const Array<double>* dataPtr);
00203   void putArrayColumnComplexV  (const Array<Complex>* dataPtr);
00204   void putArrayColumnDComplexV (const Array<DComplex>* dataPtr);
00205   void putArrayColumnStringV   (const Array<String>* dataPtr);
00206   // </group>
00207 
00208   // Remove the value in the given row.
00209   void remove (uInt rownr);
00210 
00211   // Let the column create its arrays.
00212   void doCreate (uInt nrrow);
00213 
00214   // Check if the class invariants still hold.
00215   Bool ok() const;
00216 
00217 private:
00218   // The (unique) sequence number of the column.
00219   uInt seqnr_p;
00220   // The shape of the array.
00221   IPosition shape_p;
00222   // The nr of elements in the array.
00223   uInt nrelem_p;
00224 
00225 
00226   // Delete the array in the given row.
00227   void deleteArray (uInt rownr);
00228 
00229   // Forbid copy constructor.
00230   MSMDirColumn (const MSMDirColumn&);
00231 
00232   // Forbid assignment.
00233   MSMDirColumn& operator= (const MSMDirColumn&);
00234 };
00235 
00236 
00237 
00238 
00239 } //# NAMESPACE CASA - END
00240 
00241 #endif