Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWCacheManager

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/cacheman.h>
RWFile f("file.dat");       // Construct a file
RWCacheManager(&f, 100);    // Cache 100 byte blocks to file.dat

Description

Class RWCacheManager caches fixed length blocks to and from an associated RWFile. The block size can be of any length and is set at construction time. The number of cached blocks can also be set at construction time.

Writes to the file may be deferred. Use member function flush() to have any pending writes performed.

Persistence

None

Example

#include <rw/cacheman.h>
#include <rw/rwfile.h>

struct Record {
  int i;
  float f;
  char str[15];
};
main(){
   RWoffset loc;
   RWFile file("file.dat");     // Construct a file

   // Construct a cache, using 20 slots for struct Record:
      RWCacheManager cache(&file, sizeof(Record), 20);

   Record r;
   // ...
   cache.write(loc, &r);
   // ...
   cache.read(loc, &r);
}

Public Constructor

RWCacheManager(RWFile* file, unsigned blocksz, 
               unsigned mxblks = 10);

Public Destructor

~RWCacheManager();

Public Member Functions

RWBoolean
flush();
void
invalidate();
RWBoolean
read(RWoffset locn, void* dat);
RWBoolean
write(RWoffset locn, void* dat);


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.