Block File Access. More...

#include <rblockfileaccess.h>

Collaboration diagram for RBlockFileAccess:
[legend]

Public Member Functions

 RBlockFileAccess (RBlockFile *file)
 
 RBlockFileAccess (RBlockFile *file, size_t blockid, size_t pos=0)
 
 RBlockFileAccess (RBlockFile &file)
 
 RBlockFileAccess (RBlockFile &file, size_t blockid, size_t pos=0)
 
void ReadLock (void)
 
void ReadUnLock (void)
 
void WriteLock (void)
 
void WriteUnLock (void)
 
 ~RBlockFileAccess (void)
 

Private Attributes

RBlockFileFile
 
size_t BlockId
 
RBlockFileDataBlock
 
size_t CurrentPos
 
char * CurrentData
 
bool Lock
 

Detailed Description

Block File Access.

The RBlockFileAccess class provides an access to a given block file to read and write data in a particular bloc.

When it is necessary to ensure the coherence of a serie of reads or writes (for example to store data stored in multiple variables), we must first lock the access in read or write mode. Don't forget to unlock at the end of the reads and writes!

Warning
While the RBlockFileAccess allows a multithread access to a block file, it is itself not reentrant.
See also
RBlockFile

Constructor & Destructor Documentation

Constructor of an access.

Parameters
fileFile to access to.
RBlockFileAccess ( RBlockFile file,
size_t  blockid,
size_t  pos = 0 
)

Constructor of an access for a given block and at a given position.

Parameters
fileFile to access to.
blockidIdentifier of the block to access.
posPosition in the block.

Constructor of an access.

Parameters
fileFile to access to.
RBlockFileAccess ( RBlockFile file,
size_t  blockid,
size_t  pos = 0 
)

Constructor of an access for a given block and at a given position.

Parameters
fileFile to access to.
blockidIdentifier of the block to access.
posPosition in the block.
~RBlockFileAccess ( void  )

Destructor.

Member Function Documentation

void ReadLock ( void  )

Read locking.

void ReadUnLock ( void  )

Read unlocking.

void WriteLock ( void  )

Write locking.

void WriteUnLock ( void  )

Write unlocking.

Field Documentation

RBlockFile* File
private

Block file to access to.

size_t BlockId
private

Block identifier.

RBlockFileData* Block
private

Pointer to the data block. Can be null if the block is not in memory anymore.

size_t CurrentPos
private

Current position in the data block.

char* CurrentData
private

Pointer to the current data block.

bool Lock
private

Is the access currently in lock mode ?