home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / common / rbcache.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-07  |  2.7 KB  |  73 lines

  1. /*
  2. *****************************************************************************************
  3. *                                                                                       *
  4. * COPYRIGHT:                                                                            *
  5. *   (C) Copyright Taligent, Inc.,  1997                                                 *
  6. *   (C) Copyright International Business Machines Corporation,  1997-1998                    *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.                  *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure             *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                              *
  10. *                                                                                       *
  11. *****************************************************************************************
  12. *
  13. * File rbcache.h
  14. *
  15. * Modification History:
  16. *
  17. *   Date        Name        Description
  18. *   03/20/97    aliu        Creation.
  19. *   04/29/97    aliu        Convert to use new Hashtable protocol.
  20. *   04/15/99    damiba      plugged in new C hashtable
  21. *****************************************************************************************
  22. */
  23.  
  24. #include "uhash.h"
  25. #include "unistr.h"
  26.  
  27. /**
  28.  * A class which represents an ordinary Hashtable which deletes its contents when it
  29.  * is destroyed.  This class stores UnicodeStringKeys as its keys, and
  30.  * ResourceBundleData objects as its values.
  31.  */
  32. class U_COMMON_API ResourceBundleCache  // Not really external; just making the compiler happy
  33. {
  34.  public:
  35.   ResourceBundleCache();
  36.   ~ResourceBundleCache();
  37.   UHashtable* hashTable;
  38.  private:
  39.   static void deleteValue(void* value);
  40. };
  41.  
  42. /**
  43.  * A hashtable which owns its keys and values and deletes them when it is destroyed.
  44.  * This class stored UnicodeStringKeys as its keys, and the value 1 as its objects.
  45.  * in other words, the objects are just (void*)1.  The only real information is
  46.  * whether or not a key is present.  Semantically, if a key is present, it means
  47.  * that the corresponding filename has been visited already.
  48.  */
  49. class U_COMMON_API VisitedFileCache // Not really external; just making the compiler happy
  50. {
  51.  public:
  52.   
  53.   VisitedFileCache();
  54.   ~VisitedFileCache();
  55.   UHashtable* hashTable;
  56.   inline bool_t wasVisited(const UnicodeString& filename) const;
  57.   inline void markAsVisited(const UnicodeString& filename);
  58. };
  59.  
  60. inline bool_t VisitedFileCache::wasVisited(const UnicodeString& filename) const
  61. {
  62.   return (uhash_get(hashTable, uhash_hashUString(filename.getUChars())) != 0);
  63. }
  64.  
  65. inline void VisitedFileCache::markAsVisited(const UnicodeString& filename)
  66. {
  67.   UErrorCode err = U_ZERO_ERROR;
  68.   uhash_putKey(hashTable, uhash_hashUString(filename.getUChars()), (void*)TRUE, &err);
  69. }
  70.  
  71.  
  72. //eof
  73.