HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_Cache.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_Cache.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  * An interface to a cache within Houdini. This is used so that the cache
10  * manager can monitor and manage the caches.
11  *
12  */
13 #ifndef UT_CACHE_H
14 #define UT_CACHE_H
15 
16 #include "UT_API.h"
17 #include "UT_ValArray.h"
18 
19 
20 /// Common base class for various caches
22 {
23 public:
24  UT_Cache();
25  virtual ~UT_Cache();
26 
27  /// clear this cache. May not entirely clear the cache if some items are in
28  /// use (depending on the cache)
29  void utClearCache();
30 
31  /// required - return the english name for this cache.
32  virtual const char *utGetCacheName() const = 0;
33 
34  /// required - return the current cache size, in bytes
35  virtual int64 utGetCurrentSize() const = 0;
36 
37  /// required - free contents of the cache by @c amount bytes. Returns the
38  /// amount of memory (in bytes) actually freed.
39  /// This does @b not change the cache size
40  virtual int64 utReduceCacheSizeBy(int64 amount) = 0;
41 
42  /// optional - override if the cache has a well defined maximum size
43  virtual bool utHasMaxSize() const { return false; }
44  virtual int64 utGetMaxSize() const { return 0; }
45  virtual void utSetMaxSize(int64) { }
46 
47  /// optional - override if the cache has a well defined minimum size (this
48  /// doesn't include a current min size imposed by items locked in the cache)
49  virtual bool utHasMinSize() const { return false; }
50  virtual int64 utGetMinSize() const { return 0; }
51  virtual void utSetMinSize(int64) { }
52 
53  /// override in case a method needs to be run to get the most up-to-date
54  /// cache information. Return true if it has changed.
55  virtual bool utUpdateCacheInfo() { return false; }
56 
57  /// get the list of caches
58  static const UT_ValArray<UT_Cache *> &utGetCacheList();
59 
60  /// callback to be called when a cache is added or deleted.
61  static void setCacheAddRemoveCB(void (*callback)(void *), void *data);
62 
63  /// this method attempts to free up 'amount' bytes from all the caches.
64  static int64 utClearSpaceFromCaches(int64 amount);
65 };
66 
67 #endif
virtual bool utHasMinSize() const
Definition: UT_Cache.h:49
virtual bool utUpdateCacheInfo()
Definition: UT_Cache.h:55
#define UT_API
Definition: UT_API.h:12
virtual int64 utGetMaxSize() const
Definition: UT_Cache.h:44
virtual int64 utGetMinSize() const
Definition: UT_Cache.h:50
long long int64
Definition: SYS_Types.h:100
GLboolean * data
Definition: glcorearb.h:130
Common base class for various caches.
Definition: UT_Cache.h:21
virtual void utSetMinSize(int64)
Definition: UT_Cache.h:51
virtual void utSetMaxSize(int64)
Definition: UT_Cache.h:45
virtual bool utHasMaxSize() const
optional - override if the cache has a well defined maximum size
Definition: UT_Cache.h:43