home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / i18n / colcache.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  3.2 KB  |  88 lines

  1. /*
  2. *****************************************************************************************
  3. *                                                                                       *
  4. * COPYRIGHT:                                                                            *
  5. *   (C) Copyright Taligent, Inc.,  1997                                                 *
  6. *   (C) Copyright International Business Machines Corporation,  1997-1999                    *
  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. //===============================================================================
  14. //
  15. // File colcache.h
  16. //
  17. // CollationCache implements a persistent in-memory cache for
  18. // TableCollationData objects.  The goal of CollationCache is to improve
  19. // the memory footprint of a process which may have multiple threads
  20. // loading up the same TableCollation object.  Performance improvement is
  21. // strictly a secondary goal.
  22. //
  23. // Created by: Alan Liu
  24. //
  25. // Modification History:
  26. //
  27. //  Date        Name        Description
  28. //  2/11/97     aliu        Creation.
  29. //  2/12/97     aliu        Modified to work with TableCollationData.
  30. //  8/18/97     helena      Added internal API documentation.
  31. //
  32. //===============================================================================
  33.  
  34. #ifndef COLCACHE_H
  35. #define COLCACHE_H
  36.  
  37. #include "uhash.h"
  38. #include "unistr.h"
  39.  
  40. class TableCollationData;
  41.  
  42. // Tell the VC++ compiler not to warn about DLL interface
  43. #ifdef _WIN32
  44. #pragma warning( disable : 4251 )
  45. #endif
  46.  
  47. //-------------------------------------------------------------------------------
  48. /**
  49.  * CollationCache implements a simple cache for TableCollationData objects.
  50.  * TableCollationData objects may be added to the cache, and looked up in the
  51.  * cache.  When the cache is destroyed, all the TableCollationData objects are
  52.  * deleted.
  53.  */
  54.  
  55. class CollationCache
  56. {
  57. public:
  58.     /**
  59.      * Default constructor.
  60.      */
  61.     CollationCache();
  62.     /**
  63.      * Destructor.
  64.      */
  65.     virtual ~CollationCache();
  66.  
  67.     /** 
  68.      * ::Add and ::Find use a UnicodeString as the key to Collation objects in the
  69.      * cache.  If Add is called twice with equivalent keys, but different
  70.      * collation objects, the first collation object will be deleted when the
  71.      * second one is added.  In general, this is undesirable; objects in the
  72.      * cache are usually pointed to by various clients in the system.  For this
  73.      * reason, clients should call Find to ensure a Collation object does not
  74.      * already exist in the cache for the given key before calling Add.
  75.      * @param key the unique key.
  76.      * @param data the collation data object.
  77.      * @return the found collation data object
  78.      */
  79.     void                Add(const UnicodeString& key, TableCollationData* data);
  80.     TableCollationData* Find(const UnicodeString& key);
  81.  
  82. private:
  83.     UHashtable*   fHashtable;
  84. };
  85.  
  86. #endif
  87. //eof
  88.