casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef TABLES_TABLESYNCDATA_H
27#define TABLES_TABLESYNCDATA_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Containers/Block.h>
32#include <casacore/casa/IO/MemoryIO.h>
33#include <casacore/casa/IO/AipsIO.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// <summary>
38// Class to hold table synchronization data.
39// </summary>
40
41// <use visibility=local>
42
43// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tTable" demos="">
44// </reviewed>
45
46// <prerequisite>
47// <li> class <linkto class=Table>TableLockData</linkto>
48// </prerequisite>
49
50// <synopsis>
51// This class keeps counters to synchronize the table data when a table
52// is locked or unlocked.
53// <br>
54// A few counters are kept by this class:
55// <ul>
56// <li> The numbers of rows in the table.
57// <li> The number of columns in the table.
58// <li> The table change counter.
59// <li> A change counter per data manager.
60// </ul>
61// When a lock on the table is acquired, it reads the sync data from the
62// lock file and determines if anything has changed. If so, the necessary
63// steps are taken to reread the table data when needed.
64// <br>
65// When a lock on the table is released, it updates and writes the sync data
66// which tells if table data have changed.
67// <p>
68// This class can also be used for the synchronization of tables and
69// external fillers (see class
70// <linkto class=ExternalLockSync>ExternalLockSync</linkto>). For this
71// purpose it is sufficient to store the number of rows.
72// </synopsis>
73
75 public:
77
79
80 // Copy constructor is forbidden.
81 TableSyncData(const TableSyncData& that) = delete;
82
83 // Assignment is forbidden.
84 TableSyncData& operator=(const TableSyncData& that) = delete;
85
86 // Update the synchronization data and write it into the MemoryIO object.
87 // This function is called when a table flush is done to reflect
88 // if anything has changed compared to the previous flush.
89 void write(rownr_t nrrow, uInt nrcolumn, Bool tableChanged, 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, Block<Bool>& dataManChanged);
101
102 // Get the MemoryIO object.
103 // This is used to let <src>LockFile</src> read or write the
104 // synchronization data into it.
106
107 // Get the modify counter.
108 uInt getModifyCounter() const;
109
110 private:
111 // # Member variables.
117 std::shared_ptr<MemoryIO> itsMemIO;
119};
120
123
124} // namespace casacore
125
126#endif
Block< uInt > itsDataManChangeCounter
void write(rownr_t nrrow, uInt nrcolumn, Bool tableChanged, const Block< Bool > &dataManChanged)
Update the synchronization data and write it into the MemoryIO object.
TableSyncData & operator=(const TableSyncData &that)=delete
Assignment is forbidden.
MemoryIO & memoryIO()
Get the MemoryIO object.
std::shared_ptr< MemoryIO > itsMemIO
Bool read(rownr_t &nrrow, uInt &nrcolumn, Bool &tableChanged, Block< Bool > &dataManChanged)
Read the synchronization data from the MemoryIO object.
TableSyncData(const TableSyncData &that)=delete
Copy constructor is forbidden.
void write(rownr_t nrrow)
Update the synchronization data and write it into the MemoryIO object.
uInt getModifyCounter() const
Get the modify counter.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44