casa
$Rev:20696$
|
00001 //# TableSyncData.h: Class to hold table synchronization data 00002 //# Copyright (C) 1997,1999 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: TableSyncData.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00027 00028 #ifndef TABLES_TABLESYNCDATA_H 00029 #define TABLES_TABLESYNCDATA_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <casa/Containers/Block.h> 00034 #include <casa/IO/MemoryIO.h> 00035 #include <casa/IO/AipsIO.h> 00036 00037 00038 namespace casa { //# NAMESPACE CASA - BEGIN 00039 00040 // <summary> 00041 // Class to hold table synchronization data. 00042 // </summary> 00043 00044 // <use visibility=local> 00045 00046 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tTable" demos=""> 00047 // </reviewed> 00048 00049 // <prerequisite> 00050 // <li> class <linkto class=Table>TableLockData</linkto> 00051 // </prerequisite> 00052 00053 // <synopsis> 00054 // This class keeps counters to synchronize the table data when a table 00055 // is locked or unlocked. 00056 // <br> 00057 // A few counters are kept by this class: 00058 // <ul> 00059 // <li> The numbers of rows in the table. 00060 // <li> The number of columns in the table. 00061 // <li> The table change counter. 00062 // <li> A change counter per data manager. 00063 // </ul> 00064 // When a lock on the table is acquired, it reads the sync data from the 00065 // lock file and determines if anything has changed. If so, the necessary 00066 // steps are taken to reread the table data when needed. 00067 // <br> 00068 // When a lock on the table is released, it updates and writes the sync data 00069 // which tells if table data have changed. 00070 // <p> 00071 // This class can also be used for the synchronization of tables and 00072 // external fillers (see class 00073 // <linkto class=ExternalLockSync>ExternalLockSync</linkto>). For this 00074 // purpose it is sufficient to store the number of rows. 00075 // </synopsis> 00076 00077 00078 class TableSyncData 00079 { 00080 public: 00081 TableSyncData(); 00082 00083 ~TableSyncData(); 00084 00085 // Update the synchronization data and write it into the MemoryIO object. 00086 // This function is called when a table flush is done to reflect 00087 // if anything has changed compared to the previous flush. 00088 void write (uInt nrrow, uInt nrcolumn, Bool tableChanged, 00089 const Block<Bool>& dataManChanged); 00090 00091 // Update the synchronization data and write it into the MemoryIO object. 00092 // This function should be used by an external filler when it flushes 00093 // its data. 00094 void write (uInt nrrow); 00095 00096 // Read the synchronization data from the MemoryIO object. 00097 // This function is called when a lock is acquired to see if 00098 // table data has to be reread. 00099 // <br>It returns False when the MemoryIO object is empty. 00100 Bool read (uInt& nrrow, uInt& nrcolumn, Bool& tableChanged, 00101 Block<Bool>& dataManChanged); 00102 00103 // Get the MemoryIO object. 00104 // This is used to let <src>LockFile</src> read or write the 00105 // synchronization data into it. 00106 MemoryIO& memoryIO(); 00107 00108 // Get the modify counter. 00109 uInt getModifyCounter() const; 00110 00111 00112 private: 00113 // Copy constructor is forbidden. 00114 TableSyncData (const TableSyncData& that); 00115 00116 // Assignment is forbidden. 00117 TableSyncData& operator= (const TableSyncData& that); 00118 00119 00120 //# Member variables. 00121 uInt itsNrrow; 00122 Int itsNrcolumn; 00123 uInt itsModifyCounter; 00124 uInt itsTableChangeCounter; 00125 Block<uInt> itsDataManChangeCounter; 00126 MemoryIO itsMemIO; 00127 AipsIO itsAipsIO; 00128 }; 00129 00130 00131 00132 inline MemoryIO& TableSyncData::memoryIO() 00133 { 00134 return itsMemIO; 00135 } 00136 inline uInt TableSyncData::getModifyCounter() const 00137 { 00138 return itsModifyCounter; 00139 } 00140 00141 00142 00143 00144 } //# NAMESPACE CASA - END 00145 00146 #endif