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 class UT_API UT_Cache 00029 { 00030 public: 00031 UT_Cache(); 00032 virtual ~UT_Cache(); 00033 00034 // clear this cache. May not entirely clear the cache if some items are in 00035 // use. 00036 void utClearCache(); 00037 00038 // required - return the english name for this cache. 00039 virtual const char *utGetCacheName() const = 0; 00040 00041 // required - return the current cache size, in bytes 00042 virtual int64 utGetCurrentSize() = 0; 00043 00044 // required - reduce the current cache size by amount bytes. Returns the 00045 // amount of bytes actually freed. 00046 virtual int64 utReduceCacheSizeBy(int64 amount) = 0; 00047 00048 00049 // optional - override if the cache has a well defined maximum size 00050 virtual bool utHasMaxSize() const { return false; } 00051 virtual int64 utGetMaxSize() { return 0; } 00052 virtual void utSetMaxSize(int64) { } 00053 00054 // optional - override if the cache has a well defined minimum size (this 00055 // doesn't include a current min size imposed by items locked in the cache) 00056 virtual bool utHasMinSize() const { return false; } 00057 virtual int64 utGetMinSize() { return 0; } 00058 virtual void utSetMinSize(int64) { } 00059 00060 // override in case a method needs to be run to get the most up-to-date 00061 // cache information. Return true if it has changed. 00062 virtual bool utUpdateCacheInfo() { return false; } 00063 00064 // get the list of caches 00065 static const UT_PtrArray<UT_Cache *> &utGetCacheList(); 00066 00067 // callback to be called when a cache is added or deleted. 00068 static void setCacheAddRemoveCB(void (*callback)(void *), void *data); 00069 00070 // this method attempts to free up 'amount' bytes from all the caches. 00071 static int64 utClearSpaceFromCaches(int64 amount); 00072 }; 00073 00074 #endif
1.5.9