00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Mark Alexander 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: UT_Cache.h ( UT Library, C++) 00015 * 00016 * COMMENTS: 00017 * An interface to a cache within Houdini. This is used so that the cache 00018 * manager can monitor and manage the caches. 00019 * 00020 */ 00021 #ifndef UT_CACHE_H 00022 #define UT_CACHE_H 00023 00024 #include "UT_API.h" 00025 #include "UT_PtrArray.h" 00026 00027 00028 /// Common base class for various caches 00029 class UT_API UT_Cache 00030 { 00031 public: 00032 UT_Cache(); 00033 virtual ~UT_Cache(); 00034 00035 /// clear this cache. May not entirely clear the cache if some items are in 00036 /// use (depending on the cache) 00037 void utClearCache(); 00038 00039 /// required - return the english name for this cache. 00040 virtual const char *utGetCacheName() const = 0; 00041 00042 /// required - return the current cache size, in bytes 00043 virtual int64 utGetCurrentSize() const = 0; 00044 00045 /// required - free contents of the cache by @c amount bytes. Returns the 00046 /// amount of memory (in bytes) actually freed. 00047 /// This does @b not change the cache size 00048 virtual int64 utReduceCacheSizeBy(int64 amount) = 0; 00049 00050 /// optional - override if the cache has a well defined maximum size 00051 virtual bool utHasMaxSize() const { return false; } 00052 virtual int64 utGetMaxSize() const { return 0; } 00053 virtual void utSetMaxSize(int64) { } 00054 00055 /// optional - override if the cache has a well defined minimum size (this 00056 /// doesn't include a current min size imposed by items locked in the cache) 00057 virtual bool utHasMinSize() const { return false; } 00058 virtual int64 utGetMinSize() const { return 0; } 00059 virtual void utSetMinSize(int64) { } 00060 00061 /// override in case a method needs to be run to get the most up-to-date 00062 /// cache information. Return true if it has changed. 00063 virtual bool utUpdateCacheInfo() { return false; } 00064 00065 /// get the list of caches 00066 static const UT_PtrArray<UT_Cache *> &utGetCacheList(); 00067 00068 /// callback to be called when a cache is added or deleted. 00069 static void setCacheAddRemoveCB(void (*callback)(void *), void *data); 00070 00071 /// this method attempts to free up 'amount' bytes from all the caches. 00072 static int64 utClearSpaceFromCaches(int64 amount); 00073 }; 00074 00075 #endif
1.5.9