RWBufferedPageHeap(3C++) RWBufferedPageHeap(3C++)
NameRWBufferedPageHeap - Rogue Wave library class
Synopsis
#include <rw/bufpage.h>
(Abstract base class )
Description
This is an abstract base class that represents an abstract page heap
buffered through a set of memory buffers. It inherits from the abstract
base class RWVirtualPageHeap, which represents an abstract page heap.
RWBufferedPageHeap will supply and maintain a set of memory buffers.
Specializing classes should supply the actual physical mechanism to swap
pages in and out of these buffers by supplying definitions for the pure
virtual functions swapIn(RWHandle, void*) and swapOut(RWHandle, void*).
The specializing class should also supply appropriate definitions for the
public functions allocate() and deallocate(RWHandle). For a sample
implementation of a specializing class, see class RWDiskPageHeap.
Persistence
None
Public Constructor
RWBufferedPageHeap(unsigned pgsize, unsigned nbufs=10);
Constructs a buffered page heap with page size pgsize. The number of
buffers (each of size pgsize) that will be allocated on the heap will be
nbufs. If there is insufficient memory to satisfy the request, then the
state of the resultant object as returned by member function isValid()
will be FALSE, otherwise, TRUE.
Protected Member Functions
virtual RWBoolean
swapIn(RWHandle h, void* buf) = 0;
virtual RWBoolean
swapOut(RWHandle, h void* buf) = 0;
It is the responsibility of the specializing class to supply definitions
for these two pure virtual functions. Function swapOut() should copy the
page with handle h from the buffer pointed to by buf to the swapping
medium. Function swapIn() should copy the page with handle h into the
Page 1
RWBufferedPageHeap(3C++) RWBufferedPageHeap(3C++)
buffer pointed to by buf.
Public Member Functions
virtual RWHandle
allocate() = 0;
It is the responsibility of the specializing class to supply a definition
for this pure virtual function. The specializing class should allocate a
page and return a unique handle for it. It should return zero if it
cannot satisfy the request. The size of the page is set by the
constructor.
virtual
~RWBufferedPageHeap();
Deallocates all internal buffers.
RWBoolean
isValid();
Returns TRUE if self is in a valid state. A possible reason why the
object might not be valid is insufficient memory to allocate the internal
buffers.
virtual void
deallocate(RWHandle h);
Redefined from class RWVirtualPageHeap. It is never an error to call
this function with argument zero. Even though this is not a pure virtual
function, it is the responsibility of the specializing class to supply an
appropriate definition for this function. All this definition does is
release any buffers associated with the handle h. Just as the actual
page allocation is done by the specializing class through virtual
function allocate(), so must the actual deallocation be done by
overriding deallocate().
virtual void
dirty(RWHandle h);
Redefined from class RWVirtualPageHeap.
virtual void*
lock(RWHandle h);
Redefined from class RWVirtualPageHeap.
Page 2
RWBufferedPageHeap(3C++) RWBufferedPageHeap(3C++)
virtual void
unlock(RWHandle h);
Redefined from class RWVirtualPageHeap.
Page 3