Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/BaseColumn_8h_source.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 20:32:52 2011 Кодировка: |
00001 //# BaseColumn.h: Abstract base class for a table column 00002 //# Copyright (C) 1994,1995,1996,1997,1998 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: BaseColumn.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $ 00027 00028 #ifndef TABLES_BASECOLUMN_H 00029 #define TABLES_BASECOLUMN_H 00030 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <tables/Tables/ColumnDesc.h> 00035 #include <casa/Utilities/Compare.h> 00036 #include <casa/BasicSL/Complex.h> 00037 00038 namespace casa { //# NAMESPACE CASA - BEGIN 00039 00040 //# Forward Declarations 00041 class BaseColumnDesc; 00042 class ColumnCache; 00043 class TableRecord; 00044 class RefRows; 00045 class IPosition; 00046 class Slicer; 00047 class Sort; 00048 template<class T> class Array; 00049 template<class T> class Vector; 00050 00051 // <summary> 00052 // Abstract base class for a table column 00053 // </summary> 00054 00055 // <use visibility=local> 00056 00057 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00058 // </reviewed> 00059 00060 // <prerequisite> 00061 //# Classes you should understand before using this one. 00062 // <li> ColumnDesc 00063 // <li> Table 00064 // </prerequisite> 00065 00066 // <etymology> 00067 // This is the (abstract) base class to access a column in a table. 00068 // </etymology> 00069 00070 // <synopsis> 00071 // This class is the base class for the derived column classes. 00072 // It is a private class in the sense that the user cannot get 00073 // access to it. All user access to a column is done via the 00074 // classes TableColumn, ScalarColumn and ArrayColumn. They call 00075 // the corresponding functions in this class and its derived classes. 00076 // </synopsis> 00077 00078 // <motivation> 00079 // This class serves a the base for the more specialized column classes 00080 // like FilledScalarColumn and RefColumn. It defines many virtual 00081 // functions, which are implemented in the derived classes. 00082 // Some of these functions are purely virtual, some have a default 00083 // implementation throwing an "invalid operation" exception. In that 00084 // way those latter functions only have to be implemented in the 00085 // classes which handle those cases. 00086 // <note role=tip> The class RefColumn is in fact implemented in terms of 00087 // this class. Almost every function in RefColumn calls the corresponding 00088 // function in BaseColumn with the correct row number. 00089 // </note> 00090 // </motivation> 00091 00092 // <todo asof="$DATE:$"> 00093 //# A List of bugs, limitations, extensions or planned refinements. 00094 // </todo> 00095 00096 00097 class BaseColumn 00098 { 00099 public: 00100 00101 // Construct it using the given column description. 00102 BaseColumn (const BaseColumnDesc*); 00103 00104 virtual ~BaseColumn(); 00105 00106 // Test if the column is writable. 00107 virtual Bool isWritable() const = 0; 00108 00109 // Test if the column is stored (otherwise it is virtual). 00110 virtual Bool isStored() const = 0; 00111 00112 // Get access to the column keyword set. 00113 // <group> 00114 virtual TableRecord& rwKeywordSet() = 0; 00115 virtual TableRecord& keywordSet() = 0; 00116 // </group> 00117 00118 // Get const access to the column description. 00119 const ColumnDesc& columnDesc() const 00120 { return colDesc_p; } 00121 00122 // Get nr of rows in the column. 00123 virtual uInt nrow() const = 0; 00124 00125 // Test if the given cell contains a defined value. 00126 virtual Bool isDefined (uInt rownr) const = 0; 00127 00128 // Set the shape of the array in the given row. 00129 virtual void setShape (uInt rownr, const IPosition& shape); 00130 00131 // Set the shape and tile shape of the array in the given row. 00132 virtual void setShape (uInt rownr, const IPosition& shape, 00133 const IPosition& tileShape); 00134 00135 // Get the global #dimensions of an array (ie. for all rows). 00136 virtual uInt ndimColumn() const; 00137 00138 // Get the global shape of an array (ie. for all rows). 00139 virtual IPosition shapeColumn() const; 00140 00141 // Get the #dimensions of an array in a particular cell. 00142 virtual uInt ndim (uInt rownr) const; 00143 00144 // Get the shape of an array in a particular cell. 00145 virtual IPosition shape (uInt rownr) const; 00146 00147 // Ask the data manager if the shape of an existing array can be changed. 00148 // Default is no. 00149 virtual Bool canChangeShape() const; 00150 00151 // Ask if the data manager can handle a scalar column. 00152 // Default is never. 00153 virtual Bool canAccessScalarColumn (Bool& reask) const; 00154 00155 // Ask if the data manager can handle an array column. 00156 // Default is never. 00157 virtual Bool canAccessArrayColumn (Bool& reask) const; 00158 00159 // Ask if the data manager can handle a collection of cells in a 00160 // scalar column. Default is never. 00161 virtual Bool canAccessScalarColumnCells (Bool& reask) const; 00162 00163 // Ask if the data manager can handle a collection of cells in an 00164 // array column. Default is never. 00165 virtual Bool canAccessArrayColumnCells (Bool& reask) const; 00166 00167 // Ask if the data manager can handle a cell slice. 00168 // Default is never. 00169 virtual Bool canAccessSlice (Bool& reask) const; 00170 00171 // Ask if the data manager can handle a column slice. 00172 // Default is never. 00173 virtual Bool canAccessColumnSlice (Bool& reask) const; 00174 00175 // Initialize the rows from startRow till endRow (inclusive) 00176 // with the default value defined in the column description. 00177 virtual void initialize (uInt startRownr, uInt endRownr) = 0; 00178 00179 // Get the value from a particular cell. 00180 // This can be a scalar or an array. 00181 virtual void get (uInt rownr, void* dataPtr) const = 0; 00182 00183 // Get a slice of an N-dimensional array in a particular cell. 00184 virtual void getSlice (uInt rownr, const Slicer&, void* dataPtr) const; 00185 00186 // Get the vector of all scalar values in a column. 00187 virtual void getScalarColumn (void* dataPtr) const; 00188 00189 // Get the array of all array values in a column. 00190 // If the column contains n-dim arrays, the resulting array is (n+1)-dim. 00191 // The arrays in the column have to have the same shape in all cells. 00192 virtual void getArrayColumn (void* dataPtr) const; 00193 00194 // Get subsections from all arrays in the column. 00195 // If the column contains n-dim arrays, the resulting array is (n+1)-dim. 00196 // The arrays in the column have to have the same shape in all cells. 00197 virtual void getColumnSlice (const Slicer&, void* dataPtr) const; 00198 00199 // Get the vector of some scalar values in a column. 00200 virtual void getScalarColumnCells (const RefRows& rownrs, 00201 void* dataPtr) const; 00202 00203 // Get the array of some array values in a column. 00204 // If the column contains n-dim arrays, the resulting array is (n+1)-dim. 00205 // The arrays in the column have to have the same shape in all cells. 00206 virtual void getArrayColumnCells (const RefRows& rownrs, 00207 void* dataPtr) const; 00208 00209 // Get subsections from some arrays in the column. 00210 // If the column contains n-dim arrays, the resulting array is (n+1)-dim. 00211 // The arrays in the column have to have the same shape in all cells. 00212 virtual void getColumnSliceCells (const RefRows& rownrs, 00213 const Slicer&, void* dataPtr) const; 00214 00215 // Put the value in a particular cell. 00216 // This can be a scalar or an array. 00217 virtual void put (uInt rownr, const void* dataPtr) = 0; 00218 00219 // Put a slice of an N-dimensional array in a particular cell. 00220 virtual void putSlice (uInt rownr, const Slicer&, const void* dataPtr); 00221 00222 // Put the vector of all scalar values in the column. 00223 virtual void putScalarColumn (const void* dataPtr); 00224 00225 // Put the array of all array values in the column. 00226 // If the column contains n-dim arrays, the source array is (n+1)-dim. 00227 // The arrays in the column have to have the same shape in all cells. 00228 virtual void putArrayColumn (const void* dataPtr); 00229 00230 // Put into subsections of all table arrays in the column. 00231 // If the column contains n-dim arrays, the source array is (n+1)-dim. 00232 // The arrays in the column have to have the same shape in all cells. 00233 virtual void putColumnSlice (const Slicer&, const void* dataPtr); 00234 00235 // Get the vector of some scalar values in a column. 00236 virtual void putScalarColumnCells (const RefRows& rownrs, 00237 const void* dataPtr); 00238 00239 // Get the array of some array values in a column. 00240 // If the column contains n-dim arrays, the resulting array is (n+1)-dim. 00241 // The arrays in the column have to have the same shape in all cells. 00242 virtual void putArrayColumnCells (const RefRows& rownrs, 00243 const void* dataPtr); 00244 00245 // Put subsections of some arrays in the column. 00246 // If the column contains n-dim arrays, the source array is (n+1)-dim. 00247 // The arrays in the column have to have the same shape in all cells. 00248 virtual void putColumnSliceCells (const RefRows& rownrs, 00249 const Slicer&, const void* dataPtr); 00250 00251 // Get the value from the row and convert it to the required type. 00252 // This can only be used for scalar columns with a standard data type. 00253 // Note that an unsigned integer caanot be converted to a signed integer 00254 // with the same length. So only Int64 can handle all integer values. 00255 // <group> 00256 void getScalar (uInt rownr, Bool& value) const; 00257 void getScalar (uInt rownr, uChar& value) const; 00258 void getScalar (uInt rownr, Short& value) const; 00259 void getScalar (uInt rownr, uShort& value) const; 00260 void getScalar (uInt rownr, Int& value) const; 00261 void getScalar (uInt rownr, uInt& value) const; 00262 void getScalar (uInt rownr, Int64& value) const; 00263 void getScalar (uInt rownr, float& value) const; 00264 void getScalar (uInt rownr, double& value) const; 00265 void getScalar (uInt rownr, Complex& value) const; 00266 void getScalar (uInt rownr, DComplex& value) const; 00267 void getScalar (uInt rownr, String& value) const; 00268 void getScalar (uInt rownr, TableRecord& value) const; 00269 // </group> 00270 00271 // Get a scalar for the other data types. 00272 // The given data type id must match the data type id of this column. 00273 void getScalar (uInt rownr, void* value, const String& dataTypeId) const; 00274 00275 // Put the value into the row and convert it from the given type. 00276 // This can only be used for scalar columns with a standard data type. 00277 // <group> 00278 void putScalar (uInt rownr, const Bool& value); 00279 void putScalar (uInt rownr, const uChar& value); 00280 void putScalar (uInt rownr, const Short& value); 00281 void putScalar (uInt rownr, const uShort& value); 00282 void putScalar (uInt rownr, const Int& value); 00283 void putScalar (uInt rownr, const uInt& value); 00284 void putScalar (uInt rownr, const float& value); 00285 void putScalar (uInt rownr, const double& value); 00286 void putScalar (uInt rownr, const Complex& value); 00287 void putScalar (uInt rownr, const DComplex& value); 00288 void putScalar (uInt rownr, const String& value); 00289 void putScalar (uInt rownr, const Char* value) 00290 { putScalar (rownr, String(value)); } 00291 void putScalar (uInt rownr, const TableRecord& value); 00292 // </group> 00293 00294 // Get a pointer to the underlying column cache. 00295 virtual ColumnCache& columnCache() = 0; 00296 00297 // Set the maximum cache size (in bytes) to be used by a storage manager. 00298 virtual void setMaximumCacheSize (uInt nbytes) = 0; 00299 00300 // Add this column and its data to the Sort object. 00301 // It may allocate some storage on the heap, which will be saved 00302 // in the argument dataSave. 00303 // The function freeSortKey must be called to free this storage. 00304 // <group> 00305 virtual void makeSortKey (Sort&, ObjCompareFunc* cmpFunc, 00306 Int order, const void*& dataSave); 00307 // Do it only for the given row numbers. 00308 virtual void makeRefSortKey (Sort&, ObjCompareFunc* cmpFunc, 00309 Int order, const Vector<uInt>& rownrs, 00310 const void*& dataSave); 00311 // </group> 00312 00313 // Free storage on the heap allocated by makeSortkey(). 00314 // The pointer will be set to zero. 00315 virtual void freeSortKey (const void*& dataSave); 00316 00317 // Allocate value buffers for the table iterator. 00318 // Also get a comparison function if undefined. 00319 // The function freeIterBuf must be called to free the buffers. 00320 virtual void allocIterBuf (void*& lastVal, void*& curVal, 00321 ObjCompareFunc*& cmpFunc); 00322 00323 // Free the value buffers allocated by allocIterBuf. 00324 virtual void freeIterBuf (void*& lastVal, void*& curVal); 00325 00326 protected: 00327 const BaseColumnDesc* colDescPtr_p; 00328 //# This ColumnDesc object is created to be able to return 00329 //# a const ColumnDesc& by function columnDesc(). 00330 ColumnDesc colDesc_p; 00331 }; 00332 00333 00334 00335 00336 } //# NAMESPACE CASA - END 00337 00338 #endif