Google

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

RandomFile Class Reference

The purpose of this class is to define a base class for low level random file access that is portable between Win32 and Posix systems. Portable random disk file access. More...

#include <file.h>

Inheritance diagram for RandomFile:

Mutex MappedFile SharedFile ThreadFile List of all members.

Public Methods

virtual ~RandomFile ()
 Destroy a random access file or it's derived class.

bool Initial (void)
 This method should be called right after a RandomFile derived object has been created. More...

off_t getCapacity (void)
 Get current file capacity. More...

virtual fileerror_t Restart (void)
 This method is commonly used to close and re-open an existing database. More...

fileerror_t getErrorNumber (void)
 Return current error id. More...

char* getErrorString (void)
 Return current error string. More...

bool operator! (void)

Protected Methods

 RandomFile ()
 Create an unopened random access file.

 RandomFile (const RandomFile &rf)
 Default copy constructor.

fileerror_t Error (fileerror_t errid, char *errstr = NULL)
 Post an error event. More...

fileerror_t Error (char *errstr)
 Post an extended string error message. More...

void setError (bool enable)
 Used to enable or disable throwing of exceptions on errors. More...

fileerror_t setCompletion (filecomplete_t mode)
 Used to set file completion modes. More...

void setTemporary (bool enable)
 Used to set the temporary attribute for the file. More...

virtual fileattr_t Initialize (void)
 This method is used to initialize a newly created file as indicated by the "initial" flag. More...

void Final (void)
 Close the file.


Protected Attributes

int fd
fileaccess_t access
char* pathname
struct {
   unsigned   count
   bool   thrown
   bool   initial
   bool   immediate
   bool   temp
flags

Detailed Description

The purpose of this class is to define a base class for low level random file access that is portable between Win32 and Posix systems. Portable random disk file access.

This class is a foundation both for optimized thread shared and traditional locked file access that is commonly used to build database services, rather than the standard C++ streaming file classes.

Author(s):
David Sugar <dyfet@ostel.com>


Constructor & Destructor Documentation

RandomFile::RandomFile ( ) [protected]
 

Create an unopened random access file.

RandomFile::RandomFile ( const RandomFile & rf ) [protected]
 

Default copy constructor.

RandomFile::~RandomFile ( ) [inline, virtual]
 

Destroy a random access file or it's derived class.


Member Function Documentation

fileerror_t RandomFile::Error ( char * errstr ) [inline, protected]
 

Post an extended string error message.

Returns:
FILE_EXTENDED_ERROR.
Parameters:
error   string.

fileerror_t RandomFile::Error ( fileerror_t errid,
char * errstr = NULL ) [protected]
 

Post an error event.

Returns:
error code.
Parameters:
error   code.
error   message string.

void RandomFile::Final ( void ) [protected]
 

Close the file.

bool RandomFile::Initial ( void )
 

This method should be called right after a RandomFile derived object has been created.

This method will invoke initialize if the object is newly created, and set file access permissions appropriately.

Returns:
true if file had to be initialized.

fileattr_t RandomFile::Initialize ( void ) [inline, protected, virtual]
 

This method is used to initialize a newly created file as indicated by the "initial" flag.

This method also returns the file access permissions that should be associated with the file. This method should never be called directly, but is instead used to impliment the "Initial" method. Typically one would use this to build an empty database shell when a previously empty database file is created.

Returns:
access, or FILE_ATTR_INVALID if should be removed.

fileerror_t RandomFile::Restart ( void ) [inline, virtual]
 

This method is commonly used to close and re-open an existing database.

This may be used when the database has been unlinked and an external process provides a new one to use.

Reimplemented in ThreadFile, and SharedFile.

off_t RandomFile::getCapacity ( void )
 

Get current file capacity.

Returns:
total file size.

fileerror_t RandomFile::getErrorNumber ( void ) [inline]
 

Return current error id.

Returns:
last error identifier set.

char * RandomFile::getErrorString ( void ) [inline]
 

Return current error string.

Returns:
last error string set.

bool RandomFile::operator! ( void )
 

fileerror_t RandomFile::setCompletion ( filecomplete_t mode ) [protected]
 

Used to set file completion modes.

Returns:
FILE_SUCCESS if okay.
Parameters:
completion   mode.

void RandomFile::setError ( bool enable ) [inline, protected]
 

Used to enable or disable throwing of exceptions on errors.

Parameters:
true   if errors will be thrown.

void RandomFile::setTemporary ( bool enable ) [inline, protected]
 

Used to set the temporary attribute for the file.

Temporary files are automatically deleted when closed.

Parameters:
true   for marking as temporary.


Member Data Documentation

fileaccess_t RandomFile::access [protected]
 

unsigned RandomFile::count [protected]
 

int RandomFile::fd [protected]
 

struct { ... } RandomFile::flags [protected]
 

bool RandomFile::immediate [protected]
 

bool RandomFile::initial [protected]
 

char * RandomFile::pathname [protected]
 

bool RandomFile::temp [protected]
 

bool RandomFile::thrown [protected]
 


The documentation for this class was generated from the following file:
Generated at Fri Mar 23 10:47:56 2001 for CommonC++ by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000