HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_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: SOP_Cache.h ( SOP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __SOP_Cache__
12 #define __SOP_Cache__
13 
14 #include "SOP_API.h"
15 #include "SOP_Node.h"
16 #include <UT/UT_Map.h>
17 #include <utility>
18 
19 class UT_InfoTree;
20 class CH_Manager;
21 
22 class SOP_API SOP_Cache : public SOP_Node
23 {
24 public:
25  SOP_Cache(OP_Network *net, const char *name, OP_Operator *entry);
26  virtual ~SOP_Cache();
27 
28  static OP_Node *myConstructor(OP_Network *net,
29  const char *name,
30  OP_Operator *entry);
31 
32  static PRM_Template myTemplateList[];
33 
34  virtual void getNodeSpecificInfoText(OP_Context &context,
35  OP_NodeInfoParms &iparms);
36 
37  // Fill in tree with this node's details
38  virtual void fillInfoTreeNodeSpecific(UT_InfoTree &tree,
39  const OP_NodeInfoTreeParms &parms);
40 
41  virtual bool unloadData();
42  virtual int64 getLoadedMemoryUsage() const;
43 
45  { return myRemoveSerial; }
46 
47  virtual bool updateParmsFlags();
48  virtual void syncNodeVersion(
49  const char *old_version, const char *cur_version, bool *node_deleted);
50 
51  static fpreal roundTime(fpreal current_t);
52 
53  void pruneCache(exint maxframes, fpreal current_t);
54 
55  /// NOTE: This MUST NOT be named "clearCache", because there's a virtual
56  /// function on OP_Node with that name!
57  void clearCacheSopCache();
58 
59 protected:
60  virtual OP_ERROR cookMySop(OP_Context &context);
61  void setInstance(GU_DetailHandle *igdh);
62  virtual int isRefInput(unsigned int i) const;
63  virtual const char *inputLabel(unsigned idx) const;
64 
65 private:
66  bool ANYFRAME() { return evalInt("anyframe", 0, 0) != 0; }
67  int MAXFRAMES(fpreal t) { return evalInt("maxframes",0, t); }
68  bool CLEARONCHANGE(fpreal t) { return evalInt("clearonchange", 0, t) != 0; }
69 
70  int START(fpreal t) { return evalInt("range", 0, t); }
71  int END(fpreal t) { return evalInt("range", 1, t); }
72  int INC(fpreal t) { return evalInt("range", 2, t); }
73 
74  fpreal INDEX(fpreal t) { return evalFloat("index", 0, t); }
75  void PARAM(UT_String &str) { evalString(str, "param", 0, 0); }
76 
77  int INDEXTIME() { return evalInt("indextime", 0, 0); }
78 
79  int LOADMETHOD() { return evalInt("loadmethod", 0, 0); }
80 
81 // int LOAD() { return evalInt("reload", 0, 0); }
82 // int RESET() { return evalInt("clear", 0, 0); }
83 
84  bool CACHEPOINTS() { return evalInt("cachepoints", 0, 0) != 0; }
85  bool BLENDPOS() { return evalInt("blendpos", 0, 0) != 0; }
86 
87  void clearGDPLists();
88  void clearGDPList(fpreal t);
89 
90  void loadLocalGeometry(fpreal t, bool cache_points, int ind,
91  int check_merge = 0);
92  GU_DetailHandle *getLocalGeometry(fpreal t, bool cache_points, int ind,
93  int check_merge = 0);
94 
95  static int preLoadLocalCache(void *data, int index, fpreal t,
96  const PRM_Template *);
97  static int preClearLocalCache(void *data, int index, fpreal t,
98  const PRM_Template *);
99  static int preClearLocalCacheFrame(void *data, int index, fpreal t,
100  const PRM_Template *);
101 
102  void blendGDP(fpreal t, bool cache_points, fpreal index);
103  void setGDP(fpreal t, bool cache_points, int i0);
104 
105  const GU_Detail *getLocalInput(fpreal t, fpreal val, const char *param,
106  CH_Manager *cman);
107 
108  void getRange(int &start, int &end, int &inc, fpreal t);
109 
110  void shiftCache(int start, int end, int inc);
111 
112  /// This maps from frame time to detail. Each detail has an
113  /// integer that indicates the cache access count when
114  /// it was last accessed.
115  /// When removing one item from the cache, the minimum integer is
116  /// found and removed. When removing everything (or all but one)
117  /// from the cache, it's easily cleared. Otherwise, the items
118  /// are sorted for removal.
120 
121  /// This is a cache access count, used for tracking age in myCache.
122  exint myCacheAccessCount;
123 
124  /// Cache whether any of the cooks in the cache have been time dependent.
125  bool myTimeDep;
126 
127  int myCacheStart;
128  int myCacheEnd;
129  int myCacheInc;
130  int myTotal;
131 
132  UT_Array<GU_DetailHandle *> myGDPLists;
133  fpreal myLastIndex;
134  int64 myCachedMemoryUsage;
135 
136  int64 myRemoveSerial;
137  int myLastRefInputId;
138  int myLastRefInputModVer;
139 };
140 
141 #endif
virtual bool unloadData() override
virtual bool updateParmsFlags()
Unsorted map container.
Definition: UT_Map.h:83
virtual void syncNodeVersion(const char *old_version, const char *current_version, bool *node_deleted)
GLuint start
Definition: glcorearb.h:474
virtual const char * inputLabel(unsigned idx) const
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
png_uint_32 i
Definition: png.h:2877
int64 getCacheRemoveSerial() const
Definition: SOP_Cache.h:44
long long int64
Definition: SYS_Types.h:107
int64 exint
Definition: SYS_Types.h:116
void evalString(UT_String &val, int pi, int vi, fpreal t) const
GLuint GLuint end
Definition: glcorearb.h:474
virtual int64 getLoadedMemoryUsage() const
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
double fpreal
Definition: SYS_Types.h:270
GLenum GLfloat param
Definition: glcorearb.h:103
Parameters for OP_Node::fillInfoTree()/OP_Node::fillInfoTreeNodeSpecific()
virtual void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &iparms) override
GLuint index
Definition: glcorearb.h:785
GLuint GLfloat * val
Definition: glcorearb.h:1607
#define SOP_API
Definition: SOP_API.h:10
exint evalInt(int pi, int vi, fpreal t) const
virtual void fillInfoTreeNodeSpecific(UT_InfoTree &tree, const OP_NodeInfoTreeParms &parms) override
Fill in tree with this SOP's details.
virtual OP_ERROR cookMySop(OP_Context &context)=0
virtual int isRefInput(unsigned idx) const