casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableSyncData.h
Go to the documentation of this file.
1 //# TableSyncData.h: Class to hold table synchronization data
2 //# Copyright (C) 1997,1999
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TABLES_TABLESYNCDATA_H
29 #define TABLES_TABLESYNCDATA_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
36 
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 // <summary>
41 // Class to hold table synchronization data.
42 // </summary>
43 
44 // <use visibility=local>
45 
46 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tTable" demos="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> class <linkto class=Table>TableLockData</linkto>
51 // </prerequisite>
52 
53 // <synopsis>
54 // This class keeps counters to synchronize the table data when a table
55 // is locked or unlocked.
56 // <br>
57 // A few counters are kept by this class:
58 // <ul>
59 // <li> The numbers of rows in the table.
60 // <li> The number of columns in the table.
61 // <li> The table change counter.
62 // <li> A change counter per data manager.
63 // </ul>
64 // When a lock on the table is acquired, it reads the sync data from the
65 // lock file and determines if anything has changed. If so, the necessary
66 // steps are taken to reread the table data when needed.
67 // <br>
68 // When a lock on the table is released, it updates and writes the sync data
69 // which tells if table data have changed.
70 // <p>
71 // This class can also be used for the synchronization of tables and
72 // external fillers (see class
73 // <linkto class=ExternalLockSync>ExternalLockSync</linkto>). For this
74 // purpose it is sufficient to store the number of rows.
75 // </synopsis>
76 
77 
79 {
80 public:
81  TableSyncData();
82 
84 
85  // Update the synchronization data and write it into the MemoryIO object.
86  // This function is called when a table flush is done to reflect
87  // if anything has changed compared to the previous flush.
88  void write (rownr_t nrrow, uInt nrcolumn, Bool tableChanged,
89  const Block<Bool>& dataManChanged);
90 
91  // Update the synchronization data and write it into the MemoryIO object.
92  // This function should be used by an external filler when it flushes
93  // its data.
94  void write (rownr_t nrrow);
95 
96  // Read the synchronization data from the MemoryIO object.
97  // This function is called when a lock is acquired to see if
98  // table data has to be reread.
99  // <br>It returns False when the MemoryIO object is empty.
100  Bool read (rownr_t& nrrow, uInt& nrcolumn, Bool& tableChanged,
101  Block<Bool>& dataManChanged);
102 
103  // Get the MemoryIO object.
104  // This is used to let <src>LockFile</src> read or write the
105  // synchronization data into it.
106  MemoryIO& memoryIO();
107 
108  // Get the modify counter.
109  uInt getModifyCounter() const;
110 
111 
112 private:
113  // Copy constructor is forbidden.
114  TableSyncData (const TableSyncData& that);
115 
116  // Assignment is forbidden.
117  TableSyncData& operator= (const TableSyncData& that);
118 
119 
120  //# Member variables.
128 };
129 
130 
131 
133 {
134  return itsMemIO;
135 }
137 {
138  return itsModifyCounter;
139 }
140 
141 
142 
143 
144 } //# NAMESPACE CASACORE - END
145 
146 #endif
int Int
Definition: aipstype.h:50
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
TableSyncData & operator=(const TableSyncData &that)
Assignment is forbidden.
Class to hold table synchronization data.
Definition: TableSyncData.h:78
void write(rownr_t nrrow, uInt nrcolumn, Bool tableChanged, const Block< Bool > &dataManChanged)
Update the synchronization data and write it into the MemoryIO object.
Block< uInt > itsDataManChangeCounter
MemoryIO & memoryIO()
Get the MemoryIO object.
uInt getModifyCounter() const
Get the modify counter.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
Bool read(rownr_t &nrrow, uInt &nrcolumn, Bool &tableChanged, Block< Bool > &dataManChanged)
Read the synchronization data from the MemoryIO object.
Class for IO to a memory buffer.
Definition: MemoryIO.h:124
unsigned int uInt
Definition: aipstype.h:51