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