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  /// optional - is this cache currently operational.
38  virtual bool utIsEnabled() const { return true; }
39 
40  /// required - return the current cache size, in bytes
41  virtual int64 utGetCurrentSize() const = 0;
42 
43  /// required - free contents of the cache by @c amount bytes. Returns the
44  /// amount of memory (in bytes) actually freed.
45  /// This does @b not change the cache size
46  virtual int64 utReduceCacheSizeBy(int64 amount) = 0;
47 
48  /// optional - override if the cache has a well defined maximum size
49  virtual bool utHasMaxSize() const { return false; }
50  virtual int64 utGetMaxSize() const { return 0; }
51  virtual void utSetMaxSize(int64) { }
52 
53  /// optional - override if the cache has a well defined minimum size (this
54  /// doesn't include a current min size imposed by items locked in the cache)
55  virtual bool utHasMinSize() const { return false; }
56  virtual int64 utGetMinSize() const { return 0; }
57  virtual void utSetMinSize(int64) { }
58 
59  /// override in case a method needs to be run to get the most up-to-date
60  /// cache information. Return true if it has changed.
61  virtual bool utUpdateCacheInfo() { return false; }
62 
63  /// get the list of caches
64  static const UT_ValArray<UT_Cache *> &utGetCacheList();
65 
66  /// callback to be called when a cache is added or deleted.
67  static void setCacheAddRemoveCB(void (*callback)(void *), void *data);
68 
69  /// this method attempts to free up 'amount' bytes from all the caches.
70  static int64 utClearSpaceFromCaches(int64 amount);
71 };
72 
73 #endif
virtual bool utHasMinSize() const
Definition: UT_Cache.h:55
virtual bool utUpdateCacheInfo()
Definition: UT_Cache.h:61
#define UT_API
Definition: UT_API.h:14
virtual int64 utGetMaxSize() const
Definition: UT_Cache.h:50
virtual int64 utGetMinSize() const
Definition: UT_Cache.h:56
virtual bool utIsEnabled() const
optional - is this cache currently operational.
Definition: UT_Cache.h:38
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:57
LeafData & operator=(const LeafData &)=delete
virtual void utSetMaxSize(int64)
Definition: UT_Cache.h:51
virtual bool utHasMaxSize() const
optional - override if the cache has a well defined maximum size
Definition: UT_Cache.h:49
Definition: format.h:1821