class SharedFile

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

Full nameost::SharedFile
Definition#include <file.h>
Inheritsost::RandomFile [public ], ost::RandomFile [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

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.

 SharedFile (const char *path)

SharedFile

Open or create a new database file. You should also use Initial.

Parameters:
pathnameof database to open.
fileaccess mode.

 SharedFile (const SharedFile &file)

SharedFile

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

Parameters:
originalfile.

 ~SharedFile ()

~SharedFile

[virtual]

Close and finish a database file.

fileerror_t  Restart (void)

Restart

Restart an existing database; close and re-open.

Returns: FILE_SUCCESS if successful.

Reimplemented from RandomFile.

fileerror_t  Fetch (char * address = NULL, ccxx_size_t length = 0, off_t position = -1)

Fetch

Lock and Fetch a portion of the file into physical memory. This can use state information to fetch the current record multiple times.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.
fileposition to use -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Update (char * address = NULL, ccxx_size_t length = 0, off_t position = -1)

Update

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.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.
fileposition to use or -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Clear (ccxx_size_t length = 0, off_t pos = -1)

Clear

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

Parameters:
lengthto use, or 0 if same as last I/O.
fileposition to use or -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Append (char * address = NULL, ccxx_size_t length = 0)

Append

Add new data to the end of the file. Locks file during append.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.

off_t  getPosition (void)

getPosition

Fetch the current file position marker for this thread.

Returns: file position offset.

bool  operator++ (void)

operator++

bool  operator-- (void)

operator--

 SharedFile (const char *path)

SharedFile

Open or create a new database file. You should also use Initial.

Parameters:
pathnameof database to open.
fileaccess mode.

 SharedFile (const SharedFile &file)

SharedFile

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

Parameters:
originalfile.

 ~SharedFile ()

~SharedFile

[virtual]

Close and finish a database file.

fileerror_t  Restart (void)

Restart

Restart an existing database; close and re-open.

Returns: FILE_SUCCESS if successful.

Reimplemented from RandomFile.

fileerror_t  Fetch (char * address = NULL, ccxx_size_t length = 0, off_t position = -1)

Fetch

Lock and Fetch a portion of the file into physical memory. This can use state information to fetch the current record multiple times.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.
fileposition to use -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Update (char * address = NULL, ccxx_size_t length = 0, off_t position = -1)

Update

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.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.
fileposition to use or -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Clear (ccxx_size_t length = 0, off_t pos = -1)

Clear

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

Parameters:
lengthto use, or 0 if same as last I/O.
fileposition to use or -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Append (char * address = NULL, ccxx_size_t length = 0)

Append

Add new data to the end of the file. Locks file during append.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.

off_t  getPosition (void)

getPosition

Fetch the current file position marker for this thread.

Returns: file position offset.

bool  operator++ (void)

operator++

bool  operator-- (void)

operator--