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