VirtColEng.h

Go to the documentation of this file.
00001 //# VirtColEng.h: Abstract base class for virtual column handling
00002 //# Copyright (C) 1994,1995,1996,1997,1999,2001
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_VIRTCOLENG_H
00029 #define TABLES_VIRTCOLENG_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <tables/Tables/DataManager.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward Declarations
00038 
00039 
00040 // <summary>
00041 // Abstract base class for virtual column handling
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> DataManager
00052 //   <li> Table
00053 // </prerequisite>
00054 
00055 // <etymology>
00056 // VirtualColumnEngine is the abstract data manager class for specialized
00057 // classes (engines) handling a group of virtual columns.
00058 // </etymology>
00059 
00060 // <synopsis> 
00061 // VirtualColumnEngine is the data manager for classes handling
00062 // a group of virtual columns in tables. It is an abstract base class
00063 // for the specialized virtual column engines.
00064 // Each virtual column as such is represented by a class which has
00065 // to be derived from the abstract base classes VirtualScalarColumn
00066 // or VirtualArrayColumn. The engine has to create the various
00067 // column objects via the functions makeXXXColumn.
00068 //
00069 // Initialization of the virtual column engine is done by the
00070 // functions create (for new tables), open (for existing tables) and prepare.
00071 // The engine can be flushed by the function flush, which allows to
00072 // write some data. The function open can read these data back.
00073 // VirtualColumnEngine is closely related with the table system.
00074 //
00075 // A number of (pure) virtual functions have been defined. The pure
00076 // virtual functions must be implemented in the derived class.
00077 // The non-pure virtual functions have a default implementation throwing
00078 // a "not possible" exception. They need to be implemented if they
00079 // are used for this engine (e.g. makeIndArrColumn does not need to
00080 // be implemented if the engine does not handle arrays).
00081 // Furthermore the pure virtual function dataManagerType (defined in
00082 // DataManager.h) has to be implemented. This should return the name
00083 // of the data manager, which is usually its class name. This name
00084 // has to be unique; so if the engine is templated, the template
00085 // parameter has to be part of the data manager name.
00086 //
00087 // The engine has to be registered before it can be used by the table system.
00088 // This means that a special makeObject function has to be made
00089 // known to the table system, which allows the table system to
00090 // reconstruct the engine using its name.
00091 //
00092 // An example of a virtual column engine can be found in dVirtColEng.{h,cc}
00093 // in the test directory of the Tables module.
00094 // Another exanple is class ScaledArray.
00095 // </synopsis> 
00096 
00097 // <motivation>
00098 // It is nice if a table column can be expressed as a function
00099 // of other columns (maybe even in other tables). A virtual column
00100 // provides this functionality in a very flexible way.
00101 // A specialized class can calculate the data of a virtual column,
00102 // but a common base class is required to interface it to the
00103 // table system.
00104 // </motivation>
00105 
00106 // <todo asof="$DATE:$">
00107 //# A List of bugs, limitations, extensions or planned refinements.
00108 // </todo>
00109 
00110 
00111 class VirtualColumnEngine : public DataManager
00112 {
00113 public:
00114 
00115     // Create the object.
00116     VirtualColumnEngine()
00117         {};
00118 
00119     virtual ~VirtualColumnEngine();
00120 
00121 private:
00122     // The copy constructor cannot be used for this base class.
00123     // The clone function should be used instead.
00124     // The private declaration of this constructor makes it unusable.
00125     VirtualColumnEngine (const VirtualColumnEngine& that);
00126 
00127     // Assignment cannot be used for this base class.
00128     // The private declaration of this operator makes it unusable.
00129     VirtualColumnEngine& operator= (const VirtualColumnEngine&);
00130 
00131     // The data manager is not a storage manager?
00132     Bool isStorageManager() const;
00133 
00134     // Flush the data in the engine object.
00135     // If the object contains persistent data, this is the place to write them.
00136     // This can be done in two ways:
00137     // <ul>
00138     // <li>
00139     // They can be written in the main table file (using the AipsIO argument).
00140     // This should preferably be used if the object contains only little data.
00141     // <li>
00142     // They can be written in a file of its own. A unique filename
00143     // can be acquired using DataManager::fileName().
00144     // This way is preferred when the object contains a lot of data.
00145     // Possibly this file could already be created in function create
00146     // and only be flushed and closed in this function. This allows
00147     // getting and putting of data as needed.
00148     // </ul>
00149     // Another way of storing information is by storing it as a keyword
00150     // in the table. In this case it is important to know that close
00151     // is called AFTER the keywords are written. Thus, in this way the
00152     // information has to be stored and read back in create, open and/or
00153     // prepare.
00154     // It returns a True status if it had to flush (i.e. if data have changed).
00155     // <br>The default implementation does nothing and returns False.
00156     virtual Bool flush (AipsIO&, Bool fsync);
00157 
00158     // Resync the storage manager with the new file contents.
00159     // This is done by clearing the cache.
00160     // The default implementation does nothing.
00161     virtual void resync (uInt nrrow);
00162 
00163     // Initialize the object for a new table containing initially nrrow rows.
00164     // It can be used to initialize variables (possibly using data
00165     // from other columns in the table).
00166     // The default implementation does nothing.
00167     virtual void create (uInt initialNrrow);
00168 
00169     // Initialize the object for an existing table containing nrrow rows.
00170     // It can be used to read values back (written by close) and/or
00171     // to initialize variables (possibly using data from other columns
00172     // in the table).
00173     // The default implementation does nothing.
00174     virtual void open (uInt nrrow, AipsIO& mainTableFile);
00175 
00176     // Let the data manager initialize itself further.
00177     // Prepare is called after create/open has been called for all
00178     // columns. In this way one can be sure that referenced columns
00179     // are read back and partly initialized.
00180     // The default implementation does nothing.
00181     virtual void prepare();
00182 
00183     // The data manager will be deleted (because all its columns are
00184     // requested to be deleted).
00185     // So clean up the things needed (e.g. delete files).
00186     // By default it assumes that nothing has to be done.
00187     virtual void deleteManager();
00188 
00189     // Make a column object in the engine on behalf of a table column.
00190     // This column object class is derived from VirtualScalarColumn
00191     // or VirtualArrayColumn. It handles the gets and puts of data.
00192     // <group>
00193     // Create a scalar column.
00194     // The default implementation throws an exception that it cannot
00195     // do it for this column.
00196     virtual DataManagerColumn* makeScalarColumn (const String& columnName,
00197                                                  int dataType,
00198                                                  const String& dataTypeId);
00199     // Create a direct array column.
00200     // The default implementation calls makeIndArrColumn
00201     // (when reading the user sees no difference between direct and indirect).
00202     virtual DataManagerColumn* makeDirArrColumn (const String& columnName,
00203                                                  int dataType,
00204                                                  const String& dataTypeId);
00205     // Create an indirect array column.
00206     // The default implementation throws an exception that it cannot
00207     // do it for this column.
00208     virtual DataManagerColumn* makeIndArrColumn (const String& columnName,
00209                                                  int dataType,
00210                                                  const String& dataTypeId);
00211     // </group>
00212 };
00213 
00214 
00215 
00216 } //# NAMESPACE CASA - END
00217 
00218 #endif
00219 
00220 
00221 

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