casa
5.7.0-16
|
File object for BucketCache. More...
#include <BucketFile.h>
Public Member Functions | |
BucketFile (const String &fileName, uInt bufSizeFile=0, Bool mappedFile=False, MultiFileBase *mfile=0) | |
Create a BucketFile object for a new file. More... | |
BucketFile (const String &fileName, Bool writable, uInt bufSizeFile=0, Bool mappedFile=False, MultiFileBase *mfile=0) | |
Create a BucketFile object for an existing file. More... | |
virtual | ~BucketFile () |
The destructor closes the file (if open). More... | |
virtual CountedPtr< ByteIO > | makeFilebufIO (uInt bufferSize) |
Make a (temporary) buffered IO object for this file. More... | |
MMapfdIO * | mappedFile () |
Get the mapped file object. More... | |
FilebufIO * | bufferedFile () |
Get the buffered file object. More... | |
virtual void | open () |
Open the file if not open yet. More... | |
virtual void | close () |
Close the file (if open). More... | |
virtual void | remove () |
Remove the file (and close it if needed). More... | |
virtual void | fsync () |
Fsync the file (i.e. More... | |
virtual void | setRW () |
Set the file to read/write access. More... | |
virtual const String & | name () const |
Get the file name. More... | |
Bool | isWritable () const |
Has the file logically been indicated as writable? More... | |
virtual uInt | read (void *buffer, uInt length) |
Read bytes from the file. More... | |
virtual uInt | write (const void *buffer, uInt length) |
Write bytes into the file. More... | |
virtual void | seek (Int64 offset) |
Seek in the file. More... | |
void | seek (Int offset) |
virtual Int64 | fileSize () const |
Get the (physical) size of the file. More... | |
Bool | isCached () const |
Is the file cached, mapped, or buffered? More... | |
Bool | isMapped () const |
Bool | isBuffered () const |
Private Member Functions | |
BucketFile (const BucketFile &) | |
Forbid copy constructor. More... | |
BucketFile & | operator= (const BucketFile &) |
Forbid assignment. More... | |
void | createMapBuf () |
Create the mapped or buffered file object. More... | |
void | deleteMapBuf () |
Delete the possible mapped or buffered file object. More... | |
Private Attributes | |
String | name_p |
The file name. More... | |
Bool | isWritable_p |
The (logical) writability of the file. More... | |
Bool | isMapped_p |
uInt | bufSize_p |
int | fd_p |
CountedPtr< ByteIO > | file_p |
The unbuffered file. More... | |
MMapfdIO * | mappedFile_p |
The optional mapped file. More... | |
FilebufIO * | bufferedFile_p |
The optional buffered file. More... | |
MultiFileBase * | mfile_p |
The possibly used MultiFileBase. More... | |
File object for BucketCache.
Internal
BucketFile represents a data file for the BucketCache class.
A BucketFile object represents a data file. Currently it is used by the Table system, but it can easily be turned into a more general storage manager file class.
Creation of a BucketFile object does not open the file yet. An explicit open call has to be given before the file can be used.
The file can be opened as an ordinary file (with a file descriptor) or as a file in a MultiFileBase object. An ordinary file can be accessed in 3 ways:
A MultiFileBase file can only be accessed in the unbuffered way.
Encapsulate the file creation and access into a single class to hide the file IO details.
Definition at line 107 of file BucketFile.h.
|
explicit |
Create a BucketFile object for a new file.
The file with the given name will be created as a normal file or as part of a MultiFileBase (if mfile != 0). It can be indicated if a MMapfdIO and/or FilebufIO object must be created for the file. If a MultiFileBase is used, memory-mapped IO cannot be used and mappedFile is ignored.
casacore::BucketFile::BucketFile | ( | const String & | fileName, |
Bool | writable, | ||
uInt | bufSizeFile = 0 , |
||
Bool | mappedFile = False , |
||
MultiFileBase * | mfile = 0 |
||
) |
Create a BucketFile object for an existing file.
The file should be opened by the open
. Tell if the file must be opened writable. It can be indicated if a MMapfdIO and/or FilebufIO object must be created for the file. If a MultiFileBase is used, memory-mapped IO cannot be used and mappedFile is ignored.
|
virtual |
The destructor closes the file (if open).
|
private |
Forbid copy constructor.
|
inline |
Get the buffered file object.
Definition at line 142 of file BucketFile.h.
References bufferedFile_p.
|
virtual |
Close the file (if open).
|
private |
Create the mapped or buffered file object.
|
private |
Delete the possible mapped or buffered file object.
|
virtual |
Get the (physical) size of the file.
This is doing a seek and sets the file pointer to end-of-file.
|
virtual |
Fsync the file (i.e.
force the data to be physically written).
|
inline |
Definition at line 235 of file BucketFile.h.
References bufSize_p.
|
inline |
Is the file cached, mapped, or buffered?
Definition at line 231 of file BucketFile.h.
References bufSize_p, and isMapped_p.
|
inline |
Definition at line 233 of file BucketFile.h.
References isMapped_p.
|
inline |
Has the file logically been indicated as writable?
Definition at line 225 of file BucketFile.h.
References isWritable_p.
|
virtual |
Make a (temporary) buffered IO object for this file.
That object should not close the file.
|
inline |
|
inlinevirtual |
|
virtual |
Open the file if not open yet.
Referenced by casacore::TSMFile::open().
|
private |
Forbid assignment.
Read bytes from the file.
|
virtual |
Remove the file (and close it if needed).
|
virtual |
Seek in the file.
Referenced by seek().
|
inline |
Definition at line 228 of file BucketFile.h.
References seek().
|
virtual |
Set the file to read/write access.
It is reopened if not writable. It does nothing if the file is already writable.
Write bytes into the file.
|
private |
The optional buffered file.
Definition at line 203 of file BucketFile.h.
Referenced by bufferedFile().
|
private |
Definition at line 196 of file BucketFile.h.
Referenced by isBuffered(), and isCached().
|
private |
Definition at line 197 of file BucketFile.h.
|
private |
The unbuffered file.
Definition at line 199 of file BucketFile.h.
|
private |
Definition at line 195 of file BucketFile.h.
Referenced by isCached(), and isMapped().
|
private |
The (logical) writability of the file.
Definition at line 194 of file BucketFile.h.
Referenced by isWritable().
|
private |
|
private |
The possibly used MultiFileBase.
Definition at line 205 of file BucketFile.h.
|
private |