casa
$Rev:20696$
|
00001 //# MemoryTable.h: Class for a table held in memory 00002 //# Copyright (C) 2003 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: MemoryTable.h 21014 2011-01-06 08:57:49Z gervandiepen $ 00027 00028 #ifndef TABLES_MEMORYTABLE_H 00029 #define TABLES_MEMORYTABLE_H 00030 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <tables/Tables/BaseTable.h> 00035 #include <casa/BasicSL/String.h> 00036 #include <casa/Arrays/Vector.h> 00037 00038 namespace casa { //# NAMESPACE CASA - BEGIN 00039 00040 //# Forward Declarations 00041 class SetupNewTable; 00042 class ColumnSet; 00043 class TableLockData; 00044 00045 00046 // <summary> 00047 // Class for a table held in memory 00048 // </summary> 00049 00050 // <use visibility=local> 00051 00052 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00053 // </reviewed> 00054 00055 // <prerequisite> 00056 //# Classes you should understand before using this one. 00057 // <li> BaseTable 00058 // </prerequisite> 00059 00060 // <synopsis> 00061 // MemoryTable holds all its data in memory. 00062 // It means that the data is not persistent. However, it can be copied to 00063 // another table to make the data persistent. 00064 // Furthermore it is a table as all other tables, so all table functions 00065 // can be applied to it. Some functions (e.g. lock) won't do anything. 00066 // Also all table operations like sorting, selecting, and iterating can 00067 // be used. 00068 // 00069 // The constructor accepts a SetupNewTable object which can contain 00070 // bindings of columns to any data manager. All bindings to storage 00071 // managers will be replaced by a binding to the memory based storage 00072 // manager <linkto class=MemoryStMan>MemoryStMan</linkto>. Also all 00073 // unbound columns will be bound to MemoryStMan. 00074 // Thus it is still possible that a column is bound to a virtual column 00075 // engine like <linkto class=CompressComplex>CompressComplex</linkto>. 00076 // </synopsis> 00077 00078 //# <todo asof="$DATE:$"> 00079 //# </todo> 00080 00081 00082 class MemoryTable : public BaseTable 00083 { 00084 public: 00085 00086 // Create the table in memory using the definitions in the 00087 // SetupNewTable object. 00088 MemoryTable (SetupNewTable&, uInt nrrow, Bool initialize); 00089 00090 // The destructor deletes all data. 00091 virtual ~MemoryTable(); 00092 00093 // Try to reopen the table (the underlying one) for read/write access. 00094 // It does nothing. 00095 virtual void reopenRW(); 00096 00097 // Is the table stored in big or little endian format? 00098 // It returns the endian format of the machine. 00099 virtual Bool asBigEndian() const; 00100 00101 // Is the table in use (i.e. open) in another process? 00102 // It always returns False. 00103 virtual Bool isMultiUsed (Bool checkSubTable) const; 00104 00105 // Get the locking info. 00106 // It returns PermanentLocking. 00107 virtual const TableLock& lockOptions() const; 00108 00109 // Merge the given lock info with the existing one. 00110 // It does nothing. 00111 virtual void mergeLock (const TableLock& lockOptions); 00112 00113 // Has this process the read or write lock, thus can the table 00114 // be read or written safely? 00115 // It always returns True. 00116 virtual Bool hasLock (FileLocker::LockType) const; 00117 00118 // Locking the table is a no-op. 00119 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00120 00121 // Unlocking the table is a no-op. 00122 virtual void unlock(); 00123 00124 // Flushing the table is a no-op. 00125 virtual void flush (Bool fsync, Bool recursive); 00126 00127 // Resyncing the Table is a no-op. 00128 virtual void resync(); 00129 00130 // Get the modify counter. It always returns 0. 00131 virtual uInt getModifyCounter() const; 00132 00133 // Test if the table is opened as writable. It always returns True. 00134 virtual Bool isWritable() const; 00135 00136 // Copy the table and all its subtables. 00137 // It copies the contents of each row to get a real copy. 00138 // <group> 00139 virtual void copy (const String& newName, int tableOption) const; 00140 virtual void deepCopy (const String& newName, 00141 const Record& dataManagerInfo, 00142 int tableOption, Bool, int endianFormat, 00143 Bool noRows) const; 00144 // </group> 00145 00146 // Rename the table. The tableOption is ignored. 00147 virtual void rename (const String& newName, int tableOption); 00148 00149 // Get the table type (Table::Memory). 00150 virtual int tableType() const; 00151 00152 // Get the actual table description. 00153 virtual TableDesc actualTableDesc() const; 00154 00155 // Get the data manager info. 00156 virtual Record dataManagerInfo() const; 00157 00158 // Get readonly access to the table keyword set. 00159 virtual TableRecord& keywordSet(); 00160 00161 // Get read/write access to the table keyword set. 00162 virtual TableRecord& rwKeywordSet(); 00163 00164 // Write the TableInfo object. It does not do anything. 00165 virtual void flushTableInfo(); 00166 00167 // Get a column object using its index. 00168 virtual BaseColumn* getColumn (uInt columnIndex) const; 00169 00170 // Get a column object using its name. 00171 virtual BaseColumn* getColumn (const String& columnName) const; 00172 00173 // Test if it is possible to add a row to this table (yes). 00174 virtual Bool canAddRow() const; 00175 00176 // Add one or more rows and possibly initialize them. 00177 // This will fail for tables not supporting addition of rows. 00178 virtual void addRow (uInt nrrow = 1, Bool initialize = True); 00179 00180 // Test if it is possible to remove a row from this table (yes). 00181 virtual Bool canRemoveRow() const; 00182 00183 // Remove the given row. 00184 virtual void removeRow (uInt rownr); 00185 00186 // Add a column to the table. 00187 // If the DataManager is not a virtual engine, MemoryStMan will be used. 00188 // The last Bool argument is not used in MemoryTable, but can be used in 00189 // other classes derived from BaseTable. 00190 // <group> 00191 virtual void addColumn (const ColumnDesc& columnDesc, Bool addToParent); 00192 virtual void addColumn (const ColumnDesc& columnDesc, 00193 const String& dataManager, Bool byName, 00194 Bool addToParent); 00195 virtual void addColumn (const ColumnDesc& columnDesc, 00196 const DataManager& dataManager, Bool addToParent); 00197 virtual void addColumn (const TableDesc& tableDesc, 00198 const DataManager& dataManager, Bool addToParent); 00199 // </group> 00200 00201 // Test if columns can be removed (yes). 00202 virtual Bool canRemoveColumn (const Vector<String>& columnNames) const; 00203 00204 // Remove columns. 00205 virtual void removeColumn (const Vector<String>& columnNames); 00206 00207 // Test if a column can be renamed (yes). 00208 virtual Bool canRenameColumn (const String& columnName) const; 00209 00210 // Rename a column. 00211 virtual void renameColumn (const String& newName, const String& oldName); 00212 00213 // Rename a hypercolumn. 00214 virtual void renameHypercolumn (const String& newName, 00215 const String& oldName); 00216 00217 // Find the data manager with the given name or for the given column. 00218 // There is only one storage manager (MemoryStMan) with name MSM. 00219 virtual DataManager* findDataManager (const String& name, 00220 Bool byColumn) const; 00221 00222 00223 private: 00224 ColumnSet* colSetPtr_p; //# pointer to set of columns 00225 TableLockData* lockPtr_p; //# pointer to lock object 00226 00227 // Copy constructor is forbidden, because copying a table requires 00228 // some more knowledge (like table name of result). 00229 // Declaring it private, makes it unusable. 00230 MemoryTable (const MemoryTable&); 00231 00232 // Assignment is forbidden, because copying a table requires 00233 // some more knowledge (like table name of result). 00234 // Declaring it private, makes it unusable. 00235 MemoryTable& operator= (const MemoryTable&); 00236 00237 // Setup the main parts of the object. 00238 // <br>Create the initial name map from the table description. 00239 // This map maps a name to the name in the original table. 00240 // A rename might change the map. 00241 // <br>Create the RefColumn objects. 00242 // <br>Create the initial TableInfo as a copy of the original BaseTable. 00243 void setup (BaseTable* btp); 00244 }; 00245 00246 00247 00248 } //# NAMESPACE CASA - END 00249 00250 #endif