HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 *cop_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(OP_Context &context);
27 
28  void putData(void *data, OP_Context &c);
29 
30  bool ownsData(void *); // Does the cache own the data
31  void clear(); // Deletes all data in the cache.
32 
33  // These are public; however, they're meant for diagnostics
34  void print(FILE *);
35  const void *getDataPtr(int idx);
36  const OP_Context *getContextPtr(int idx);
37 
38  virtual int64 getMemoryUsage(bool inclusive) const
39  {
40  int64 mem = inclusive ? sizeof(*this) : 0;
41  mem += myCacheData.getMemoryUsage(false);
42  mem += myOpName.getMemoryUsage(false);
43  mem += myCacheName.getMemoryUsage(false);
44  return mem;
45  }
46 
47 private:
48  void deleteData(op_CacheEntry *entry) const;
49  bool deleteReference(void *);
50 
51  OP_Node *myClient;
52  UT_StringHolder myOpName;
53  UT_StringHolder myCacheName;
54  UT_Array<op_CacheEntry *> myCacheData;
55  int myMaxSize;
56 };
57 
58 #endif
GLsizeiptr size
Definition: glcorearb.h:663
int getSize() const
Definition: OP_Cache.h:23
long long int64
Definition: SYS_Types.h:100
GLboolean * data
Definition: glcorearb.h:130
#define OP_API
Definition: OP_API.h:10
virtual int64 getMemoryUsage(bool inclusive) const
Definition: OP_Cache.h:38