HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_Cache.h
Go to the documentation of this file.
1 #ifndef _OP_Cache_
2 #define _OP_Cache_
3 
4 #include "OP_API.h"
5 #include "OP_Context.h"
6 #include <UT/UT_NonCopyable.h>
7 #include <UT/UT_StringHolder.h>
8 #include <UT/UT_Array.h>
9 
10 class OP_Node;
11 class OP_CacheInfo;
12 class op_CacheEntry;
13 
15 {
16 public:
17  OP_Cache(OP_Node *client,
18  const char *cop2_name,
19  const char *cache_name);
20  virtual ~OP_Cache();
21 
22  void setSize(int size);
23  int getSize() const
24  { return( myMaxSize ); }
25 
26  void *getData(const OP_Context &context);
27 
28  void putData(void *data, const OP_Context &c);
29  void updateContextDeps(const DEP_ContextOptionDeps &deps);
30 
31  bool ownsData(void *); // Does the cache own the data
32  void clear(); // Deletes all data in the cache.
33 
34  // These are public; however, they're meant for diagnostics
35  void print(FILE *);
36  const void *getDataPtr(int idx);
37  const OP_Context *getContextPtr(int idx);
38 
39  virtual int64 getMemoryUsage(bool inclusive) const
40  {
41  int64 mem = inclusive ? sizeof(*this) : 0;
42  mem += myCacheData.getMemoryUsage(false);
43  mem += myOpName.getMemoryUsage(false);
44  mem += myCacheName.getMemoryUsage(false);
45  return mem;
46  }
47 
48 private:
49  void deleteData(op_CacheEntry *entry) const;
50  bool deleteReference(void *);
51 
52  OP_Node *myClient;
53  UT_StringHolder myOpName;
54  UT_StringHolder myCacheName;
55  UT_Array<op_CacheEntry *> myCacheData;
56  int myMaxSize;
57 };
58 
59 #endif
UT_ConcurrentSet< UT_StringHolder > DEP_ContextOptionDeps
GT_API const UT_StringHolder cache_name
int getSize() const
Definition: OP_Cache.h:23
long long int64
Definition: SYS_Types.h:116
GLsizeiptr size
Definition: glcorearb.h:664
#define OP_API
Definition: OP_API.h:10
virtual int64 getMemoryUsage(bool inclusive) const
Definition: OP_Cache.h:39
FMT_INLINE void print(format_string< T...> fmt, T &&...args)
Definition: core.h:2976
Definition: format.h:895