home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbdatabs / cache.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-03-14  |  2.6 KB  |  64 lines

  1. // ------------------------------- //
  2. // -------- Start of File -------- //
  3. // ------------------------------- //
  4. // ----------------------------------------------------------- // 
  5. // C++ Source Code File Name: cache.cpp 
  6. // Compiler Used: MSVC40, DJGPP 2.7.2.1, GCC 2.7.2.1, HP CPP 10.24
  7. // Produced By: Doug Gaer  
  8. // File Creation Date: 02/07/1997  
  9. // Date Last Modified: 03/15/1999
  10. // Copyright (c) 1997 Douglas M. Gaer
  11. // ----------------------------------------------------------- // 
  12. // ------------- Program Description and Details ------------- // 
  13. // ----------------------------------------------------------- // 
  14. /*
  15. The VBD C++ classes are copyright (c) 1997, by Douglas M. Gaer.
  16. All those who put this code or its derivatives in a commercial
  17. product MUST mention this copyright in their documentation for
  18. users of the products in which this code or its derivative
  19. classes are used. Otherwise, you have the freedom to redistribute
  20. verbatim copies of this source code, adapt it to your specific
  21. needs, or improve the code and release your improvements to the
  22. public provided that the modified files carry prominent notices
  23. stating that you changed the files and the date of any change.
  24.  
  25. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
  26. THE ENTIRE RISK OF THE QUALITY AND PERFORMANCE OF THIS SOFTWARE
  27. IS WITH YOU. SHOULD ANY ELEMENT OF THIS SOFTWARE PROVE DEFECTIVE,
  28. YOU WILL ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
  29. CORRECTION.
  30.  
  31. The Cache class is derived from the Cacheb class. It adds two
  32. functions to handle the allocation and de-allocation of buckets.
  33. The cache is used to handle requests for file-based objects. The
  34. cache must determine whether an object is already loaded. If the
  35. object is not loaded the cache reserves a bucket and loads the
  36. object into memory. This cache design uses cache pointers to
  37. reference cache buckets directly, with each cache pointer being
  38. initialized after the bucket is reserved. The least-recently
  39. reserved cache bucket is overwritten when the cache fills up.
  40. */
  41. // ----------------------------------------------------------- //   
  42.  
  43. #ifdef __NOT_USING_TEMPLATE_CLASS__
  44. #include "cache.h"
  45.  
  46. Cache::Cache(int n) : Cacheb(buckets = new Bucket[n], n, sizeof(Bucket))
  47. // Buckets are stored in an array and organized as a circular doubly-linked
  48. // list by the Cacheb class.
  49. {
  50.  
  51. }
  52.  
  53. Cache::~Cache()
  54. {
  55.   if (fptr) Flush(); Disconnect();
  56.   delete[] buckets;
  57. }
  58. #endif //  __NOT_USING_TEMPLATE_CLASS__
  59.  
  60. // ----------------------------------------------------------- // 
  61. // ------------------------------- //
  62. // --------- End of File --------- //
  63. // ------------------------------- //
  64.