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. | |
BucketFile (const String &fileName, Bool writable, uInt bufSizeFile=0, Bool mappedFile=False, MultiFileBase *mfile=0) | |
Create a BucketFile object for an existing file. | |
virtual | ~BucketFile () |
The destructor closes the file (if open). | |
virtual CountedPtr< ByteIO > | makeFilebufIO (uInt bufferSize) |
Make a (temporary) buffered IO object for this file. | |
MMapfdIO * | mappedFile () |
Get the mapped file object. | |
FilebufIO * | bufferedFile () |
Get the buffered file object. | |
virtual void | open () |
Open the file if not open yet. | |
virtual void | close () |
Close the file (if open). | |
virtual void | remove () |
Remove the file (and close it if needed). | |
virtual void | fsync () |
Fsync the file (i.e. | |
virtual void | setRW () |
Set the file to read/write access. | |
virtual const String & | name () const |
Get the file name. | |
Bool | isWritable () const |
Has the file logically been indicated as writable? | |
virtual uInt | read (void *buffer, uInt length) |
Read bytes from the file. | |
virtual uInt | write (const void *buffer, uInt length) |
Write bytes into the file. | |
virtual void | seek (Int64 offset) |
Seek in the file. | |
void | seek (Int offset) |
virtual Int64 | fileSize () const |
Get the (physical) size of the file. | |
Bool | isCached () const |
Is the file cached, mapped, or buffered? | |
Bool | isMapped () const |
Bool | isBuffered () const |
Private Member Functions | |
BucketFile (const BucketFile &) | |
Forbid copy constructor. | |
BucketFile & | operator= (const BucketFile &) |
Forbid assignment. | |
void | createMapBuf () |
Create the mapped or buffered file object. | |
void | deleteMapBuf () |
Delete the possible mapped or buffered file object. | |
Private Attributes | |
String | name_p |
The file name. | |
Bool | isWritable_p |
The (logical) writability of the file. | |
Bool | isMapped_p |
uInt | bufSize_p |
int | fd_p |
CountedPtr< ByteIO > | file_p |
The unbuffered file. | |
MMapfdIO * | mappedFile_p |
The optional mapped file. | |
FilebufIO * | bufferedFile_p |
The optional buffered file. | |
MultiFileBase * | mfile_p |
The possibly used MultiFileBase. |
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.
// Create the file for the given storage manager. BucketFile file ("file.name"); // Open the file and write into it. file.open(); file.write (someBuffer, someLength); // Get the length of the file. uInt size = file.fileSize();
Definition at line 107 of file BucketFile.h.
casacore::BucketFile::BucketFile | ( | const String & | fileName, | |
uInt | bufSizeFile = 0 , |
|||
Bool | mappedFile = False , |
|||
MultiFileBase * | mfile = 0 | |||
) | [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 casacore::BucketFile::~BucketFile | ( | ) | [virtual] |
The destructor closes the file (if open).
casacore::BucketFile::BucketFile | ( | const BucketFile & | ) | [private] |
Forbid copy constructor.
FilebufIO* casacore::BucketFile::bufferedFile | ( | ) | [inline] |
Get the buffered file object.
Definition at line 142 of file BucketFile.h.
References bufferedFile_p.
virtual void casacore::BucketFile::close | ( | ) | [virtual] |
Close the file (if open).
void casacore::BucketFile::createMapBuf | ( | ) | [private] |
Create the mapped or buffered file object.
void casacore::BucketFile::deleteMapBuf | ( | ) | [private] |
Delete the possible mapped or buffered file object.
virtual Int64 casacore::BucketFile::fileSize | ( | ) | const [virtual] |
virtual void casacore::BucketFile::fsync | ( | ) | [virtual] |
Fsync the file (i.e.
force the data to be physically written).
Bool casacore::BucketFile::isBuffered | ( | ) | const [inline] |
Definition at line 235 of file BucketFile.h.
References bufSize_p.
Bool casacore::BucketFile::isCached | ( | ) | const [inline] |
Is the file cached, mapped, or buffered?
Definition at line 231 of file BucketFile.h.
References bufSize_p, and isMapped_p.
Bool casacore::BucketFile::isMapped | ( | ) | const [inline] |
Definition at line 233 of file BucketFile.h.
References isMapped_p.
Bool casacore::BucketFile::isWritable | ( | ) | const [inline] |
Has the file logically been indicated as writable?
Definition at line 225 of file BucketFile.h.
References isWritable_p.
virtual CountedPtr<ByteIO> casacore::BucketFile::makeFilebufIO | ( | uInt | bufferSize | ) | [virtual] |
MMapfdIO* casacore::BucketFile::mappedFile | ( | ) | [inline] |
const String & casacore::BucketFile::name | ( | ) | const [inline, virtual] |
virtual void casacore::BucketFile::open | ( | ) | [virtual] |
Open the file if not open yet.
Referenced by casacore::TSMFile::open().
BucketFile& casacore::BucketFile::operator= | ( | const BucketFile & | ) | [private] |
Forbid assignment.
Read bytes from the file.
virtual void casacore::BucketFile::remove | ( | ) | [virtual] |
Remove the file (and close it if needed).
void casacore::BucketFile::seek | ( | Int | offset | ) | [inline] |
Definition at line 228 of file BucketFile.h.
References seek().
virtual void casacore::BucketFile::seek | ( | Int64 | offset | ) | [virtual] |
virtual void casacore::BucketFile::setRW | ( | ) | [virtual] |
Write bytes into the file.
FilebufIO* casacore::BucketFile::bufferedFile_p [private] |
The optional buffered file.
Definition at line 203 of file BucketFile.h.
Referenced by bufferedFile().
uInt casacore::BucketFile::bufSize_p [private] |
Definition at line 196 of file BucketFile.h.
Referenced by isBuffered(), and isCached().
int casacore::BucketFile::fd_p [private] |
Definition at line 197 of file BucketFile.h.
CountedPtr<ByteIO> casacore::BucketFile::file_p [private] |
The unbuffered file.
Definition at line 199 of file BucketFile.h.
Bool casacore::BucketFile::isMapped_p [private] |
Definition at line 195 of file BucketFile.h.
Referenced by isCached(), and isMapped().
Bool casacore::BucketFile::isWritable_p [private] |
The (logical) writability of the file.
Definition at line 194 of file BucketFile.h.
Referenced by isWritable().
MMapfdIO* casacore::BucketFile::mappedFile_p [private] |
MultiFileBase* casacore::BucketFile::mfile_p [private] |
The possibly used MultiFileBase.
Definition at line 205 of file BucketFile.h.
String casacore::BucketFile::name_p [private] |