Access free portions of a file in blocks. More...
#include <QueueAccessFile.h>
Public Member Functions | |
QueueAccessFile (const char *filename, std::ios::openmode mode) | |
Initialise the class with a file name and access mode. | |
QueueAccessFile (const char *filename, std::ios::openmode mode, FileBlockQueue *sQueue, FileBlockQueue *uQueue) | |
Initialise the class with file details and access queues sQueue showing free blocks and uQueue containing used blocks. | |
QueueAccessFile (const char *filename, std::ios::openmode mode, FileBlockQueue *uQueue) | |
Initialise the class with file details and access queue uQueue containing used blocks. | |
virtual void | nextFileBlock (char *buffer, int blockSize)=0 |
Process the next file block using the given buffer and block size. | |
void | addQueue (FileBlockQueue *fQueue) |
Add the contents of fQueue to the spare file block queue. | |
void | addFreeBlock (FILE_POS_TYPE position) |
Add the file position to the back of the spare queue. | |
FileBlockQueue * | usedBlocks (void) |
Return the number of used blocks in the file. | |
FILE_POS_TYPE | usedFileBytes (void) |
Return the number of used bytes in the file. | |
void | segmentAccesses (long segment, FILE_POS_TYPE start, FILE_POS_TYPE end) |
Add the continous file region from start to end to the spare queue in segment sized blocks. | |
void | segmentAccesses (long segment, FILE_POS_TYPE start) |
Add the continous file region from start to the end of the file to the spare queue in segment sized blocks. | |
Protected Attributes | |
FileBlockQueue * | spareQueue |
The spare quere containing the free blocks. | |
FileBlockQueue * | usedQueue |
The used queue containing the processed blocks. | |
FILE_POS_TYPE | usedBytes |
The number of used bytes in the file. |
Access free portions of a file in blocks.
This class is used to access a file using FileIO in blocks. Queues are maintained to keep track of which parts of the file are available for processing and which parts have been processed. By doing this, multiple QueueAccessFiles can have access to the same file as long as they all report to each other which blocks are availble and which are not.