casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Private Attributes
casa::BucketFile Class Reference

File object for the bucket cache. More...

#include <BucketFile.h>

List of all members.

Public Member Functions

 BucketFile (const String &fileName, uInt bufSizeFile=0, Bool mappedFile=False)
 Create a BucketFile object for a new file.
 BucketFile (const String &fileName, Bool writable, uInt bufSizeFile=0, Bool mappedFile=False)
 Create a BucketFile object for an existing file.
 ~BucketFile ()
 The destructor closes the file (if open).
MMapfdIOmappedFile ()
 Get the mapped file object.
LargeFilebufIObufferedFile ()
 Get the buffered file object.
void open ()
 Open the file if not open yet.
void close ()
 Close the file (if open).
void remove ()
 Remove the file (and close it if needed).
void fsync ()
 Fsync the file (i.e.
void setRW ()
 Set the file to read/write access.
const Stringname () const
 Get the file name.
Bool isWritable () const
 Has the file logically been indicated as writable?
uInt read (void *buffer, uInt length) const
 Read bytes from the file.
uInt write (const void *buffer, uInt length)
 Write bytes into the file.
void seek (Int64 offset) const
 Seek in the file.
void seek (Int offset) const
Int64 fileSize () const
 Get the (physical) size of the file.
int fd ()
 Get the file descriptor of the internal 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.
BucketFileoperator= (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
 
     

Bool isWritable_p
 The (logical) writability of the file.
Bool isMapped_p
uInt bufSize_p
int fd_p
 The file descriptor.
MMapfdIOmappedFile_p
 The optional mapped file.
LargeFilebufIObufferedFile_p
 The optional buffered file.

Detailed Description

File object for the bucket cache.

Intended use:

Internal

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Etymology

BucketFile represents a data file for the BucketCache class.

Synopsis

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.

Underneath it uses a file descriptor to access the file. It is straightforward to replace this by a mapped file or a filebuf.

Motivation

Encapsulate the file creation and access into a single class to hide the file IO details.

Example

        // 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();

To Do

Definition at line 97 of file BucketFile.h.


Constructor & Destructor Documentation

casa::BucketFile::BucketFile ( const String fileName,
uInt  bufSizeFile = 0,
Bool  mappedFile = False 
) [explicit]

Create a BucketFile object for a new file.

The file with the given name will be created. It can be indicated if a MMapfdIO and/or LargeFilebufIO object must be created for the file.

casa::BucketFile::BucketFile ( const String fileName,
Bool  writable,
uInt  bufSizeFile = 0,
Bool  mappedFile = False 
)

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 LargeFilebufIO object must be created for the file.

The destructor closes the file (if open).

casa::BucketFile::BucketFile ( const BucketFile ) [private]

Forbid copy constructor.


Member Function Documentation

Get the buffered file object.

Definition at line 123 of file BucketFile.h.

References bufferedFile_p.

Close the file (if open).

void casa::BucketFile::createMapBuf ( ) [private]

Create the mapped or buffered file object.

void casa::BucketFile::deleteMapBuf ( ) [private]

Delete the possible mapped or buffered file object.

int casa::BucketFile::fd ( ) [inline]

Get the file descriptor of the internal file.

Definition at line 209 of file BucketFile.h.

References fd_p.

Get the (physical) size of the file.

This is doing a seek and sets the file pointer to end-of-file.

Fsync the file (i.e.

force the data to be physically written).

Bool casa::BucketFile::isBuffered ( ) const [inline]

Definition at line 219 of file BucketFile.h.

References bufSize_p.

Bool casa::BucketFile::isCached ( ) const [inline]

Is the file cached, mapped, or buffered?

Definition at line 215 of file BucketFile.h.

References bufSize_p, and isMapped_p.

Bool casa::BucketFile::isMapped ( ) const [inline]

Definition at line 217 of file BucketFile.h.

References isMapped_p.

Bool casa::BucketFile::isWritable ( ) const [inline]

Has the file logically been indicated as writable?

Definition at line 206 of file BucketFile.h.

References isWritable_p.

Get the mapped file object.

Definition at line 119 of file BucketFile.h.

References mappedFile_p.

const String & casa::BucketFile::name ( ) const [inline]

Get the file name.

Definition at line 203 of file BucketFile.h.

References name_p.

Open the file if not open yet.

Referenced by casa::TSMFile::open().

BucketFile& casa::BucketFile::operator= ( const BucketFile ) [private]

Forbid assignment.

uInt casa::BucketFile::read ( void *  buffer,
uInt  length 
) const

Read bytes from the file.

Remove the file (and close it if needed).

void casa::BucketFile::seek ( Int64  offset) const

Seek in the file.

Referenced by seek().

void casa::BucketFile::seek ( Int  offset) const [inline]

Definition at line 212 of file BucketFile.h.

References seek().

Set the file to read/write access.

It is reopened if not writable. It does nothing if the file is already writable.

uInt casa::BucketFile::write ( const void *  buffer,
uInt  length 
)

Write bytes into the file.


Member Data Documentation

The optional buffered file.

Definition at line 186 of file BucketFile.h.

Referenced by bufferedFile().

Definition at line 180 of file BucketFile.h.

Referenced by isBuffered(), and isCached().

int casa::BucketFile::fd_p [private]

The file descriptor.

Definition at line 182 of file BucketFile.h.

Referenced by fd().

Definition at line 179 of file BucketFile.h.

Referenced by isCached(), and isMapped().

The (logical) writability of the file.

Definition at line 178 of file BucketFile.h.

Referenced by isWritable().

The optional mapped file.

Definition at line 184 of file BucketFile.h.

Referenced by mappedFile().

     

The file name.

Definition at line 176 of file BucketFile.h.

Referenced by name().


The documentation for this class was generated from the following file: