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 * Mark Elendt 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: OP_Expression.h ( OP Library, C++) 00015 * 00016 * COMMENTS: This contains a base class for expressions which reference OPs. 00017 * This class should be allocated by a function callback (i.e. see 00018 * ev_SetFunctionInstanceAllocator in EXPR/EXPR.h) and can be used 00019 * to quickly get the correct OP_Node given a path. 00020 */ 00021 00022 #ifndef __OP_Expression__ 00023 #define __OP_Expression__ 00024 00025 #include "OP_API.h" 00026 #include <UT/UT_String.h> 00027 00028 class OP_Node; 00029 class PRM_Parm; 00030 class PRM_ParmList; 00031 class CH_Channel; 00032 00033 class OP_API OP_ExprFindOp { 00034 public: 00035 OP_ExprFindOp(); 00036 ~OP_ExprFindOp() {} 00037 00038 // Find the node specified by "path" relative to the current location 00039 // specified by "cwd". Returns null if there's no such op. If add_warnings 00040 // is true, then it will also call UTaddWarning() with something 00041 // appropriate when the return value is NULL. 00042 OP_Node *getNode(const char *path, OP_Node *cwd, 00043 bool add_warnings); 00044 00045 // The following functions can be used by the expression lib allocator 00046 // However, they may not be used if this class is sub-classed 00047 static void *allocFindOp(); 00048 static void freeFindOp(void *data); 00049 00050 private: 00051 int myOpId; 00052 int myCwdOpId; 00053 UT_String myPath; 00054 }; 00055 00056 00057 class OP_API OP_ExprFindCh 00058 { 00059 public: 00060 OP_ExprFindCh(); 00061 ~OP_ExprFindCh() {} 00062 00063 // If is_for_channel_name is false, look up the parm name (e.g. "t") 00064 // instead of the channel name (e.g. "tx"). When looking up a parm 00065 // name, the subindex result will always be -1. 00066 bool findParmRelativeTo( 00067 OP_Node &relative_to_node, 00068 const char *path, 00069 fpreal now, OP_Node *&node, 00070 int &parmindex, int &subindex, 00071 bool is_for_channel_name); 00072 00073 // Returns the node and/or parm that is currently evaluating. 00074 // parm_index might be NULL if the node is not currently cooking. 00075 void getEvaluatingSource(OP_Node *&node, int &parm_index, int thread); 00076 00077 // If there is no parameter currently being evaluated, node will be null 00078 // and parm_index will be -1. 00079 void getEvaluatingParm(OP_Node *&node, int &parm_index, int thread); 00080 00081 private: 00082 int getDestIndex( 00083 OP_Node *node, const char *channel_name, bool allow_alias); 00084 00085 // myOpId is for the node that was found (i.e. the node being referenced). 00086 int myOpId; 00087 bool myIsForChannelName; 00088 int myRelativeToOpId; 00089 // myPath is the relative path from myRelativeToOpId's node to myOpId. 00090 UT_String myPath; 00091 00092 int myParmIndex; 00093 int mySubIndex; 00094 PRM_ParmList *myParmList; 00095 unsigned long myParmListCounter; 00096 00097 // The dest parameter is the one being evaluated. It's the one that will 00098 // get node interests. 00099 OP_Node * myDestNode; 00100 int myDestIndex; 00101 unsigned long myDestListCounter; 00102 UT_String myDestName; 00103 }; 00104 00105 00106 // Get a parameter relative to the currently evaluating node/the pwd. 00107 // 00108 // This function has the important option of adding parm interests in 00109 // the referenced parameter from the currently evaluating parameter. It 00110 // basically assumes that that referenced parameter will be evaluated from the 00111 // currently evaluating parameter (e.g. like when we do a channel reference). 00112 // 00113 // This function will use OP_ExprFindCh to cache parameter lookups. Houdini 00114 // will allocate OP_ExprFindCh objects when some expression functions 00115 // (ch(), chs(), etc.) are compiled into bytecode, so you don't often have 00116 // to deal with OP_ExprFindCh manually. Because HOM needs finer-grained 00117 // control over when dependencies are added, though, it does deal with them 00118 // manually. 00119 OP_API extern void OPgetParameter(const char *path, float &time, 00120 int *retsubindex, PRM_Parm **retparm, 00121 CH_Channel **retchannel, OP_Node **retnode, 00122 bool allow_alias, 00123 bool add_parm_interests /*= true*/, 00124 int thread, bool add_warnings = false); 00125 00126 #endif
1.5.9