casa
$Rev:20696$
|
00001 //# MSMBase.h: Base class for storage manager for tables using 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: MSMBase.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00027 00028 #ifndef TABLES_MSMBASE_H 00029 #define TABLES_MSMBASE_H 00030 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <tables/Tables/DataManager.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward Declarations 00039 class MSMColumn; 00040 00041 00042 // <summary> 00043 // Base class for memory-based table storage manager class 00044 // </summary> 00045 00046 // <use visibility=local> 00047 00048 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00049 // </reviewed> 00050 00051 // <prerequisite> 00052 //# Classes you should understand before using this one. 00053 // <li> <linkto class=DataManager>DataManager</linkto> 00054 // </prerequisite> 00055 00056 // <etymology> 00057 // MSMBase is the base class for MemoryStMan. 00058 // </etymology> 00059 00060 // <synopsis> 00061 // See class <linkto class=MemoryStMan>MemoryStMan</linkto> for 00062 // the description. 00063 // </synopsis> 00064 00065 00066 class MSMBase : public DataManager 00067 { 00068 public: 00069 00070 // Create a memory storage manager. 00071 // Its name will be blank. 00072 MSMBase(); 00073 00074 // Create a memory storage manager with the given name. 00075 // Its name can be used later in e.g. Table::addColumn to 00076 // add a column to this storage manager. 00077 // <br> Note that the 2nd constructor is needed for table creation 00078 // from a record specification. 00079 // <group> 00080 MSMBase (const String& storageManagerName); 00081 MSMBase (const String& storageManagerName, const Record&); 00082 // </group> 00083 00084 ~MSMBase(); 00085 00086 // Clone this object. 00087 // It does not clone MSMColumn objects possibly used. 00088 DataManager* clone() const; 00089 00090 // Get the type name of the data manager (i.e. MemoryStMan). 00091 String dataManagerType() const; 00092 00093 // Get the name given to this storage manager. 00094 String dataManagerName() const; 00095 00096 // Get the nr of rows in this storage manager. 00097 uInt nrow() const 00098 { return nrrow_p; } 00099 00100 // Does the storage manager allow to add rows? (yes) 00101 Bool canAddRow() const; 00102 00103 // Does the storage manager allow to delete rows? (yes) 00104 Bool canRemoveRow() const; 00105 00106 // Does the storage manager allow to add columns? (yes) 00107 Bool canAddColumn() const; 00108 00109 // Does the storage manager allow to delete columns? (yes) 00110 Bool canRemoveColumn() const; 00111 00112 // Make the object from the string. 00113 // This function gets registered in the DataManager "constructor" map. 00114 static DataManager* makeObject (const String& dataManagerType, 00115 const Record& spec); 00116 00117 00118 private: 00119 // Flush and optionally fsync the data. 00120 // It does not done anything and always returns a False status. 00121 virtual Bool flush (AipsIO&, Bool fsync); 00122 00123 // Let the storage manager create the nr of rows needed. 00124 virtual void create (uInt nrrow); 00125 00126 // Open the storage manager file for an existing table. 00127 // It fills the rows with 0 values. 00128 virtual void open (uInt nrrow, AipsIO&); 00129 00130 // Let the data manager initialize itself further. 00131 // It creates nr of rows (given to create) if needed. 00132 // Note this is done after reallocateColumn. 00133 virtual void prepare(); 00134 00135 // Resync the storage manager with the new file contents. 00136 // It adds or removes rows as needed. 00137 // It cannot know which rows are deleted, so it always deletes 00138 // the last rows. 00139 virtual void resync (uInt nrrow); 00140 00141 // The data manager will be deleted (because all its columns are 00142 // requested to be deleted). 00143 // It does not have to do anything. 00144 virtual void deleteManager(); 00145 00146 // Add rows to all columns. 00147 void addRow (uInt nrrow); 00148 00149 // Delete a row from all columns. 00150 void removeRow (uInt rownr); 00151 00152 // Create a column in the storage manager on behalf of a table column. 00153 // <group> 00154 // Create a scalar column. 00155 DataManagerColumn* makeScalarColumn (const String& name, int dataType, 00156 const String& dataTypeID); 00157 // Create a direct array column. 00158 DataManagerColumn* makeDirArrColumn (const String& name, int dataType, 00159 const String& dataTypeID); 00160 // Create an indirect array column. 00161 DataManagerColumn* makeIndArrColumn (const String& name, int dataType, 00162 const String& dataTypeID); 00163 // </group> 00164 00165 // The MemoryStMan wants to do reallocateColumn. 00166 Bool canReallocateColumns() const; 00167 00168 // Reallocate the column object if it is part of this data manager. 00169 // It returns a pointer to the new column object. 00170 // It is used to replace an MSMIndColumn object for indirect array with 00171 // a fixed shape by an MSMDirColumn object. 00172 DataManagerColumn* reallocateColumn (DataManagerColumn* column); 00173 00174 // Add a column. 00175 void addColumn (DataManagerColumn*); 00176 00177 // Delete a column. 00178 void removeColumn (DataManagerColumn*); 00179 00180 00181 // Name given by user to this storage manager. 00182 String stmanName_p; 00183 // The number of rows in the columns. 00184 uInt nrrow_p; 00185 // The number of rows in create(). 00186 uInt nrrowCreate_p; 00187 // The assembly of all columns. 00188 PtrBlock<MSMColumn*> colSet_p; 00189 }; 00190 00191 00192 00193 00194 } //# NAMESPACE CASA - END 00195 00196 #endif