HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  UT_Cache(const UT_Cache &) = delete;
28  UT_Cache &operator=(const UT_Cache &) = delete;
29 
30  /// clear this cache. May not entirely clear the cache if some items are in
31  /// use (depending on the cache)
32  void utClearCache();
33 
34  /// required - return the english name for this cache.
35  virtual const char *utGetCacheName() const = 0;
36 
37  /// required - return the current cache size, in bytes
38  virtual int64 utGetCurrentSize() const = 0;
39 
40  /// required - free contents of the cache by @c amount bytes. Returns the
41  /// amount of memory (in bytes) actually freed.
42  /// This does @b not change the cache size
43  virtual int64 utReduceCacheSizeBy(int64 amount) = 0;
44 
45  /// optional - override if the cache has a well defined maximum size
46  virtual bool utHasMaxSize() const { return false; }
47  virtual int64 utGetMaxSize() const { return 0; }
48  virtual void utSetMaxSize(int64) { }
49 
50  /// optional - override if the cache has a well defined minimum size (this
51  /// doesn't include a current min size imposed by items locked in the cache)
52  virtual bool utHasMinSize() const { return false; }
53  virtual int64 utGetMinSize() const { return 0; }
54  virtual void utSetMinSize(int64) { }
55 
56  /// override in case a method needs to be run to get the most up-to-date
57  /// cache information. Return true if it has changed.
58  virtual bool utUpdateCacheInfo() { return false; }
59 
60  /// get the list of caches
61  static const UT_ValArray<UT_Cache *> &utGetCacheList();
62 
63  /// callback to be called when a cache is added or deleted.
64  static void setCacheAddRemoveCB(void (*callback)(void *), void *data);
65 
66  /// this method attempts to free up 'amount' bytes from all the caches.
67  static int64 utClearSpaceFromCaches(int64 amount);
68 };
69 
70 #endif
virtual bool utHasMinSize() const
Definition: UT_Cache.h:52
virtual bool utUpdateCacheInfo()
Definition: UT_Cache.h:58
#define UT_API
Definition: UT_API.h:14
virtual int64 utGetMaxSize() const
Definition: UT_Cache.h:47
virtual int64 utGetMinSize() const
Definition: UT_Cache.h:53
long long int64
Definition: SYS_Types.h:116
Common base class for various caches.
Definition: UT_Cache.h:21
virtual void utSetMinSize(int64)
Definition: UT_Cache.h:54
LeafData & operator=(const LeafData &)=delete
virtual void utSetMaxSize(int64)
Definition: UT_Cache.h:48
virtual bool utHasMaxSize() const
optional - override if the cache has a well defined maximum size
Definition: UT_Cache.h:46
Definition: format.h:895