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

  1. #ifndef __RWVREF_H__
  2. #define __RWVREF_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWVirtualRef: Reference counted virtual array reference.
  7.  *
  8.  * $Header:   E:/vcs/rw/vref.h_v   1.0   11 Mar 1992 14:10:00   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/vref.h_v  $
  22.  * 
  23.  *    Rev 1.0   11 Mar 1992 14:10:00   KEFFER
  24.  * Initial revision.
  25.  */
  26.  
  27. #ifndef __RWREF_H__
  28. #  include "rw/ref.h"
  29. #endif
  30. #include "rw/vpage.h"
  31. STARTWRAP
  32. #include <stdlib.h>
  33. ENDWRAP
  34.  
  35. typedef unsigned RWPageSlot;
  36.  
  37. class RWExport RWVirtualRef : public RWReference {
  38.  
  39. public:
  40.  
  41.   RWVirtualRef(long length, size_t elementSize, RWVirtualPageHeap* h);
  42.   RWVirtualRef(const RWVirtualRef&);    // Deep copy
  43.   ~RWVirtualRef();
  44.  
  45.   long            capacity() const    {return _nSlots*_nPerPage;}
  46.   RWVirtualPageHeap*    heap() const        {return _myHeap;}
  47.   long            length() const        {return _length;}
  48.   void            slide(long start, long delta);
  49.   void            setSlice(long start1, long extent1,
  50.                 RWVirtualRef& v, long start2, long extent2);
  51.   void            reshape(long newLength);
  52.  
  53.   // The following three functions are formally intended to be
  54.   // protected, but a bug in Borland C++ requires that they be public.
  55. #ifdef __TURBOC__
  56. public:
  57. #else
  58. protected:
  59. #endif
  60.  
  61.   void            findLocation(long, RWPageSlot&, unsigned&) const;
  62.   void*            lock(RWPageSlot p)    {return _myHeap->lock(_handles[p]);}
  63.   void            unlock(RWPageSlot p)    {_myHeap->unlock(_handles[p]);}
  64.  
  65. protected:
  66.  
  67.   // Neither augmentLeft nor augmentRight change the vector length.
  68.   // They just add capacity to one side or the other.
  69.   void            augmentLeft(long);    // Add capacity on left
  70.   void            augmentRight(long);    // Add capacity on right
  71.   unsigned        pages()            {return _nSlots;}
  72.   unsigned        pageSize()        {return _myHeap->pageSize();}
  73.   void            dirty(RWPageSlot p)    {_myHeap->dirty(_handles[p]);}
  74.  
  75.   // Supplied by specializing class:
  76.   virtual void        conformalCopy(long start1, RWVirtualRef& v2, long start2, long N) = 0;
  77.  
  78. protected:
  79.  
  80.   // Protected data.
  81.   // Note that the length of the vector _handles is _nSlots.
  82.  
  83.   long            _length;    // Total number of elements
  84.   long            _baseIndex;    // Start of actual data
  85.   unsigned        _nPerPage;    // Number of elements per page
  86.   RWVirtualPageHeap*    _myHeap;    // The heap I'm getting my pages from
  87.   RWHandle*        _handles;    // Array of handles
  88.   RWPageSlot        _nSlots;    // Length of _handles.
  89.  
  90. };
  91.  
  92. pragma pop_align_members();
  93. #endif    /* __RWVREF_H__ */
  94.