HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PY_EvaluationCache.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  * COMMENTS:
7  * An instance of this class is stored with each instance of
8  * PY_CompiledCode. Each time the code is evaluated, the cache is
9  * made active, and subsequent evaluations can use information that
10  * was cached during previous evaluations.
11  *
12  * The cache has nothing to do with python, and is used to cache
13  * the results of expensive computations done in Houdini's code.
14  *
15  * This class only exists at the PY level so PY_CompiledCode can store
16  * an instance of it and so it can deleted it. HOMF_Module will set
17  * a callback to create new instances of HOMF_EvaluationCache objects.
18  * These objects store things like OP_ExprFindOp caches that speed up
19  * channel references, etc.
20  */
21 
22 #ifndef __PY_EvaluationCache_h__
23 #define __PY_EvaluationCache_h__
24 
25 #include "PY_API.h"
26 #include <UT/UT_ValArray.h>
27 
29 {
30 public:
32  {}
33 
34  // Count all memory owned by the PY_EvaluationCache. Remember to
35  // include sizeof(*this) if inclusive, else don't.
36  virtual int64 getMemoryUsage(bool inclusive) const
37  { return inclusive ? sizeof(*this) : 0; }
38 
39  // Use this static function to set a callback that creates instances of a
40  // subclass of PY_EvaluationCache. This callback is invoked from
41  // PY_CompiledCode when evaluating Python code. This static function is
42  // called when the hou Python module is imported and the HOMF_Module
43  // instance is created.
44  static void setConstructionCallback(
45  PY_EvaluationCache *(*callback)());
46 
47  static bool isConstructionCallbackSet();
48 
49  // This static function uses the creation callback to create a new instance
50  // of the evaluation cache subclass. Don't call this function unless
51  // the callback has been set.
52  static PY_EvaluationCache *createNew();
53 
54  // Each thread has a stack of evaluation caches, and this static function
55  // returns that stack. Note that you must use the evaluation stack from
56  // the same thread that you call evaluationCacheStack() from.
57  static UT_ValArray<PY_EvaluationCache *> &getThreadSpecificStack();
58 
59 private:
60  static PY_EvaluationCache *(*theConstructionCallback)();
61 };
62 
63 #endif
virtual int64 getMemoryUsage(bool inclusive) const
long long int64
Definition: SYS_Types.h:107
#define PY_API
Definition: PY_API.h:10