DataManager.h

Go to the documentation of this file.
00001 //# DataManager.h: Abstract base classes for a data manager
00002 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2001,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$
00027 
00028 #ifndef TABLES_DATAMANAGER_H
00029 #define TABLES_DATAMANAGER_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/ColumnCache.h>
00035 #include <casa/BasicSL/String.h>
00036 #include <casa/BasicSL/Complex.h>
00037 #include <casa/Containers/SimOrdMap.h>
00038 #include <casa/IO/ByteIO.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 //# Forward Declarations
00043 class DataManager;
00044 class DataManagerColumn;
00045 class SetupNewTable;
00046 class Table;
00047 class Record;
00048 class IPosition;
00049 class Slicer;
00050 class RefRows;
00051 template<class T> class Array;
00052 class AipsIO;
00053 
00054 
00055 // <summary>
00056 // Define the type of the static "constructor" function.
00057 // </summary>
00058 // <use visibility=local>
00059 // <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
00060 // </reviewed>
00061 
00062 // <synopsis>
00063 // Class names of data managers and pointers to their associated constructor
00064 // function are registered in a static map to be able to create the correct
00065 // data manager object from a string giving the type name of the data manager.
00066 // DataManagerCtor is the type of the constructor functions.
00067 // </synopsis>
00068 // <group name=DataManagerCtor>
00069 typedef DataManager* (*DataManagerCtor) (const String& dataManagerType,
00070                                          const Record& spec);
00071 // </group>
00072 
00073 
00074 // <summary>
00075 // Abstract base class for a data manager
00076 // </summary>
00077 
00078 // <use visibility=local>
00079 
00080 // <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
00081 // </reviewed>
00082 
00083 // <prerequisite>
00084 //# Classes you should understand before using this one.
00085 // </prerequisite>
00086 
00087 // <synopsis> 
00088 // DataManager is the abstract base class for all kind of table data managers.
00089 // There are currently 2 classes of data managers:
00090 // <ul>
00091 //  <li> Storage managers handling the storage of data. These classes
00092 //         have to be derived from DataManager.
00093 //         StManAipsIO is an example of a storage manager.
00094 //  <li> Virtual column engines handling the on-the-fly calculation
00095 //         of data, which are not stored as such. The base class for
00096 //         these is VirtualColumnEngine (which is derived from DataManager),
00097 //         from which all virtual columns engine must be derived from.
00098 // </ul>
00099 // DataManager contains some common data and defines several virtual
00100 // functions, which usually have to be implemented in the derived classes.
00101 // It also contains some helper functions for the derived classes
00102 // (like fileName().
00103 //
00104 // The actual handling of a column by the data manager is defined in
00105 // the abstract base class
00106 // <linkto class="DataManagerColumn:description">DataManagerColumn</linkto>.
00107 // Each data manager must
00108 // have an associated class (derived from DataManagerColumn) to
00109 // handle the columns.
00110 //
00111 // There is a protocol defined how a data manager is created and
00112 // initialized. For a new table it is:
00113 // <ul>
00114 //  <li>
00115 //   The user creates data managers and binds them to columns. For example:
00116 //   <srcblock>
00117 //   SetupNewTable newtab("name.data", Table::New);  // set up new table
00118 //   StManAipsIO stman;                       // define storage manager
00119 //   newtab.bindColumn ("column1", stman);    // bind column to st.man.
00120 //   newtab.bindColumn ("column2", stman);    // bind column to st.man.
00121 //   Table tab(newtab);                       // actually create table
00122 //   </srcblock>
00123 //   When the given data manager object is used for the first time in a bind
00124 //   function, a copy of the object is made using the clone function.
00125 //   Thus in the above example column1 and column2 share the same data
00126 //   manager; only at the first bind the stman object is cloned.
00127 //   Columns not explicitly bound to a data manager get implicitly bound
00128 //   to the default data manager (as defined in the column description)
00129 //   by the Table constructor (as used in line 5).
00130 //  <li>
00131 //   After binding the unbound columns, the PlainTable constructor sets up
00132 //   the data managers. For each column it asks the data manager to
00133 //   construct a DataManagerColumn object (in fact, an object of a class
00134 //   derived from DataManagerColumn). This is done by the functions
00135 //   createScalarColumn, createIndArrColumn and createDirArrColumn.
00136 //   For each data manager the create function is called. This allows
00137 //   them to initialize themselves and/or to call an initialization
00138 //   function in their column objects.
00139 //   This is, for instance, used by the storage managers to create files.
00140 //   Thereafter the prepare function is called to allow the data managers
00141 //   to do further initialization possibly requiring information from
00142 //   other columns.
00143 //  <li>
00144 //   When the table gets written (by the PlainTable destructor),
00145 //   the flush function is called for each data manager. This allows
00146 //   the data manager or their column objects to write or flush their data.
00147 //   The table system takes care of storing the information required
00148 //   to reconstruct the data managers. It uses the function dataManagerType
00149 //   to store the (unique) type name of the data manager class.
00150 //  <li>
00151 //   Finally each data manager object gets deleted. Their destructors
00152 //   must delete their column objects (if any and if needed).
00153 // </ul>
00154 // For an existing table the procedure is slightly different:
00155 // <ul>
00156 //  <li>
00157 //   The statement
00158 //   <br><src> Table tab("name.data"); </src>
00159 //   will create a table object for an existing table. This has the effect
00160 //   that the given table file will be read to reconstruct the Table object
00161 //   and the data managers.
00162 //  <li>
00163 //   The stored data manager class names are used to reconstruct
00164 //   the data managers. This uses the static registration map, which
00165 //   maps the class name to a static class constructor function (usually
00166 //   called makeObject). This requires that the type name and constructor
00167 //   for each possible data manager are registered before the table
00168 //   is opened. The DataManager function registerAllCtor (implemented
00169 //   in DataManReg.cc) is called before a table is opened, so registration
00170 //   of data managers should, in principle, be done there.
00171 //  <li>
00172 //   Each table column is bound to the correct data manager. The sequence
00173 //   number stored in the table file is used for that purpose.
00174 //  <li>
00175 //   The DataManager createXXXColumn functions are called for each table
00176 //   column to let the data manager construct a data manager column object.
00177 //  <li>
00178 //   For each data manager the open function is called to allow it and
00179 //   its column objects to read back the information stored in the
00180 //   flush function.
00181 //   Thereafter the prepare function is called for each data manager
00182 //   to allow it to initialize some variables.
00183 //   The reason that open and prepare are separated is that in order to
00184 //   initialize variables it may be required to use other columns.
00185 //   So it may be needed that all columns are read back before they
00186 //   get initialized.
00187 //  <li>
00188 //   Similar to a new table the flush functions gets called when the
00189 //   table gets written. Destruction is also the same as sketched
00190 //   for new tables.
00191 // </ul>
00192 // </synopsis> 
00193 
00194 // <motivation>
00195 // An abstract base class is needed to support data managers and
00196 // virtual column engines in the table system in a transparant way.
00197 // </motivation>
00198 
00199 // <todo asof="$DATE:$">
00200 //# A List of bugs, limitations, extensions or planned refinements.
00201 //  <li> Handle unregistered data managers in a better way.
00202 //         Instead of throwing an exception a subprocess could be
00203 //         started which represents the data manager.
00204 // </todo>
00205 
00206 
00207 class DataManager
00208 {
00209 friend class SetupNewTable;
00210 friend class ColumnSet;
00211 
00212 public:
00213 
00214     // Default constructor.
00215     DataManager();
00216 
00217     virtual ~DataManager();
00218 
00219     // Make a clone of the derived object.
00220     virtual DataManager* clone() const = 0;
00221 
00222     // Return the name of the data manager. This is the name of this
00223     // instantiation of the data manager, thus not its type name.
00224     // By default it returns an empty string.
00225     virtual String dataManagerName() const;
00226 
00227     // Return the type name of the data manager (in fact its class name).
00228     // It has to be a unique name, thus if the class is templated
00229     // the template parameter has to be part of the name.
00230     // This is used by the open/flush mechanism to be able to reconstruct
00231     // the correct data manager.
00232     virtual String dataManagerType() const = 0;
00233 
00234     // Record a record containing data manager specifications.
00235     // The default impementation returns an empty record.
00236     virtual Record dataManagerSpec() const;
00237 
00238     // Is the data manager a storage manager?
00239     // The default is yes.
00240     virtual Bool isStorageManager() const;
00241 
00242     // Tell if the data manager wants to reallocate the data manager
00243     // column objects.
00244     // This is used by the tiling storage manager.
00245     // By default it returns False.
00246     virtual Bool canReallocateColumns() const;
00247 
00248     // Reallocate the column object if it is part of this data manager.
00249     // It returns a pointer to the new column object.
00250     // This function is used by the tiling storage manager.
00251     // By default it does nothing and returns the input pointer.
00252     virtual DataManagerColumn* reallocateColumn (DataManagerColumn* column);
00253     
00254     // Get the (unique) sequence nr of this data manager.
00255     uInt sequenceNr() const
00256         { return seqnr_p; }
00257 
00258     // Get the nr of columns in this data manager (can be zero).
00259     uInt ncolumn() const
00260         { return nrcol_p; }
00261 
00262     // Have the data to be stored in big or little endian canonical format?
00263     Bool asBigEndian() const
00264       { return asBigEndian_p; }
00265 
00266     // Compose a keyword name from the given keyword appended with the
00267     // sequence number (e.g. key_0).
00268     // This makes the keyword name unique if multiple data managers
00269     // are used with the same type.
00270     String keywordName (const String& keyword) const;
00271 
00272     // Compose a unique filename from the table name and sequence number.
00273     String fileName() const;
00274 
00275     // Get the AipsIO option of the underlying file.
00276     ByteIO::OpenOption fileOption() const;
00277 
00278     // Get the table this object is associated with.
00279     Table& table() const
00280         { return *table_p; }
00281 
00282     // Reopen the data manager for read/write access.
00283     // By default it is assumed that a reopen for read/write does
00284     // not have to do anything.
00285     virtual void reopenRW();
00286 
00287     // Does the data manager allow to add rows? (default no)
00288     virtual Bool canAddRow() const;
00289 
00290     // Does the data manager allow to delete rows? (default no)
00291     virtual Bool canRemoveRow() const;
00292 
00293     // Does the data manager allow to add columns? (default no)
00294     virtual Bool canAddColumn() const;
00295 
00296     // Does the data manager allow to delete columns? (default no)
00297     virtual Bool canRemoveColumn() const;
00298 
00299     // Set the maximum cache size (in bytes) to be used by a storage manager.
00300     // The default implementation does nothing.
00301     virtual void setMaximumCacheSize (uInt nbytes);
00302     
00303     // Create a column in the data manager on behalf of a table column.
00304     // It calls makeXColumn and checks the data type.
00305     // <group>
00306     // Create a scalar column.
00307     // The <src>dataTypeId</src> argument is gives the id (i.e. name)
00308     // of the data type of the column. It is only used for virtual
00309     // columns of a non-standard data type to be able to check if
00310     // the correctness of the column data type.
00311     // <br>Storage managers only handle standard data types and
00312     // can readily ignore this argument.
00313     DataManagerColumn* createScalarColumn (const String& columnName,
00314                                            int dataType,
00315                                            const String& dataTypeId);
00316     // Create a direct array column.
00317     DataManagerColumn* createDirArrColumn (const String& columnName,
00318                                            int dataType,
00319                                            const String& dataTypeId);
00320     // Create an indirect array column.
00321     DataManagerColumn* createIndArrColumn (const String& columnName,
00322                                            int dataType,
00323                                            const String& dataTypeId);
00324     // </group>
00325 
00326     // The data manager will be deleted (because all its columns are
00327     // requested to be deleted).
00328     // So clean up the things needed (e.g. delete files).
00329     virtual void deleteManager() = 0;
00330 
00331 
00332 protected:
00333     // Decrement number of columns (in case a column is deleted).
00334     void decrementNcolumn()
00335         { nrcol_p--; }
00336 
00337     // Tell the data manager if big or little endian format is needed.
00338     void setEndian (Bool bigEndian)
00339       { asBigEndian_p = bigEndian; }
00340 
00341     // Throw an exception in case data type is TpOther, because the
00342     // storage managers (and maybe other data managers) do not support
00343     // such columns.
00344     void throwDataTypeOther (const String& columnName, int dataType) const;
00345 
00346 
00347 private:
00348     uInt         nrcol_p;            //# #columns in this st.man.
00349     uInt         seqnr_p;            //# Unique nr of this st.man. in a Table
00350     Bool         asBigEndian_p;      //# store data in big or little endian
00351     Table*       table_p;            //# Table this data manager belongs to
00352     mutable DataManager* clone_p;    //# Pointer to clone (used by SetupNewTab)
00353 
00354 
00355     // The copy constructor cannot be used for this base class.
00356     // The clone function should be used instead.
00357     // The private declaration of this constructor makes it unusable.
00358     DataManager (const DataManager&);
00359 
00360     // Assignment cannot be used for this base class.
00361     // The private declaration of this operator makes it unusable.
00362     DataManager& operator= (const DataManager&);
00363 
00364     // Create a column in the data manager on behalf of a table column.
00365     //# Should be private, but has to be public because friend
00366     //# declaration gave internal CFront error.
00367     // <group>
00368     // Create a scalar column.
00369     virtual DataManagerColumn* makeScalarColumn (const String& columnName,
00370                                                  int dataType,
00371                                                  const String& dataTypeId) = 0;
00372     // Create a direct array column.
00373     virtual DataManagerColumn* makeDirArrColumn (const String& columnName,
00374                                                  int dataType,
00375                                                  const String& dataTypeId) = 0;
00376     // Create an indirect array column.
00377     virtual DataManagerColumn* makeIndArrColumn (const String& columnName,
00378                                                  int dataType,
00379                                                  const String& dataTypeId) = 0;
00380     // </group>
00381 
00382     // Check if the data type of the created data manager column is correct.
00383     void checkDataType (const DataManagerColumn* colPtr,
00384                         const String& columnName,
00385                         int dataType, const String& dataTypeId) const;
00386 
00387     // Add rows to all columns.
00388     // The default implementation throws a "not possible" exception.
00389     virtual void addRow (uInt nrrow);
00390 
00391     // Delete a row from all columns.
00392     // The default implementation throws a "not possible" exception.
00393     virtual void removeRow (uInt rownr);
00394 
00395     // Add a column.
00396     // The default implementation throws a "not possible" exception.
00397     virtual void addColumn (DataManagerColumn*);
00398 
00399     // Delete a column.
00400     // The default implementation throws a "not possible" exception.
00401     virtual void removeColumn (DataManagerColumn*);
00402 
00403     // Set the sequence number of this data manager.
00404     void setSeqnr (uInt nr)
00405         { seqnr_p = nr; }
00406 
00407     // Link the data manager to the Table object.
00408     void linkToTable (Table& tab);
00409 
00410     // Flush and optionally fsync the data.
00411     // The AipsIO stream represents the main table file and can be
00412     // used by virtual column engines to store SMALL amounts of data.
00413     // It returns a True status if it had to flush (i.e. if data have changed).
00414     virtual Bool flush (AipsIO& ios, Bool fsync) = 0;
00415 
00416     // Let the data manager initialize itself for a new table.
00417     virtual void create (uInt nrrow) = 0;
00418 
00419     // Let the data manager initialize itself for an existing table.
00420     // The AipsIO stream represents the main table file and must be
00421     // used by virtual column engines to retrieve the data stored
00422     // in the flush function.
00423     virtual void open (uInt nrrow, AipsIO& ios) = 0;
00424 
00425     // Resync the data by rereading cached data from the file.
00426     // This is called when a lock is acquired on the file and it appears 
00427     // that data in this data manager has been changed by another process.
00428     virtual void resync (uInt nrrow) = 0;
00429 
00430     // Let the data manager initialize itself further.
00431     // Prepare is called after create/open has been called for all
00432     // columns. In this way one can be sure that referenced columns
00433     // are read back and partly initialized.
00434     // The default implementation does nothing.
00435     virtual void prepare();
00436 
00437     // Declare the mapping of the data manager type name to a static
00438     // "makeObject" function.
00439     static SimpleOrderedMap<String,DataManagerCtor> registerMap;
00440 
00441 public:
00442     // Register a mapping of a data manager type to its static "constructor".
00443     static void registerCtor (const String& dataManagerType,
00444                               DataManagerCtor fn);
00445 
00446     // Get the "constructor" of a data manager.
00447     static DataManagerCtor getCtor (const String& dataManagerType);
00448 
00449     // Test if the data manager is registered.
00450     static Bool isRegistered (const String& dataManagerType);
00451 
00452     // Register all mappings.
00453     // This will be a bunch of register calls. It is implemented in
00454     // DataManReg.cc. In this way it is easier to add new functions
00455     // to it (or maybe eventually automate that process).
00456     static void registerAllCtor();
00457 
00458     // Serve as default function for registerMap, which catches all
00459     // unknown data manager types.
00460     // <thrown>
00461     //   <li> TableUnknownDataManager
00462     // </thrown>
00463     static DataManager* unknownDataManager (const String& dataManagerType,
00464                                             const Record& spec);
00465 
00466     // Has the object already been cloned?
00467     DataManager* getClone() const
00468         { return clone_p; }
00469 
00470     // Set the pointer to the clone.
00471     void setClone (DataManager* clone) const
00472         { clone_p = clone; }
00473 };
00474 
00475 
00476 
00477 
00478 // <summary>
00479 // Abstract base class for a column in a data manager
00480 // </summary>
00481 
00482 // <use visibility=local>
00483 
00484 // <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
00485 // </reviewed>
00486 
00487 // <prerequisite>
00488 //# Classes you should understand before using this one.
00489 //   <li> DataManager
00490 // </prerequisite>
00491 
00492 // <etymology>
00493 // DataManagerColumn handles a column for a data manager.
00494 // </etymology>
00495 
00496 // <synopsis> 
00497 // DataManagerColumn is the abstract base class to handle a column in
00498 // a data manager. Each data manager class must have one or more associated
00499 // classes derived from DataManagerColumn to handle the columns.
00500 // For example, storage manager StManAipsIO has columns classes
00501 // StManColumnAipsIO, StManColumnArrayAipsIO and StManColumnIndArrayAipsIO
00502 // to handle scalars, direct arrays and indirect arrays, resp..
00503 // However, using multiple inheritance it is possible that the derived
00504 // DataManager and DataManagerColumn classes are the same. This is used
00505 // in class ScaledArrayEngine<S,T> which represents both the data manager
00506 // and its column class. It can do that, because the virtual column engine
00507 // <linkto class="ScaledArrayEngine:description">ScaledArrayEngine</linkto>
00508 // can handle only one column.
00509 //
00510 // In the synopsis of class DataManager it is described how the (derived)
00511 // DataManagerColumn objects gets created and deleted.
00512 // 
00513 // DataManagerColumn defines various virtual functions to get or put (slices)
00514 // of data in a column. These functions are called by the table column
00515 // classes ScalarColumnData and ArrayColumnData.
00516 // It does not define functions create, open, flush and prepare like
00517 // those defined in DataManager. It is left to the derived classes to
00518 // define those as needed and to interact properly with their
00519 // data manager object.
00520 // </synopsis> 
00521 
00522 // <motivation>
00523 // An abstract base class is needed to support multiple data
00524 // managers in the table system
00525 // </motivation>
00526 
00527 // <todo asof="$DATE:$">
00528 //# A List of bugs, limitations, extensions or planned refinements.
00529 // </todo>
00530 
00531 
00532 class DataManagerColumn
00533 {
00534 public:
00535 
00536     // Create a column.
00537     DataManagerColumn()
00538         : isFixedShape_p(False) {;}
00539 
00540     // Frees up the storage.
00541     virtual ~DataManagerColumn();
00542 
00543     // Set the isFixedShape flag.
00544     void setIsFixedShape (Bool isFixedShape)
00545         { isFixedShape_p = isFixedShape; }
00546 
00547     // Is this a fixed shape column?
00548     Bool isFixedShape() const
00549         { return isFixedShape_p; }
00550 
00551     // Get the data type of the column as defined in DataType.h.
00552     virtual int dataType() const = 0;
00553 
00554     // Get the data type id of the column for dataType==TpOther.
00555     // The default implementation returns an emptry string.
00556     // This function is required for virtual column engines handling
00557     // non-standard data types. It is used to check the data type.
00558     virtual String dataTypeId() const;
00559 
00560     // Test if data can be put into this column.
00561     // This does not test if the data file is writable, only if
00562     // it is in principle allowed to store data into the column.
00563     // (It may not be allowed for virtual columns).
00564     // The default is True.
00565     virtual Bool isWritable() const;
00566 
00567     // Set the maximum length of the value (can be used for strings).
00568     // By default the maximum length is ignored.
00569     virtual void setMaxLength (uInt maxLength);
00570 
00571     // Set the shape of all (fixed-shaped) arrays in the column.
00572     // Effectively it is the same as setShapeColumn, but it also sets
00573     // the isFixedShape_p flag.
00574     void setFixedShapeColumn (const IPosition& shape)
00575         { setShapeColumn (shape); isFixedShape_p = True; }
00576 
00577     // Set the shape of an (variable-shaped) array in the given row.
00578     // By default it throws a "not possible" exception.
00579     virtual void setShape (uInt rownr, const IPosition& shape);
00580 
00581     // Set the shape and tile shape of an (variable-shaped) array
00582     // in the given row.
00583     // By default it ignores the tile shape (thus only sets the shape).
00584     virtual void setShapeTiled (uInt rownr, const IPosition& shape,
00585                                 const IPosition& tileShape);
00586 
00587     // Is the value shape defined in the given row?
00588     // By default it returns True.
00589     virtual Bool isShapeDefined (uInt rownr);
00590 
00591     // Get the dimensionality of the item in the given row.
00592     // By default it returns shape(rownr).nelements().
00593     virtual uInt ndim (uInt rownr);
00594 
00595     // Get the shape of the item in the given row.
00596     // By default it returns a zero-length IPosition (for a scalar value).
00597     virtual IPosition shape (uInt rownr);
00598 
00599     // Can the data manager handle chaging the shape of an existing array?
00600     // Default is no.
00601     virtual Bool canChangeShape() const;
00602 
00603     // Can the column data manager handle access to a scalar column?
00604     // If not, the caller should access the column by looping through
00605     // all cells in the column.
00606     // Default is no.
00607     // <br>
00608     // The returned reask switch determines if the information is
00609     // permanent. False indicates it is permanent; True indicates it
00610     // will be reasked for the next get/putColumn.
00611     // By default reask is set to False.
00612     virtual Bool canAccessScalarColumn (Bool& reask) const;
00613 
00614     // Can the column data manager handle access to a clooection of cells
00615     // in a scalar column?
00616     // If not, the caller should access the column cells by looping through
00617     // the cells in the column.
00618     // Default is no.
00619     // <br>
00620     // The returned reask switch determines if the information is
00621     // permanent. False indicates it is permanent; True indicates it
00622     // will be reasked for the next get/putColumn.
00623     // By default reask is set to False.
00624     virtual Bool canAccessScalarColumnCells (Bool& reask) const;
00625 
00626     // Can the column data manager handle access to a scalar column?
00627     // If not, the caller should access the column by looping through
00628     // all cells in the column.
00629     // Default is no.
00630     // <br>
00631     // The returned reask switch determines if the information is
00632     // permanent. False indicates it is permanent; True indicates it
00633     // will be reasked for the next get/putColumn.
00634     // By default reask is set to False.
00635     virtual Bool canAccessArrayColumn (Bool& reask) const;
00636 
00637     // Can the column data manager handle access to a collection of cells
00638     // in an array column?
00639     // If not, the caller should access the column cells by looping through
00640     // the cells in the column.
00641     // Default is no.
00642     // <br>
00643     // The returned reask switch determines if the information is
00644     // permanent. False indicates it is permanent; True indicates it
00645     // will be reasked for the next get/putColumn.
00646     // By default reask is set to False.
00647     virtual Bool canAccessArrayColumnCells (Bool& reask) const;
00648 
00649     // Can the column data manager handle access to a cell slice?
00650     // If not, the caller should do slicing itself (by accessing the
00651     // entire array and slicing it).
00652     // Default is no.
00653     // <br>
00654     // The returned reask switch determines if the information is
00655     // permanent. False indicates it is permanent; True indicates it
00656     // will be reasked for the next get/putColumn.
00657     // By default reask is set to False.
00658     virtual Bool canAccessSlice (Bool& reask) const;
00659 
00660     // Can the column data manager handle access to a column slice?
00661     // If not, the caller should access the column slice by looping through
00662     // all cell slices in the column.
00663     // Default is no.
00664     // <br>
00665     // The returned reask switch determines if the information is
00666     // permanent. False indicates it is permanent; True indicates it
00667     // will be reasked for the next get/putColumn.
00668     // By default reask is set to False.
00669     virtual Bool canAccessColumnSlice (Bool& reask) const;
00670 
00671     // Get access to the ColumnCache object.
00672     // <group>
00673     ColumnCache& columnCache()
00674         { return colCache_p; }
00675     const ColumnCache* columnCachePtr() const
00676         { return &colCache_p; }
00677     // </group>
00678 
00679     // Get the scalar value in the given row.
00680     // These functions are non-virtual and are converted to their
00681     // virtual getV equivalent to achieve that a derived templated class
00682     //(like VirtualScalarColumn) does not have to declare and implement
00683     // all these functions.
00684     // The compiler complains about hiding virtual functions if you do not
00685     // declare all virtual functions with the same name in a derived class.
00686     // <group>
00687     void get (uInt rownr, Bool* dataPtr)
00688         { getBoolV (rownr, dataPtr); }
00689     void get (uInt rownr, uChar* dataPtr)
00690         { getuCharV (rownr, dataPtr); }
00691     void get (uInt rownr, Short* dataPtr)
00692         { getShortV (rownr, dataPtr); }
00693     void get (uInt rownr, uShort* dataPtr)
00694         { getuShortV (rownr, dataPtr); }
00695     void get (uInt rownr, Int* dataPtr)
00696         { getIntV (rownr, dataPtr); }
00697     void get (uInt rownr, uInt* dataPtr)
00698         { getuIntV (rownr, dataPtr); }
00699     void get (uInt rownr, float* dataPtr)
00700         { getfloatV (rownr, dataPtr); } 
00701    void get (uInt rownr, double* dataPtr)
00702         { getdoubleV (rownr, dataPtr); }
00703     void get (uInt rownr, Complex* dataPtr)
00704         { getComplexV (rownr, dataPtr); }
00705     void get (uInt rownr, DComplex* dataPtr)
00706         { getDComplexV (rownr, dataPtr); }
00707     void get (uInt rownr, String* dataPtr)
00708         { getStringV (rownr, dataPtr); }
00709     // This function is the get for all non-standard data types.
00710     void get (uInt rownr, void* dataPtr)
00711         { getOtherV (rownr, dataPtr); }
00712     // </group>
00713 
00714     // Put the scalar value into the given row.
00715     // These functions are non-virtual and are converted to their
00716     // virtual putV equivalent to achieve that a derived templated class
00717     //(like VirtualScalarColumn) does not have to declare and implement
00718     // all these functions.
00719     // The compiler complains about hiding virtual functions if you do not
00720     // declare all virtual functions with the same name in a derived class.
00721     // <group>
00722     void put (uInt rownr, const Bool* dataPtr)
00723         { putBoolV (rownr, dataPtr); }
00724     void put (uInt rownr, const uChar* dataPtr)
00725         { putuCharV (rownr, dataPtr); }
00726     void put (uInt rownr, const Short* dataPtr)
00727         { putShortV (rownr, dataPtr); }
00728     void put (uInt rownr, const uShort* dataPtr)
00729         { putuShortV (rownr, dataPtr); }
00730     void put (uInt rownr, const Int* dataPtr)
00731         { putIntV (rownr, dataPtr); }
00732     void put (uInt rownr, const uInt* dataPtr)
00733         { putuIntV (rownr, dataPtr); }
00734     void put (uInt rownr, const float* dataPtr)
00735         { putfloatV (rownr, dataPtr); }
00736     void put (uInt rownr, const double* dataPtr)
00737         { putdoubleV (rownr, dataPtr); }
00738     void put (uInt rownr, const Complex* dataPtr)
00739         { putComplexV (rownr, dataPtr); }
00740     void put (uInt rownr, const DComplex* dataPtr)
00741         { putDComplexV (rownr, dataPtr); }
00742     void put (uInt rownr, const String* dataPtr)
00743         { putStringV (rownr, dataPtr); }
00744     // This function is the put for all non-standard data types.
00745     void put (uInt rownr, const void* dataPtr)
00746         { putOtherV (rownr, dataPtr); }
00747     // </group>
00748 
00749     // Get all scalar values in the column.
00750     // The argument dataPtr is in fact a Vector<T>*, but a void*
00751     // is needed to be generic.
00752     // The vector pointed to by dataPtr has to have the correct length
00753     // (which is guaranteed by the ScalarColumn getColumn function).
00754     // The default implementation throws an "invalid operation" exception.
00755     virtual void getScalarColumnV (void* dataPtr);
00756 
00757     // Put all scalar values in the column.
00758     // The argument dataPtr is in fact a const Vector<T>*, but a const void*
00759     // is needed to be generic.
00760     // The vector pointed to by dataPtr has to have the correct length
00761     // (which is guaranteed by the ScalarColumn putColumn function).
00762     // The default implementation throws an "invalid operation" exception.
00763     virtual void putScalarColumnV (const void* dataPtr);
00764 
00765     // Get some scalar values in the column.
00766     // The argument dataPtr is in fact a Vector<T>*, but a void*
00767     // is needed to be generic.
00768     // The vector pointed to by dataPtr has to have the correct length
00769     // (which is guaranteed by the ScalarColumn getColumn function).
00770     // The default implementation throws an "invalid operation" exception.
00771     virtual void getScalarColumnCellsV (const RefRows& rownrs,
00772                                         void* dataPtr);
00773 
00774     // Put some scalar values in the column.
00775     // The argument dataPtr is in fact a const Vector<T>*, but a const void*
00776     // is needed to be generic.
00777     // The vector pointed to by dataPtr has to have the correct length
00778     // (which is guaranteed by the ScalarColumn getColumn function).
00779     // The default implementation throws an "invalid operation" exception.
00780     virtual void putScalarColumnCellsV (const RefRows& rownrs,
00781                                         const void* dataPtr);
00782 
00783     // Get scalars from the given row on with a maximum of nrmax values.
00784     // It returns the actual number of values got.
00785     // This can be used to get an entire column of scalars or to get
00786     // a part of a column (for a cache for example).
00787     // The argument dataPtr is in fact a T*, but a void*
00788     // is needed to be generic.
00789     // The default implementation throws an "invalid operation" exception.
00790     virtual uInt getBlockV (uInt rownr, uInt nrmax, void* dataPtr);
00791 
00792     // Put nrmax scalars from the given row on.
00793     // It returns the actual number of values put.
00794     // This can be used to put an entire column of scalars or to put
00795     // a part of a column (for a cache for example).
00796     // The argument dataPtr is in fact a const T*, but a const void*
00797     // is needed to be generic.
00798     // The default implementation throws an "invalid operation" exception.
00799     virtual void putBlockV (uInt rownr, uInt nrmax, const void* dataPtr);
00800 
00801     // Get the array value in the given row.
00802     // The argument dataPtr is in fact an Array<T>*, but a void*
00803     // is needed to be generic.
00804     // The array pointed to by dataPtr has to have the correct shape
00805     // (which is guaranteed by the ArrayColumn get function).
00806     // The default implementation throws an "invalid operation" exception.
00807     virtual void getArrayV (uInt rownr, void* dataPtr);
00808 
00809     // Put the array value into the given row.
00810     // The argument dataPtr is in fact a const Array<T>*, but a const void*
00811     // is needed to be generic.
00812     // The array pointed to by dataPtr has to have the correct shape
00813     // (which is guaranteed by the ArrayColumn put function).
00814     // The default implementation throws an "invalid operation" exception.
00815     virtual void putArrayV (uInt rownr, const void* dataPtr);
00816 
00817     // Get all array values in the column.
00818     // The argument dataPtr is in fact an Array<T>*, but a void*
00819     // is needed to be generic.
00820     // The vector pointed to by dataPtr has to have the correct length
00821     // (which is guaranteed by the ArrayColumn getColumn function).
00822     // The default implementation throws an "invalid operation" exception.
00823     virtual void getArrayColumnV (void* dataPtr);
00824 
00825     // Put all array values in the column.
00826     // The argument dataPtr is in fact a const Array<T>*, but a const void*
00827     // is needed to be generic.
00828     // The vector pointed to by dataPtr has to have the correct length
00829     // (which is guaranteed by the ArrayColumn putColumn function).
00830     // The default implementation throws an "invalid operation" exception.
00831     virtual void putArrayColumnV (const void* dataPtr);
00832 
00833     // Get some array values in the column.
00834     // The argument dataPtr is in fact an Array<T>*, but a void*
00835     // is needed to be generic.
00836     // The vector pointed to by dataPtr has to have the correct length
00837     // (which is guaranteed by the ArrayColumn getColumn function).
00838     // The default implementation throws an "invalid operation" exception.
00839     virtual void getArrayColumnCellsV (const RefRows& rownrs,
00840                                        void* dataPtr);
00841 
00842     // Put some array values in the column.
00843     // The argument dataPtr is in fact an const Array<T>*, but a const void*
00844     // is needed to be generic.
00845     // The vector pointed to by dataPtr has to have the correct length
00846     // (which is guaranteed by the ArrayColumn getColumn function).
00847     // The default implementation throws an "invalid operation" exception.
00848     virtual void putArrayColumnCellsV (const RefRows& rownrs,
00849                                        const void* dataPtr);
00850 
00851     // Get a section of the array in the given row.
00852     // The argument dataPtr is in fact an Array<T>*, but a void*
00853     // is needed to be generic.
00854     // The array pointed to by dataPtr has to have the correct shape
00855     // (which is guaranteed by the ArrayColumn getSlice function).
00856     // The default implementation throws an "invalid operation" exception.
00857     virtual void getSliceV (uInt rownr, const Slicer& slicer, void* dataPtr);
00858 
00859     // Put into a section of the array in the given row.
00860     // The argument dataPtr is in fact a const Array<T>*, but a const void*
00861     // is needed to be generic.
00862     // The array pointed to by dataPtr has to have the correct shape
00863     // (which is guaranteed by the ArrayColumn putSlice function).
00864     // The default implementation throws an "invalid operation" exception.
00865     virtual void putSliceV (uInt rownr, const Slicer& slicer,
00866                             const void* dataPtr);
00867 
00868     // Get a section of all arrays in the column.
00869     // The argument dataPtr is in fact an Array<T>*, but a void*
00870     // is needed to be generic.
00871     // The array pointed to by dataPtr has to have the correct shape
00872     // (which is guaranteed by the ArrayColumn getColumn function).
00873     // The default implementation throws an "invalid operation" exception.
00874     virtual void getColumnSliceV (const Slicer& slicer, void* dataPtr);
00875 
00876     // Put into a section of all arrays in the column.
00877     // The argument dataPtr is in fact a const Array<T>*, but a const void*
00878     // is needed to be generic.
00879     // The array pointed to by dataPtr has to have the correct shape
00880     // (which is guaranteed by the ArrayColumn putColumn function).
00881     // The default implementation throws an "invalid operation" exception.
00882     virtual void putColumnSliceV (const Slicer& slicer, const void* dataPtr);
00883 
00884     // Get a section of some arrays in the column.
00885     // The argument dataPtr is in fact an Array<T>*, but a void*
00886     // is needed to be generic.
00887     // The array pointed to by dataPtr has to have the correct shape
00888     // (which is guaranteed by the ArrayColumn getColumn function).
00889     // The default implementation throws an "invalid operation" exception.
00890     virtual void getColumnSliceCellsV (const RefRows& rownrs,
00891                                        const Slicer& slicer, void* dataPtr);
00892 
00893     // Put into a section of some arrays in the column.
00894     // The argument dataPtr is in fact a const Array<T>*, but a const void*
00895     // is needed to be generic.
00896     // The array pointed to by dataPtr has to have the correct shape
00897     // (which is guaranteed by the ArrayColumn putColumn function).
00898     // The default implementation throws an "invalid operation" exception.
00899     virtual void putColumnSliceCellsV (const RefRows& rownrs,
00900                                        const Slicer& slicer,
00901                                        const void* dataPtr);
00902 
00903     // Throw an "invalid operation" exception for the default
00904     // implementation of get.
00905     void throwGet() const;
00906 
00907     // Throw an "invalid operation" exception for the default
00908     // implementation of put.
00909     void throwPut() const;
00910 
00911 protected:
00912     // Get the scalar value in the given row.
00913     // The default implementation throws an "invalid operation" exception.
00914     // <group>
00915     virtual void getBoolV     (uInt rownr, Bool* dataPtr);
00916     virtual void getuCharV    (uInt rownr, uChar* dataPtr);
00917     virtual void getShortV    (uInt rownr, Short* dataPtr);
00918     virtual void getuShortV   (uInt rownr, uShort* dataPtr);
00919     virtual void getIntV      (uInt rownr, Int* dataPtr);
00920     virtual void getuIntV     (uInt rownr, uInt* dataPtr);
00921     virtual void getfloatV    (uInt rownr, float* dataPtr);
00922     virtual void getdoubleV   (uInt rownr, double* dataPtr);
00923     virtual void getComplexV  (uInt rownr, Complex* dataPtr);
00924     virtual void getDComplexV (uInt rownr, DComplex* dataPtr);
00925     virtual void getStringV   (uInt rownr, String* dataPtr);
00926     // This function is the get for all non-standard data types.
00927     virtual void getOtherV    (uInt rownr, void* dataPtr);
00928     // </group>
00929 
00930     // Put the scalar value into the given row.
00931     // The default implementation throws an "invalid operation" exception.
00932     // <group>
00933     virtual void putBoolV     (uInt rownr, const Bool* dataPtr);
00934     virtual void putuCharV    (uInt rownr, const uChar* dataPtr);
00935     virtual void putShortV    (uInt rownr, const Short* dataPtr);
00936     virtual void putuShortV   (uInt rownr, const uShort* dataPtr);
00937     virtual void putIntV      (uInt rownr, const Int* dataPtr);
00938     virtual void putuIntV     (uInt rownr, const uInt* dataPtr);
00939     virtual void putfloatV    (uInt rownr, const float* dataPtr);
00940     virtual void putdoubleV   (uInt rownr, const double* dataPtr);
00941     virtual void putComplexV  (uInt rownr, const Complex* dataPtr);
00942     virtual void putDComplexV (uInt rownr, const DComplex* dataPtr);
00943     virtual void putStringV   (uInt rownr, const String* dataPtr);
00944     // This function is the put for all non-standard data types.
00945     virtual void putOtherV    (uInt rownr, const void* dataPtr);
00946     // </group>
00947 
00948 private:
00949     Bool        isFixedShape_p;
00950     ColumnCache colCache_p;
00951 
00952     // Set the shape of all (fixed-shaped) arrays in the column.
00953     // By default it throws a "not possible" exception.
00954     virtual void setShapeColumn (const IPosition& shape);
00955 
00956     // The copy constructor cannot be used for this base class.
00957     // The private declaration of this constructor makes it unusable.
00958     DataManagerColumn (const DataManagerColumn&);
00959 
00960     // Assignment cannot be used for this base class.
00961     // The private declaration of this operator makes it unusable.
00962     DataManagerColumn& operator= (const DataManagerColumn&);
00963 };
00964 
00965 
00966 
00967 } //# NAMESPACE CASA - END
00968 
00969 #endif

Generated on Mon Sep 1 22:36:18 2008 for NRAOCASA by  doxygen 1.5.1