casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SSMIndColumn.h
Go to the documentation of this file.
00001 //# SSMIndColumn.h: A column in Standard storage manager for indirect arrays
00002 //# Copyright (C) 2000
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: SSMIndColumn.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_SSMINDCOLUMN_H
00029 #define TABLES_SSMINDCOLUMN_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/SSMColumn.h>
00035 #include <tables/Tables/StIndArray.h>
00036 #include <casa/Arrays/IPosition.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //# Forward Declarations
00041 class StManArrayFile;
00042 class AipsIO;
00043 
00044 
00045 // <summary>
00046 // A column of Standard storage manager for indirect arrays.
00047 // </summary>
00048 
00049 // <use visibility=local>
00050 
00051 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tStandardStMan.cc">
00052 // </reviewed>
00053 
00054 // <prerequisite>
00055 //# Classes you should understand before using this one.
00056 //   <li> <linkto class=SSMColumn>SSMColumn</linkto>
00057 //   <li> <linkto class=StIndArray>StIndArray</linkto>
00058 // </prerequisite>
00059 
00060 // <etymology>
00061 // SSMIndColumn represents a Column in the Standard Storage Manager
00062 // containing Indirect arrays.
00063 // </etymology>
00064 
00065 // <synopsis> 
00066 // SSMIndColumn is the implementation of an
00067 // <linkto class=SSMColumn>SSMColumn</linkto> class
00068 // to handle indirect arrays. The arrays (shape and data) are stored in
00069 // a separate file using class <linkto class=StIndArray>StIndArray</linkto>.
00070 // The file offset of the beginning of the array in stored in the
00071 // appropriate data bucket using the standard SSMColumn functions.
00072 // <p>
00073 // Note that an indirect array can have a fixed shape. In that case
00074 // adding a row results in reserving space for the array in the StIndArray
00075 // file, so for each row an array is present.
00076 // On the other hand adding a row does nothing for variable shaped arrays.
00077 // So when no data is put or shape is set, a row may contain no array at all.
00078 // In that case the function <src>isShapeDefined</src> returns False for
00079 // that row.
00080 // <p>
00081 // Indirect arrays containing strings are not handled by this class, but
00082 // by <linkto class=SSMIndStringColumn>SSMIndStringColumn</linkto>.
00083 // That class stores those string arrays in the special string buckets
00084 // instead of using StIndArray. The reason is that the string buckets
00085 // are more disk space efficient when string arrays are frequently updated.
00086 // </synopsis> 
00087 
00088 //# <todo asof="$DATE:$">
00089 //# A List of bugs, limitations, extensions or planned refinements.
00090 //# </todo>
00091 
00092 
00093 class SSMIndColumn : public SSMColumn
00094 {
00095 public:
00096   // Create a column of the given data type.
00097   // It keeps the pointer to its parent (but does not own it).
00098   SSMIndColumn (SSMBase* aParent, int aDataType, uInt aColNr);
00099   
00100   // Frees up the storage.
00101   ~SSMIndColumn();
00102   
00103   // An array of 'fixed length' strings is not handled specially,
00104   // thus this function is ignored.
00105   // It is needed to override the bahviour of the base class.
00106   virtual void setMaxLength (uInt maxLength);
00107 
00108   // It can handle access to a slice in a cell.
00109   virtual Bool canAccessSlice (Bool& reask) const;
00110   
00111   // Add (newNrrow-oldNrrow) rows to the column.
00112   virtual void addRow (uInt aNewNrRows, uInt anOldNrRows, Bool doInit);
00113   
00114   // Set the (fixed) shape of the arrays in the entire column.
00115   virtual void setShapeColumn (const IPosition& aShape);
00116   
00117   // Get the dimensionality of the item in the given row.
00118   virtual uInt ndim (uInt aRowNr);
00119   
00120   // Set the shape of the array in the given row and allocate the array
00121   // in the file.
00122   void setShape (uInt aRowNr, const IPosition& aShape);
00123   
00124   // Is the shape defined (i.e. is there an array) in this row?
00125   virtual Bool isShapeDefined (uInt aRowNr);
00126   
00127   // Get the shape of the array in the given row.
00128   virtual IPosition shape (uInt aRowNr);
00129   
00130   // This storage manager can handle changing array shapes.
00131   Bool canChangeShape() const;
00132   
00133   // Get an array value in the given row.
00134   // The buffer pointed to by dataPtr has to have the correct length
00135   // (which is guaranteed by the ArrayColumn get function).
00136   // <group>
00137   virtual void getArrayBoolV     (uInt aRowNr, Array<Bool>* aDataPtr);
00138   virtual void getArrayuCharV    (uInt aRowNr, Array<uChar>* aDataPtr);
00139   virtual void getArrayShortV    (uInt aRowNr, Array<Short>* aDataPtr);
00140   virtual void getArrayuShortV   (uInt aRowNr, Array<uShort>* aDataPtr);
00141   virtual void getArrayIntV      (uInt aRowNr, Array<Int>* aDataPtr);
00142   virtual void getArrayuIntV     (uInt aRowNr, Array<uInt>* aDataPtr);
00143   virtual void getArrayfloatV    (uInt aRowNr, Array<float>* aDataPtr);
00144   virtual void getArraydoubleV   (uInt aRowNr, Array<double>* aDataPtr);
00145   virtual void getArrayComplexV  (uInt aRowNr, Array<Complex>* aDataPtr);
00146   virtual void getArrayDComplexV (uInt aRowNr, Array<DComplex>* aDataPtr);
00147   virtual void getArrayStringV   (uInt aRowNr, Array<String>* aDataPtr);
00148   // </group>
00149   
00150   // Put an array value into the given row.
00151   // The buffer pointed to by dataPtr has to have the correct length
00152   // (which is guaranteed by the ArrayColumn put function).
00153   // <group>
00154   virtual void putArrayBoolV     (uInt aRowNr,
00155                                   const Array<Bool>* aDataPtr);
00156   virtual void putArrayuCharV    (uInt aRowNr,
00157                                   const Array<uChar>* aDataPtr);
00158   virtual void putArrayShortV    (uInt aRowNr,
00159                                   const Array<Short>* aDataPtr);
00160   virtual void putArrayuShortV   (uInt aRowNr,
00161                                   const Array<uShort>* aDataPtr);
00162   virtual void putArrayIntV      (uInt aRowNr,
00163                                   const Array<Int>* aDataPtr);
00164   virtual void putArrayuIntV     (uInt aRowNr,
00165                                   const Array<uInt>* aDataPtr);
00166   virtual void putArrayfloatV    (uInt aRowNr,
00167                                   const Array<float>* aDataPtr);
00168   virtual void putArraydoubleV   (uInt aRowNr,
00169                                   const Array<double>* aDataPtr);
00170   virtual void putArrayComplexV  (uInt aRowNr,
00171                                   const Array<Complex>* aDataPtr);
00172   virtual void putArrayDComplexV (uInt aRowNr,
00173                                   const Array<DComplex>* aDataPtr);
00174   virtual void putArrayStringV   (uInt aRowNr,
00175                                   const Array<String>* aDataPtr);
00176   // </group>
00177   
00178   // Get a section of the array in the given row.
00179   // The buffer pointed to by dataPtr has to have the correct length
00180   // (which is guaranteed by the ArrayColumn getSlice function).
00181   // <group>
00182   virtual void getSliceBoolV     (uInt aRowNr, const Slicer&,
00183                                   Array<Bool>* aDataPtr);
00184   virtual void getSliceuCharV    (uInt aRowNr, const Slicer&,
00185                                   Array<uChar>* aDataPtr);
00186   virtual void getSliceShortV    (uInt aRowNr, const Slicer&,
00187                                   Array<Short>* aDataPtr);
00188   virtual void getSliceuShortV   (uInt aRowNr, const Slicer&,
00189                                   Array<uShort>* aDataPtr);
00190   virtual void getSliceIntV      (uInt aRowNr, const Slicer&,
00191                                   Array<Int>* aDataPtr);
00192   virtual void getSliceuIntV     (uInt aRowNr, const Slicer&,
00193                                   Array<uInt>* aDataPtr);
00194   virtual void getSlicefloatV    (uInt aRowNr, const Slicer&,
00195                                   Array<float>* aDataPtr);
00196   virtual void getSlicedoubleV   (uInt aRowNr, const Slicer&,
00197                                   Array<double>* aDataPtr);
00198   virtual void getSliceComplexV  (uInt aRowNr, const Slicer&,
00199                                   Array<Complex>* aDataPtr);
00200   virtual void getSliceDComplexV (uInt aRowNr, const Slicer&,
00201                                   Array<DComplex>* aDataPtr);
00202   virtual void getSliceStringV   (uInt aRowNr, const Slicer&,
00203                                   Array<String>* aDataPtr);
00204   // </group>
00205   
00206   // Put into a section of the array in the given row.
00207   // The buffer pointed to by aDataPtr has to have the correct length
00208   // (which is guaranteed by the ArrayColumn putSlice function).
00209   // <group>
00210   virtual void putSliceBoolV     (uInt aRowNr, const Slicer&,
00211                                   const Array<Bool>* aDataPtr);
00212   virtual void putSliceuCharV    (uInt aRowNr, const Slicer&,
00213                                   const Array<uChar>* aDataPtr);
00214   virtual void putSliceShortV    (uInt aRowNr, const Slicer&,
00215                                   const Array<Short>* aDataPtr);
00216   virtual void putSliceuShortV   (uInt aRowNr, const Slicer&,
00217                                   const Array<uShort>* aDataPtr);
00218   virtual void putSliceIntV      (uInt aRowNr, const Slicer&,
00219                                   const Array<Int>* aDataPtr);
00220   virtual void putSliceuIntV     (uInt aRowNr, const Slicer&,
00221                                   const Array<uInt>* aDataPtr);
00222   virtual void putSlicefloatV    (uInt aRowNr, const Slicer&,
00223                                   const Array<float>* aDataPtr);
00224   virtual void putSlicedoubleV   (uInt aRowNr, const Slicer&,
00225                                   const Array<double>* aDataPtr);
00226   virtual void putSliceComplexV  (uInt aRowNr, const Slicer&,
00227                                   const Array<Complex>* aDataPtr);
00228   virtual void putSliceDComplexV (uInt aRowNr, const Slicer&,
00229                                   const Array<DComplex>* aDataPtr);
00230   virtual void putSliceStringV   (uInt aRowNr, const Slicer&,
00231                                   const Array<String>* aDataPtr);
00232   // </group>
00233   
00234   // Let the column object create its array file.
00235   virtual void doCreate (uInt aNrRows);
00236 
00237   // Open an existing file.
00238   virtual void getFile (uInt aNrRows);
00239 
00240   // Remove the given row from the data bucket and possibly string bucket.
00241   virtual void deleteRow(uInt aRowNr);
00242 
00243 
00244 private:
00245   // Forbid copy constructor.
00246   SSMIndColumn (const SSMIndColumn&);
00247   
00248   // Forbid assignment.
00249   SSMIndColumn& operator= (const SSMIndColumn&);
00250   
00251   // Initialize part of the object and open/create the file.
00252   // It is used by doCreate and getFile.
00253   void init();
00254   
00255   // Read the shape at the given row.
00256   // This will cache the information in the StIndArray
00257   // object for that row.
00258   StIndArray* getShape (uInt aRowNr);
00259   
00260   // Return a pointer to the array in the given row (for a get).
00261   StIndArray* getArrayPtr (uInt aRowNr);
00262 
00263   
00264   //# The shape off all arrays in case it is fixed
00265   IPosition       itsFixedShape;
00266   //# Switch indicating if the shape is fixed.
00267   Bool            isShapeFixed;
00268   //# The file containing the arrays.
00269   StManArrayFile* itsIosFile;
00270   //# The indirect array object.
00271   StIndArray      itsIndArray;
00272 };
00273 
00274 
00275 
00276 } //# NAMESPACE CASA - END
00277 
00278 #endif