home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / 01 < prev    next >
Encoding:
Text File  |  1992-06-07  |  2.1 KB  |  75 lines

  1. #ifndef __RWDISKPAGE_H__
  2. #define __RWDISKPAGE_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWDiskPageHeap: Specializing buffered page heap that swaps pages out to disk.
  7.  *
  8.  * $Header:   E:/vcs/rw/diskpage.h_v   1.0   11 Mar 1992 14:09:58   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave Software, Inc.
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  *
  16.  * Copyright (C) 1992. This software is subject to copyright 
  17.  * protection under the laws of the United States and other countries.
  18.  *
  19.  ***************************************************************************
  20.  *
  21.  * $Log:   E:/vcs/rw/diskpage.h_v  $
  22.  * 
  23.  *    Rev 1.0   11 Mar 1992 14:09:58   KEFFER
  24.  * Initial revision.
  25.  */
  26.  
  27. #include "rw/bufpage.h"
  28. #include "rw/bitvec.h"
  29. STARTWRAP
  30. #include <stdio.h>
  31. ENDWRAP
  32.  
  33. class RWExport RWDiskPageHeap : public RWBufferedPageHeap {
  34.  
  35. public:
  36.  
  37.   RWDiskPageHeap(const char* filename=0, unsigned nbufs=10, unsigned pgsize=512);
  38.   virtual        ~RWDiskPageHeap();
  39.  
  40.   RWBoolean        isValid() const {return _tempfp!=0;}
  41.  
  42.   // Inherited from RWPageBuffer:
  43.   virtual RWHandle    allocate();
  44.   virtual void        deallocate(RWHandle);
  45.  
  46. protected:
  47.  
  48.   enum HandleStatus { NotUsed, NoSwapSpace, HasSwapSpace };
  49.  
  50.   RWBoolean        allocateDiskPage(RWHandle);
  51.   RWBoolean        handleValid(RWHandle);
  52.   RWoffset        offsetOfHandle(RWHandle);
  53.   void            resize(unsigned);
  54.  
  55.   // Inherited from RWBufferedPageHeap:
  56.   virtual RWBoolean    swapIn(RWHandle, void*);
  57.   virtual RWBoolean    swapOut(RWHandle, void*);
  58.  
  59. private:
  60.  
  61.   static const unsigned        _initialPages;
  62.   static const unsigned        _initialHandles;
  63.   static const unsigned        _pageIncrement;
  64.   static const unsigned        _handleIncrement;
  65.   RWBitVec            _freePageMap;    // Bit flags for free disk pages
  66.   unsigned*            _handleMap;    // Array that maps from handle number to disk page
  67.   HandleStatus*            _handleStatus;    // Status of each slot in _handleMap
  68.   unsigned            _nHandles;    // Length of _handleMap and _handleStatus
  69.   FILE*                _tempfp;
  70.  
  71. };
  72.  
  73. pragma pop_align_members();
  74. #endif    /* __RWDISKPAGE_H__ */
  75.