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$ 00027 00028 #ifndef TABLES_PLAINCOLUMN_H 00029 #define TABLES_PLAINCOLUMN_H 00030 00031 00032 //# Includes 00033 #include <casacore/casa/aips.h> 00034 #include <casacore/tables/Tables/BaseColumn.h> 00035 #include <casacore/tables/Tables/ColumnSet.h> 00036 #include <casacore/tables/Tables/TableRecord.h> 00037 00038 namespace casacore { //# NAMESPACE CASACORE - 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 Bool rtraceColumn_p; //# trace reads of the column? 00146 Bool wtraceColumn_p; //# trace writes of the column? 00147 00148 // Get the trace-id of the table. 00149 int traceId() const 00150 { return colSetPtr_p->traceId(); } 00151 00152 // Write the column. 00153 // The control information is written into the given AipsIO object, 00154 // while the data is written by the storage manager. 00155 virtual void putFileDerived (AipsIO&) = 0; 00156 00157 // Read the column back. 00158 // The control information is read from the given AipsIO object. 00159 // This is used to bind the column to the appropriate data manager. 00160 virtual void getFileDerived (AipsIO&, const ColumnSet&) = 0; 00161 00162 // Check the length of a value. 00163 // This a meant for String values for which a maximum length is defined. 00164 // The void* version is a no-op for other values. 00165 // <group> 00166 void checkValueLength (const void*) const; 00167 void checkValueLength (const String* value) const; 00168 void checkValueLength (const Array<String>* value) const; 00169 // </group> 00170 00171 // Lock the table before reading or writing. 00172 // If manual or permanent locking is in effect, it checks if 00173 // the table is locked. 00174 // <group> 00175 void checkReadLock (Bool wait) const; 00176 void checkWriteLock (Bool wait) const; 00177 // </group> 00178 00179 // Inspect the auto lock when the inspection interval has expired and 00180 // release it when another process needs the lock. 00181 void autoReleaseLock() const; 00182 }; 00183 00184 00185 inline DataManager* PlainColumn::dataManager() const 00186 { return dataManPtr_p; } 00187 inline DataManagerColumn*& PlainColumn::dataManagerColumn() 00188 { return dataColPtr_p; } 00189 00190 inline void PlainColumn::checkValueLength (const void*) const 00191 {} 00192 00193 inline void PlainColumn::checkReadLock (Bool wait) const 00194 { colSetPtr_p->checkReadLock (wait); } 00195 inline void PlainColumn::checkWriteLock (Bool wait) const 00196 { colSetPtr_p->checkWriteLock (wait); } 00197 inline void PlainColumn::autoReleaseLock() const 00198 { colSetPtr_p->autoReleaseLock(); } 00199 00200 00201 00202 } //# NAMESPACE CASACORE - END 00203 00204 #endif