casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PlainColumn.h
Go to the documentation of this file.
00001 //# PlainColumn.h: Base class for a column in a plain table
00002 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,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: PlainColumn.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_PLAINCOLUMN_H
00029 #define TABLES_PLAINCOLUMN_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/BaseColumn.h>
00035 #include <tables/Tables/ColumnSet.h>
00036 #include <tables/Tables/TableRecord.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //# Forward Declarations
00041 class TableAttr;
00042 class BaseColumnDesc;
00043 class DataManager;
00044 class DataManagerColumn;
00045 class AipsIO;
00046 template<class T> class Array;
00047 class IPosition;
00048 
00049 
00050 // <summary>
00051 // Base class for a column in a plain table
00052 // </summary>
00053 
00054 // <use visibility=local>
00055 
00056 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00057 // </reviewed>
00058 
00059 // <prerequisite>
00060 //# Classes you should understand before using this one.
00061 //   <li> BaseColumn
00062 //   <li> PlainTable
00063 // </prerequisite>
00064 
00065 // <etymology>
00066 // PlainColumn represents any column in a plain table.
00067 // A plain table is a regular table, i.e. not a table like a
00068 // RefTable which is a view on a plain table.
00069 // </etymology>
00070 
00071 // <synopsis> 
00072 // Abstract base class for all types of columns in a plain table.
00073 // It implements the common functionality for all columns in a plain
00074 // table. Furthermore it defines some virtual functions (on top of
00075 // the virtual functions defined in BaseColumn) which are specific for
00076 // plain columns.
00077 // </synopsis> 
00078 
00079 // <todo asof="$DATE:$">
00080 //# A List of bugs, limitations, extensions or planned refinements.
00081 // </todo>
00082 
00083 
00084 class PlainColumn : public BaseColumn
00085 {
00086 public:
00087 
00088     PlainColumn (const BaseColumnDesc*, ColumnSet*);
00089 
00090     virtual ~PlainColumn();
00091 
00092     // Test if the column is in principle writable.
00093     // This does not test if the table itself is writable.
00094     // That has to be done by the caller.
00095     virtual Bool isWritable() const;
00096 
00097     // Test if the column is stored (otherwise it is virtual).
00098     virtual Bool isStored() const;
00099 
00100     // Get access to the column keyword set.
00101     // <group>
00102     TableRecord& rwKeywordSet();
00103     TableRecord& keywordSet();
00104     // </group>
00105 
00106     // Get nr of rows in the column.
00107     uInt nrow() const;
00108 
00109     // Define the shape of all arrays in the column.
00110     virtual void setShapeColumn (const IPosition& shape);
00111 
00112     // Test if the column is bound to a storage manager or
00113     // virtual column engine.
00114     virtual Bool isBound() const;
00115 
00116     // Bind the column to a data manager.
00117     virtual void bind (DataManager*);
00118 
00119     // Create a data manager column for a filled column.
00120     virtual void createDataManagerColumn() = 0;
00121 
00122     // Get the pointer to the data manager.
00123     DataManager* dataManager() const;
00124 
00125     // Get the pointer to the data manager column.
00126     DataManagerColumn*& dataManagerColumn();
00127 
00128     // Get a pointer to the underlying column cache.
00129     virtual ColumnCache& columnCache();
00130 
00131     // Set the maximum cache size (in bytes) to be used by a storage manager.
00132     virtual void setMaximumCacheSize (uInt nbytes);
00133 
00134     // Write the column.
00135     void putFile (AipsIO&, const TableAttr&);
00136 
00137     // Read the column.
00138     void getFile (AipsIO&, const ColumnSet&, const TableAttr&);
00139 
00140 protected:
00141     DataManager*        dataManPtr_p;    //# Pointer to data manager.
00142     DataManagerColumn*  dataColPtr_p;    //# Pointer to column in data manager.
00143     ColumnSet*          colSetPtr_p;
00144     String              originalName_p;  //# Column name before any rename
00145 
00146     // Write the column.
00147     // The control information is written into the given AipsIO object,
00148     // while the data is written by the storage manager.
00149     virtual void putFileDerived (AipsIO&) = 0;
00150 
00151     // Read the column back.
00152     // The control information is read from the given AipsIO object.
00153     // This is used to bind the column to the appropriate data manager.
00154     virtual void getFileDerived (AipsIO&, const ColumnSet&) = 0;
00155 
00156     // Check the length of a value.
00157     // This a meant for String values for which a maximum length is defined.
00158     // The void* version is a no-op for other values.
00159     // <group>
00160     void checkValueLength (const void*) const;
00161     void checkValueLength (const String* value) const;
00162     void checkValueLength (const Array<String>* value) const;
00163     // </group>
00164     
00165     // Lock the table before reading or writing.
00166     // If manual or permanent locking is in effect, it checks if
00167     // the table is locked.
00168     // <group>
00169     void checkReadLock (Bool wait) const;
00170     void checkWriteLock (Bool wait) const;
00171     // </group>
00172 
00173     // Inspect the auto lock when the inspection interval has expired and
00174     // release it when another process needs the lock.
00175     void autoReleaseLock() const;
00176 };
00177 
00178 
00179 inline DataManager* PlainColumn::dataManager() const
00180     { return dataManPtr_p; }
00181 inline DataManagerColumn*& PlainColumn::dataManagerColumn()
00182     { return dataColPtr_p; }
00183 
00184 inline void PlainColumn::checkValueLength (const void*) const
00185     {}
00186 
00187 inline void PlainColumn::checkReadLock (Bool wait) const
00188     { colSetPtr_p->checkReadLock (wait); }
00189 inline void PlainColumn::checkWriteLock (Bool wait) const
00190     { colSetPtr_p->checkWriteLock (wait); }
00191 inline void PlainColumn::autoReleaseLock() const
00192     { colSetPtr_p->autoReleaseLock(); }
00193 
00194 
00195 
00196 } //# NAMESPACE CASA - END
00197 
00198 #endif