TAO_CosNotification  2.0.8
Public Member Functions | Private Member Functions | Private Attributes
TAO_Notify::Random_File Class Reference

A random file class. More...

#include <Random_File.h>

Inheritance diagram for TAO_Notify::Random_File:
Inheritance graph
[legend]
Collaboration diagram for TAO_Notify::Random_File:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Random_File ()
 The constructor.
 ~Random_File ()
 The destructor, which closes the open file.
bool open (const ACE_TCHAR *filename, size_t block_size=512)
 Open a file with default permissions.
size_t block_size () const
ACE_OFF_T size () const
 Return the current file size, in number of blocks.
bool write (const size_t block_number, void *buffer, bool atomic=false)
bool read (const size_t block_number, void *buffer)
 Read a block from our file.

Private Member Functions

bool seek (const size_t block_number)
 Seek to a given block number, used by reads and writes.
bool sync ()
 Synchronize the file to disk, used to implement atomic.

Private Attributes

size_t block_size_
TAO_SYNCH_MUTEX lock_

Detailed Description

A random file class.

Derived from ACE_FILE, this class provides access to a file of fixed-size blocks.


Constructor & Destructor Documentation

TAO_Notify::Random_File::Random_File ( )

The constructor.

TAO_Notify::Random_File::~Random_File ( )

The destructor, which closes the open file.


Member Function Documentation

size_t TAO_Notify::Random_File::block_size ( ) const

Accessor for the block size. Note signed size_t is used to be compatible with ACE_FILE.

bool TAO_Notify::Random_File::open ( const ACE_TCHAR filename,
size_t  block_size = 512 
)

Open a file with default permissions.

bool TAO_Notify::Random_File::read ( const size_t  block_number,
void *  buffer 
)

Read a block from our file.

bool TAO_Notify::Random_File::seek ( const size_t  block_number) [private]

Seek to a given block number, used by reads and writes.

ACE_OFF_T TAO_Notify::Random_File::size ( ) const

Return the current file size, in number of blocks.

bool TAO_Notify::Random_File::sync ( ) [private]

Synchronize the file to disk, used to implement atomic.

bool TAO_Notify::Random_File::write ( const size_t  block_number,
void *  buffer,
bool  atomic = false 
)

Write a block to our file, potentially as an "atomic" write. If the atomic argument is true, then the operating system's write-through cache for this file is flushed both before and after the write. The flush before ensures that any record pointers in this block will point to records that actually appear in the file. The flush after provides the caller with a guarantee that the data will appear in the file even if the system fails immediately after this method returns.


Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines