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