home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / io / dskbtree.h < prev    next >
C/C++ Source or Header  |  1995-04-08  |  3KB  |  96 lines

  1.  
  2.  
  3. #ifndef _dskbtree_h_ /* Thu Feb 24 15:01:49 1994 */
  4. #define _dskbtree_h_
  5.  
  6.  
  7.  
  8.  
  9.  
  10. /*
  11.  *
  12.  *          Copyright (C) 1994, M. A. Sridhar
  13.  *  
  14.  *
  15.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  16.  *     to copy, modify or distribute this software  as you see fit,
  17.  *     and to use  it  for  any  purpose, provided   this copyright
  18.  *     notice and the following   disclaimer are included  with all
  19.  *     copies.
  20.  *
  21.  *                        DISCLAIMER
  22.  *
  23.  *     The author makes no warranties, either expressed or implied,
  24.  *     with respect  to  this  software, its  quality, performance,
  25.  *     merchantability, or fitness for any particular purpose. This
  26.  *     software is distributed  AS IS.  The  user of this  software
  27.  *     assumes all risks  as to its quality  and performance. In no
  28.  *     event shall the author be liable for any direct, indirect or
  29.  *     consequential damages, even if the  author has been  advised
  30.  *     as to the possibility of such damages.
  31.  *
  32.  */
  33.  
  34. // The DiskBTree owns its contained objects, unlike other containers that
  35. // use reference semantics. A client of this object is required to ``hand
  36. // over'' the stored objects to the DiskBTree, which then takes care of
  37. // destroying it.
  38. //
  39. // An object that needs to be stored in a B-tree on disk must implement
  40. // the virtual ReadFrom and WriteTo methods of CL_Object. The
  41. // ObjectBuilder passed to the constructor of the DiskBTree must
  42. // reconstruct an instance of the B-tree item and return it.
  43.  
  44.  
  45. #if defined(__GNUC__)
  46. #pragma interface
  47. #endif
  48.  
  49. #include "base/stream.h"
  50. #include "base/tbtree.h"
  51. #include "base/builder.h"
  52. #include "io/bytstore.h"
  53.  
  54. class CL_EXPORT CL_DiskBTreeNodeSpace;
  55.  
  56. class CL_EXPORT CL_DiskBTree: public  CL_BTree<CL_ObjectPtr> {
  57.  
  58. public:
  59.     CL_DiskBTree (CL_ByteStringStore& store,
  60.                   CL_ObjectBuilder* f, short order, bool create = FALSE);
  61.     // The parameter f is an ObjectBuilder that can reconstruct an item of
  62.     // the B-tree from its passive representation in a Stream, and return
  63.     // this item (see {\tt builder.h}). The (memory for the) object f is
  64.     // assumed to be owned by the user of this tree, and is not tampered
  65.     // with by this tree.
  66.     //
  67.     // The present implementation of the DiskBTreeNodeSpace uses no
  68.     // caching; it simply maps nodes to byte strings and stores them in
  69.     // the ByteStringStore.
  70.  
  71.     
  72.     ~CL_DiskBTree();
  73.     // Destructor.
  74.     
  75.     // ---------------------- Basic methods ----------------------------
  76.  
  77.  
  78.     virtual const char* ClassName () const { return "CL_DiskBTree";};
  79.  
  80.     // --------------------- End public protocol -----------------------
  81. protected:
  82.     CL_Comparator<CL_ObjectPtr> _comparator;
  83.     CL_ByteStringStore&         _store;
  84.     CL_DiskBTreeNodeSpace*      _diskNodeSpace;
  85.     CL_ObjectBuilder*           _builder;
  86.  
  87.     friend CL_DiskBTreeNodeSpace;
  88.  
  89. };
  90.  
  91.  
  92.  
  93.  
  94.  
  95. #endif /* _dskbtree_h_ */
  96.