casacore
Loading...
Searching...
No Matches
BucketBase.h
Go to the documentation of this file.
1// # BucketBase.h: Abstract base class for Bucket classes
2// # Copyright (C) 2010
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 CASA_BUCKETBASE_H
27#define CASA_BUCKETBASE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/IO/BucketFile.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// <summary>
36// Abstract base class for Bucket classes.
37// </summary>
38
39// <use visibility=local>
40
41// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
42// </reviewed>
43
44// <prerequisite>
45// # Classes you should understand before using this one.
46// <li> <linkto class=BucketFile>BucketFile</linkto>
47// </prerequisite>
48
49// <synopsis>
50// BucketBase is the abstract baseclass for the various Bucket classes
51// like BucketMapped and BucketBuffered.
52// It is used by TSMCube to do the IO in the required way.
53// </synopsis>
54
56 public:
57 // Create the bucket access for (part of) a file.
58 // The file part starts at startOffset. Its length is
59 // bucketSize*nrOfBuckets bytes.
60 // If the file is smaller, the remainder is indicated as an extension
61 // similarly to the behaviour of function extend.
62 BucketBase(BucketFile* file, Int64 startOffset, uInt bucketSize, uInt nrOfBuckets);
63
64 // Detach the file. The BucketFile is not closed.
65 virtual ~BucketBase();
66
67 // Flush the cached buckets.
68 // Possibly remaining uninitialized buckets will be initialized first.
69 // A True status is returned if buckets had to be written.
70 // The actual flushing is done using <src>doFlush</src> in the derived
71 // class.
73
74 // Resynchronize the object (after another process updated the file).
75 // It remaps the file if the nr of buckets has changed.
76 // the new sizes.
77 virtual void resync(uInt nrBucket);
78
79 // Get the current nr of buckets in the file.
80 uInt nBucket() const { return itsCurNrOfBuckets; }
81
82 // Extend the file with the given number of buckets.
83 // The buckets get initialized when they are acquired
84 // (using getBucket) for the first time.
85 void extend(uInt nrBucket);
86
87 // Set that data has been written.
89
90 protected:
91 // Copy constructor is not possible.
93
94 // Assignment is not possible.
96
97 // Do the actual flushing.
98 virtual void doFlush() = 0;
99
100 // Do the actual resync-ing.
101 virtual void doResync() = 0;
102
103 // Do the actual extension of the file.
104 // Note that itsNewNrOfBuckets has been increased before doExtend is called.
105 virtual void doExtend(uInt nrBucket) = 0;
106
107 // Initialize the bucket buffer.
108 // The uninitialized buckets before this bucket are also initialized.
109 virtual void initializeBuckets(uInt bucketNr) = 0;
110
111 // The file used.
113 // The starting offsets of the buckets in the file.
115 // The bucket size.
117 // The current nr of buckets in the file.
119 // The new nr of buckets in the file (after extension).
121 // Have data been written?
123};
124
125} // namespace casacore
126
127#endif
virtual void doExtend(uInt nrBucket)=0
Do the actual extension of the file.
uInt itsNewNrOfBuckets
The new nr of buckets in the file (after extension).
Definition BucketBase.h:120
uInt itsCurNrOfBuckets
The current nr of buckets in the file.
Definition BucketBase.h:118
Bool itsHasWritten
Have data been written?
Definition BucketBase.h:122
uInt itsBucketSize
The bucket size.
Definition BucketBase.h:116
virtual void doResync()=0
Do the actual resync-ing.
virtual void initializeBuckets(uInt bucketNr)=0
Initialize the bucket buffer.
virtual void resync(uInt nrBucket)
Resynchronize the object (after another process updated the file).
void extend(uInt nrBucket)
Extend the file with the given number of buckets.
uInt nBucket() const
Get the current nr of buckets in the file.
Definition BucketBase.h:80
BucketFile * itsFile
The file used.
Definition BucketBase.h:112
Int64 itsStartOffset
The starting offsets of the buckets in the file.
Definition BucketBase.h:114
BucketBase(BucketFile *file, Int64 startOffset, uInt bucketSize, uInt nrOfBuckets)
Create the bucket access for (part of) a file.
BucketBase(const BucketBase &)
Copy constructor is not possible.
Bool flush()
Flush the cached buckets.
void setWritten()
Set that data has been written.
Definition BucketBase.h:88
virtual ~BucketBase()
Detach the file.
BucketBase & operator=(const BucketBase &)
Assignment is not possible.
virtual void doFlush()=0
Do the actual flushing.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41