00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * COMMENTS: 00014 * An instance of this class is stored with each instance of 00015 * PY_CompiledCode. Each time the code is evaluated, the cache is 00016 * made active, and subsequent evaluations can use information that 00017 * was cached during previous evaluations. 00018 * 00019 * The cache has nothing to do with python, and is used to cache 00020 * the results of expensive computations done in Houdini's code. 00021 * 00022 * This class only exists at the PY level so PY_CompiledCode can store 00023 * an instance of it and so it can deleted it. HOMF_Module will set 00024 * a callback to create new instances of HOMF_EvaluationCache objects. 00025 * These objects store things like OP_ExprFindOp caches that speed up 00026 * channel references, etc. 00027 */ 00028 00029 #ifndef __PY_EvaluationCache_h__ 00030 #define __PY_EvaluationCache_h__ 00031 00032 #include "PY_API.h" 00033 #include <UT/UT_PtrArray.h> 00034 00035 class PY_API PY_EvaluationCache 00036 { 00037 public: 00038 virtual ~PY_EvaluationCache() 00039 {} 00040 00041 // Use this static function to set a callback that creates instances of a 00042 // subclass of PY_EvaluationCache. This callback is invoked from 00043 // PY_CompiledCode when evaluating Python code. This static function is 00044 // called when the hou Python module is imported and the HOMF_Module 00045 // instance is created. 00046 static void setConstructionCallback( 00047 PY_EvaluationCache *(*callback)()); 00048 00049 static bool isConstructionCallbackSet(); 00050 00051 // This static function uses the creation callback to create a new instance 00052 // of the evaluation cache subclass. Don't call this function unless 00053 // the callback has been set. 00054 static PY_EvaluationCache *createNew(); 00055 00056 // Each thread has a stack of evaluation caches, and this static function 00057 // returns that stack. Note that you must use the evaluation stack from 00058 // the same thread that you call evaluationCacheStack() from. 00059 static UT_PtrArray<PY_EvaluationCache *> &getThreadSpecificStack(); 00060 00061 private: 00062 static PY_EvaluationCache *(*theConstructionCallback)(); 00063 }; 00064 00065 #endif
1.5.9