Google

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

SharedFile Class Reference

This class defines a database I/O file service that can be shared by multiple processes. This class defines a database I/O file service that can be shared by multiple processes. More...

#include <file.h>

Inheritance diagram for SharedFile:

RandomFile Mutex List of all members.

Public Methods

 SharedFile (const char *path)
 Open or create a new database file. More...

 SharedFile (const SharedFile &file)
 Create a shared file as a duplicate of an existing shared file. More...

 ~SharedFile ()
 Close and finish a database file.

fileerror_t Restart (void)
 Restart an existing database; close and re-open. More...

fileerror_t Fetch (caddr_t address = NULL, size_t length = 0, off_t position = - 1)
 Lock and Fetch a portion of the file into physical memory. More...

fileerror_t Update (caddr_t address = NULL, size_t length = 0, off_t position = -1)
 Update a portion of a file from physical memory. More...

fileerror_t Clear (size_t length = 0, off_t pos = -1)
 Clear a lock held from a previous fetch operation without updating. More...

fileerror_t Append (caddr_t address = NULL, size_t length = 0)
 Add new data to the end of the file. More...

off_t getPosition (void)
 Fetch the current file position marker for this thread. More...

bool operator++ (void)
bool operator-- (void)

Detailed Description

This class defines a database I/O file service that can be shared by multiple processes. This class defines a database I/O file service that can be shared by multiple processes.

Each thread should access a dup of the database object, and mutex locks can be used to preserve transaction integrety if multiple threads are used.

SharedFile is used when a database may be shared between multiple processes. SharedFile automatically applies low level byte-range "file locks", and provides an interface to fetch and release byte-range locked portions of a file.

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


Constructor & Destructor Documentation

SharedFile::SharedFile ( const char * path )
 

Open or create a new database file.

You should also use Initial.

Parameters:
pathname   of database to open.
file   access mode.

SharedFile::SharedFile ( const SharedFile & file )
 

Create a shared file as a duplicate of an existing shared file.

Parameters:
original   file.

SharedFile::~SharedFile ( )
 

Close and finish a database file.


Member Function Documentation

fileerror_t SharedFile::Append ( caddr_t address = NULL,
size_t length = 0 )
 

Add new data to the end of the file.

Locks file during append.

Parameters:
address   to use, or NULL if same as last I/O.
length   to use, or 0 if same as last I/O.

fileerror_t SharedFile::Clear ( size_t length = 0,
off_t pos = -1 )
 

Clear a lock held from a previous fetch operation without updating.

Returns:
FILE_SUCCESS on success.
Parameters:
length   to use, or 0 if same as last I/O.
file   position to use or -1 if same as last I/O.

fileerror_t SharedFile::Fetch ( caddr_t address = NULL,
size_t length = 0,
off_t position = - 1 )
 

Lock and Fetch a portion of the file into physical memory.

This can use state information to fetch the current record multiple times.

Returns:
FILE_SUCCESS on success.
Parameters:
address   to use, or NULL if same as last I/O.
length   to use, or 0 if same as last I/O.
file   position to use -1 if same as last I/O.

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

Restart an existing database; close and re-open.

Returns:
FILE_SUCCESS if successful.

Reimplemented from RandomFile.

fileerror_t SharedFile::Update ( caddr_t address = NULL,
size_t length = 0,
off_t position = -1 )
 

Update a portion of a file from physical memory.

This can use state information to commit the last read record. The current lock is also cleared.

Returns:
FILE_SUCCESS on success.
Parameters:
address   to use, or NULL if same as last I/O.
length   to use, or 0 if same as last I/O.
file   position to use or -1 if same as last I/O.

off_t SharedFile::getPosition ( void )
 

Fetch the current file position marker for this thread.

Returns:
file position offset.

bool SharedFile::operator++ ( void )
 

bool SharedFile::operator-- ( void )
 


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