HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_Expression.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: OP_Expression.h ( OP Library, C++)
7  *
8  * COMMENTS: This contains a base class for expressions which reference OPs.
9  * This class should be allocated by a function callback (i.e. see
10  * ev_SetFunctionInstanceAllocator in EXPR/EXPR.h) and can be used
11  * to quickly get the correct OP_Node given a path.
12  */
13 
14 #ifndef __OP_Expression__
15 #define __OP_Expression__
16 
17 #include "OP_API.h"
18 #include "OP_Error.h"
19 #include <UT/UT_String.h>
20 #include <SYS/SYS_Types.h>
21 #include <stddef.h>
22 
23 class OP_Node;
24 class PRM_Parm;
25 class PRM_ParmList;
26 class CH_Channel;
28 
30 public:
31  OP_ExprFindOp();
33 
34  // Count all memory owned by the OP_ExprFindOp. Remember to
35  // include sizeof(*this) if inclusive, else don't.
36  int64 getMemoryUsage(bool inclusive) const
37  {
38  int64 mem = inclusive ? sizeof(*this) : 0;
39  mem += myPath.getMemoryUsage(false);
40  return mem;
41  }
42 
43  // Find the node specified by "path" relative to the current location
44  // specified by "cwd". Returns null if there's no such op. If add_warnings
45  // is true, then it will also call UTaddWarning() with something
46  // appropriate when the return value is NULL.
47  OP_Node *getNode(const char *path, OP_Node *cwd,
48  bool add_warnings);
49 
50  // The following functions can be used by the expression lib allocator
51  // However, they may not be used if this class is sub-classed
52  static void *allocFindOp();
53  static void freeFindOp(void *data);
54 
55 private:
56  int myOpId;
57  int myCwdOpId;
58  UT_String myPath;
59 };
60 
61 
63 {
64 public:
65  OP_ExprFindCh();
67 
68  // Count all memory owned by the OP_ExprFindCh. Remember to
69  // include sizeof(*this) if inclusive, else don't.
70  int64 getMemoryUsage(bool inclusive) const
71  {
72  int64 mem = inclusive ? sizeof(*this) : 0;
73  mem += myPath.getMemoryUsage(false);
74  mem += myDestName.getMemoryUsage(false);
75  return mem;
76  }
77 
78  // If is_for_channel_name is false, look up the parm name (e.g. "t")
79  // instead of the channel name (e.g. "tx"). When looking up a parm
80  // name, the subindex result will always be -1.
81  bool findParmRelativeTo(
82  OP_Node &relative_to_node,
83  const char *path,
84  fpreal now, OP_Node *&node,
85  int &parmindex, int &subindex,
86  bool is_for_channel_name);
87 
88  // Returns the node and/or parm that is currently evaluating.
89  // parm_index might be NULL if the node is not currently cooking.
90  void getEvaluatingSource(OP_Node *&node, int &parm_index, int &sub_index,
91  int thread);
92 
93  // If there is no parameter currently being evaluated, node will be null
94  // and parm_index will be -1.
95  void getEvaluatingParm(OP_Node *&node, int &parm_index, int &sub_index,
96  int thread);
97 
98 private:
99  int getDestIndex(
100  OP_Node *node, const char *channel_name, int &sub_index,
101  bool allow_alias);
102 
103  // myOpId is for the node that was found (i.e. the node being referenced).
104  int myOpId;
105  bool myIsForChannelName;
106  int myRelativeToOpId;
107  // myPath is the relative path from myRelativeToOpId's node to myOpId.
108  UT_String myPath;
109 
110  int myParmIndex;
111  int mySubIndex;
112  PRM_ParmList *myParmList;
113  size_t myParmListCounter;
114 
115  // The dest parameter is the one being evaluated. It's the one that will
116  // get node interests.
117  OP_Node * myDestNode;
118  int myDestIndex;
119  int myDestSubIndex;
120  size_t myDestListCounter;
121  UT_String myDestName;
122 };
123 
124 
125 // Get a parameter relative to the currently evaluating node/the pwd.
126 //
127 // This function has the important option of adding parm interests in
128 // the referenced parameter from the currently evaluating parameter. It
129 // basically assumes that that referenced parameter will be evaluated from the
130 // currently evaluating parameter (e.g. like when we do a channel reference).
131 //
132 // This function will use OP_ExprFindCh to cache parameter lookups. Houdini
133 // will allocate OP_ExprFindCh objects when some expression functions
134 // (ch(), chs(), etc.) are compiled into bytecode, so you don't often have
135 // to deal with OP_ExprFindCh manually. Because HOM needs finer-grained
136 // control over when dependencies are added, though, it does deal with them
137 // manually.
138 OP_API extern void
139 OPgetParameter(const char *path, fpreal &time,
140  int *retsubindex, PRM_Parm **retparm,
141  CH_Channel **retchannel, OP_Node **retnode,
142  bool allow_alias,
143  bool add_parm_interests /*= true*/,
144  int thread, bool add_warnings = false);
145 
146 // Possible error code values:
147 // OP_WARN_BAD_CHREF, OP_WARN_BAD_OPREF
148 OP_API extern void
149 OPaddBadRefWarning(OP_ErrorCodes err_code, const char *path, int thread);
150 
151 // Create an attribute evaluator for the requested context option. If the
152 // context option doesn't exist, it returns NULL.
155 
156 #endif
OP_ErrorCodes
Definition: OP_Error.h:8
GLuint const GLchar * name
Definition: glew.h:1814
int64 getMemoryUsage(bool inclusive) const
Definition: OP_Expression.h:70
GT_API const UT_StringHolder time
OP_API void OPgetParameter(const char *path, fpreal &time, int *retsubindex, PRM_Parm **retparm, CH_Channel **retchannel, OP_Node **retnode, bool allow_alias, bool add_parm_interests, int thread, bool add_warnings=false)
long long int64
Definition: SYS_Types.h:111
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
*Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
GLsizei const GLchar *const * path
Definition: glew.h:6461
double fpreal
Definition: SYS_Types.h:276
OP_API void OPaddBadRefWarning(OP_ErrorCodes err_code, const char *path, int thread)
#define OP_API
Definition: OP_API.h:10
OP_API UT_AttributeEvaluator * OPcreateContextOptionEvaluator(const char *name)
int64 getMemoryUsage(bool inclusive) const
Definition: OP_Expression.h:36