casacore
BucketBuffered.h
Go to the documentation of this file.
1 //# BucketBuffered.h: Use buffered file IO for buckets in a part of a file
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_BUCKETBUFFERED_H
29 #define CASA_BUCKETBUFFERED_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/IO/BucketBase.h>
34 
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38  //# Forward Declarations.
39  class FilebufIO;
40 
41 
42  // <summary>
43  // Use buffered file IO for buckets in a part of a file
44  // </summary>
45 
46  // <use visibility=export>
47 
48  // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
49  // </reviewed>
50 
51  // <prerequisite>
52  //# Classes you should understand before using this one.
53  // <li> <linkto class=BucketFile>BucketFile</linkto>
54  // </prerequisite>
55 
56  // <synopsis>
57  // BucketBuffered is similar to class
58  // <linkto class=BucketCache>BucketCache</linkto> and is meant to be used by
59  // the storage managers of the Table System.
60  //
61  // It gives access to buckets in a file by means of memory-buffered files.
62  // However, its functionality is a subset of BucketCache and is only meant
63  // to be used by the Tiled Storage Managers. If The Standard and Incremental
64  // Storage Manager also want to use it, functions like <src>extend</src>
65  // needs to be added to this class. Also support for a free bucket list needs
66  // to be added.
67  // </synopsis>
68 
69  // <motivation>
70  // Use of BucketCache is sub-optimal when having large buckets and more or
71  // less random IO. Memory-buffering behaves much better.
72  // </motivation>
73 
74 
75  class BucketBuffered: public BucketBase
76  {
77  public:
78  // Create the object for (part of) a file.
79  // The file part buffered into memory starts at startOffset. Its length is
80  // bucketSize*nrOfBuckets bytes.
81  // If the file is smaller, the remainder is indicated as an extension
82  // similarly to the behaviour of function extend.
83  BucketBuffered (BucketFile* file, Int64 startOffset, uInt bucketSize,
84  uInt nrOfBuckets);
85 
86  virtual ~BucketBuffered();
87 
88  // Get a pointer to the buffer.
89  char* getBuffer()
90  { return itsBuffer; }
91 
92  // Read the given part into the internal buffer at the given offset.
93  void read (uInt bucketNr, uInt bucketOffset, uInt nbytes,
94  uInt bufferOffset=0);
95 
96  // Write the given part from the internal buffer.
97  void write (uInt bucketNr, uInt bucketOffset, uInt nbytes);
98 
99 private:
100  // Copy constructor is not possible.
102 
103  // Assignment is not possible.
105 
106  // Flush the file.
107  virtual void doFlush();
108 
109  // Do the actual resync-ing.
110  virtual void doResync();
111 
112  // Extend the file with the given number of buckets.
113  virtual void doExtend (uInt nrBucket);
114 
115  // Initialize the bucket buffer.
116  // The uninitialized buckets before this bucket are also initialized.
117  virtual void initializeBuckets (uInt bucketNr);
118 
119 
120  // Data buffer.
121  char* itsBuffer;
122 };
123 
124 
125 } //# NAMESPACE CASACORE - END
126 
127 #endif
char * itsBuffer
Data buffer.
BucketBuffered(BucketFile *file, Int64 startOffset, uInt bucketSize, uInt nrOfBuckets)
Create the object for (part of) a file.
virtual void doResync()
Do the actual resync-ing.
void write(uInt bucketNr, uInt bucketOffset, uInt nbytes)
Write the given part from the internal buffer.
char * getBuffer()
Get a pointer to the buffer.
BucketBuffered(const BucketBuffered &)
Copy constructor is not possible.
BucketBuffered & operator=(const BucketBuffered &)
Assignment is not possible.
virtual void doExtend(uInt nrBucket)
Extend the file with the given number of buckets.
void read(uInt bucketNr, uInt bucketOffset, uInt nbytes, uInt bufferOffset=0)
Read the given part into the internal buffer at the given offset.
virtual void initializeBuckets(uInt bucketNr)
Initialize the bucket buffer.
virtual void doFlush()
Flush the file.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38