HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_GraphProxy.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_GraphProxy.h ( OP Library, C++)
7  *
8  * COMMENTS:
9  * Allows the idea of a OP_Node network to be abstracted from
10  * actual OP_Node *s.
11  */
12 
13 #ifndef __OP_GraphProxy_h__
14 #define __OP_GraphProxy_h__
15 
16 #include "OP_API.h"
17 #include "OP_Node.h"
18 #include "OP_NodeParms.h"
19 #include <UT/UT_OpGraphProxy.h>
20 #include <DEP/DEP_TimedMicroNode.h>
21 
23 class OP_GraphProxy;
24 class SOP_NodeVerb;
25 class COP_Verb;
26 
27 /// Returns singleton proxy for our OP_Director network.
28 /// This uses getUniqueId() as the indices
30 
31 /// Sets the global direct graph proxy, used for registration.
32 OP_API void OPsetDirectGraphProxy(const OP_GraphProxy *proxy);
33 
35 {
36 public:
37  OP_GraphProxy();
38  ~OP_GraphProxy() override;
39 
40  using NodeIdx = exint;
41 
42  class NodeOrIdx
43  {
44  public:
45  explicit NodeOrIdx(OP_Node *node)
46  {
47  myNode = node;
48  myIdx = -1;
49  if (myNode) myIdx = myNode->getUniqueId();
50  }
52  {
53  myNode = nullptr;
54  myIdx = index;
55  }
57  {
58  myNode = node;
59  myIdx = index;
60  }
61  NodeIdx index() const { return myIdx; }
62  OP_Node *node() const { return myNode; }
63  bool valid() const { if (myNode) return true; return myIdx >= 0; }
64  private:
65  OP_Node *myNode = nullptr;
66  NodeIdx myIdx = -1;
67  };
68 
69  /// Direct proxies mirror actual nodes:
70  virtual bool isDirect() const = 0;
71  /// Return an actual node associated with an index, callers must
72  /// handle this being nullptr as the point of proxies is to allow
73  /// non-node proxies.
74  virtual OP_Node *idxToNode(NodeIdx idx) const = 0;
75 
76  // Will only work with direct proxies, as indirect don't have an
77  // index for a node.
78  virtual NodeIdx nodeToIdx(const OP_Node *node) const = 0;
79  virtual UT_StringHolder getFullPath(NodeIdx idx) const = 0;
80  virtual UT_StringHolder getType(NodeIdx idx) const = 0;
81 
82  // Micronode accessors
83  virtual DEP_MicroNode *getEventMicroNode(NodeIdx idx, OP_EventType e) const = 0;
84  virtual DEP_MicroNode *getFlagMicroNode(NodeIdx idx) const = 0;
85 
86  virtual bool validate(NodeIdx idx) const = 0;
87  virtual const SOP_NodeVerb *cookVerb(NodeIdx idx) const = 0;
88 
89  // COP specific accessors
90  virtual int getCOPSignatureCount(NodeIdx idx) const = 0;
91  virtual int getCOPInputCableSize(NodeIdx idx, OP_InputIdx input) const = 0;
92  virtual int getCOPOutputCableSize(NodeIdx idx, OP_OutputIdx output) const = 0;
93  virtual int getCOPNodeInputType(NodeIdx idx, OP_InputIdx input_port_idx, int sig_idx) const = 0;
94  virtual int getCOPNodeOutputType(NodeIdx idx, OP_OutputIdx output_port_idx, int sig_idx) const = 0;
95  virtual bool isCOPOutputNull(NodeIdx idx, OP_OutputIdx output_port_idx, int sig_idx) const = 0;
96  virtual DEP_MicroNode *getCOPSignatureMicroNode(NodeIdx idx) const = 0;
97  virtual const COP_Verb *getCOPVerb(NodeIdx idx) const = 0;
98  virtual int getCOPNumInputs(NodeIdx idx) const = 0;
99  virtual int getCOPNumOutputs(NodeIdx idx) const = 0;
100  virtual bool getCOPAlwaysBypass(NodeIdx idx) const = 0;
101  virtual void getCOPInputName(NodeIdx idx, UT_String& name, OP_InputIdx input_idx) const = 0;
102  virtual NodeIdx getCOPSubNetOutputNode(NodeIdx idx) const = 0;
103  virtual bool addCOPSignatureError(NodeIdx idx, UT_ErrorManager &error) const = 0;
104 
105  // Must be in-sync with COP_Node::OutputPort (with the exception of the
106  // override ID field, which is not needed).
107  typedef std::tuple<NodeIdx, OP_OutputIdx, int> COP_NodeOutputPort;
108  virtual COP_NodeOutputPort getCOPBypassPort(NodeIdx idx, UT_ErrorManager& error, DEP_MicroNode* dep, OP_OutputIdx port_index, int sig_index) const = 0;
109  virtual COP_NodeOutputPort getCOPOutputPortFromInput(NodeIdx idx, OP_InputIdx input, int sig_index, bool markused=false) const = 0;
110 
111  // Flag accessors
112  virtual bool getBypass(NodeIdx idx) const = 0;
113  virtual bool getHardLock(NodeIdx idx) const = 0;
114  virtual bool getUnload(NodeIdx idx) const = 0;
115 
116  virtual bool getLockedGeometry(NodeIdx idx, GU_ConstDetailHandle *handle) const = 0;
117 
118  // Topology
119  virtual int nInputs(NodeIdx idx) const = 0;
120  virtual int minInputs(NodeIdx idx) const = 0;
121  virtual NodeIdx getInput(NodeIdx idx, OP_InputIdx input, bool markused=false) const = 0;
122  virtual NodeIdx getInputFollowingOutputs(NodeIdx idx, OP_InputIdx input, DEP_MicroNode *depnode=0) const = 0;
123  virtual NodeIdx getOutputSop(NodeIdx idx, OP_OutputIdx output) const = 0;
124  virtual NodeIdx findNode(const UT_StringRef &path) const = 0;
125  virtual NodeIdx findRelativeNode(NodeIdx cwd, const UT_StringRef &path) const = 0;
126  virtual NodeIdx getSOPNode(NodeIdx idx, const UT_StringRef &path, bool addref=true) const = 0;
127  virtual bool isPaired(NodeIdx idx, NodeIdx pair) const = 0;
128  virtual OP_OutputIdx whichOutputIsFollowingIndirect(NodeIdx idx, NodeIdx target, OP_InputIdx input_on_target) const = 0;
129  virtual int numSpareInputs(NodeIdx idx) const = 0;
130 
131  virtual NodeIdx getParentNode(NodeIdx idx) const = 0;
132  virtual void getPathWithSubnet(NodeIdx idx, UT_String &str) const = 0;
133 
134  // Gets the spare input using 0-based number.
135  virtual bool hasSpareInput(NodeIdx idx, int input, fpreal t, DEP_MicroNode *depnode) const = 0;
136  virtual NodeIdx getSpareInput(NodeIdx idx, int input, fpreal t, DEP_MicroNode *depnode) const = 0;
137  // Input number of parm override, in -1 base.
138  virtual int getParmOverrideInput(NodeIdx idx, fpreal time, DEP_MicroNode *depnode) const = 0;
139 
140  virtual NodeIdx getTemplateSOP(NodeIdx idx, fpreal t) const = 0;
141  virtual NodeIdx getFeedbackSOP(NodeIdx idx, fpreal t) const = 0;
142 
143  // Type tests
144  virtual bool isBlockBeginCompile(NodeIdx idx) const = 0;
145  virtual bool isBlockEndCompile(NodeIdx idx) const = 0;
146  virtual bool isBlockBeginFor(NodeIdx idx) const = 0;
147  virtual bool isBlockEndFor(NodeIdx idx) const = 0;
148  virtual bool isInvoke(NodeIdx idx) const = 0;
149  virtual bool isSubNet(NodeIdx idx) const = 0;
150  virtual bool isSubNetInputNode(NodeIdx idx) const = 0;
151  virtual bool isSubNetOutputNode(NodeIdx idx) const = 0;
152  virtual bool isObjectMerge(NodeIdx idx) const = 0;
153 
154  // Parameter evaluation
155  virtual bool hasParm(NodeIdx node, const char *parmname) const = 0;
156  virtual void evalOpParm(
157  int64 &v, NodeIdx node, const char *parmname, fpreal time,
158  DEP_MicroNode *depnode) const = 0;
159  virtual void evalOpParm(
160  bool &v, NodeIdx node, const char *parmname, fpreal time,
161  DEP_MicroNode *depnode) const = 0;
162  virtual void evalOpParm(
163  fpreal64 &v, NodeIdx node, const char *parmname, fpreal time,
164  DEP_MicroNode *depnode) const = 0;
165  virtual void evalOpParm(
166  UT_Vector2D &v, NodeIdx node, const char *parmname, fpreal time,
167  DEP_MicroNode *depnode) const = 0;
168  virtual void evalOpParm(
169  UT_Vector3D &v, NodeIdx node, const char *parmname, fpreal time,
170  DEP_MicroNode *depnode) const = 0;
171  virtual void evalOpParm(
172  UT_Vector4D &v, NodeIdx node, const char *parmname, fpreal time,
173  DEP_MicroNode *depnode) const = 0;
174 
175  virtual void evalOpParm(
176  UT_Matrix2D &v, NodeIdx node, const char *parmname, fpreal time,
177  DEP_MicroNode *depnode) const = 0;
178  virtual void evalOpParm(
179  UT_Matrix3D &v, NodeIdx node, const char *parmname, fpreal time,
180  DEP_MicroNode *depnode) const = 0;
181  virtual void evalOpParm(
182  UT_Matrix4D &v, NodeIdx node, const char *parmname, fpreal time,
183  DEP_MicroNode *depnode) const = 0;
184 
185  virtual void evalOpParm(
186  UT_Vector2I &v, NodeIdx node, const char *parmname, fpreal time,
187  DEP_MicroNode *depnode) const = 0;
188  virtual void evalOpParm(
189  UT_Vector3I &v, NodeIdx node, const char *parmname, fpreal time,
190  DEP_MicroNode *depnode) const = 0;
191  virtual void evalOpParm(
192  UT_Vector4I &v, NodeIdx node, const char *parmname, fpreal time,
193  DEP_MicroNode *depnode) const = 0;
194  virtual void evalOpParm(
195  UT_StringHolder &v, NodeIdx node, const char *parmname, fpreal time,
196  DEP_MicroNode *depnode) const = 0;
197  virtual void evalOpParmRaw(
198  UT_StringHolder &v, NodeIdx node, const char *parmname, fpreal time,
199  DEP_MicroNode *depnode) const = 0;
200  virtual void evalOpParm(
201  UT_SharedPtr<UT_Ramp> &v, NodeIdx node, const char *parmname, fpreal time,
202  DEP_MicroNode *depnode) const = 0;
203  virtual void evalOpParm(
204  PRM_DataItemHandle &v, NodeIdx node, const char *parmname, fpreal time,
205  DEP_MicroNode *depnode) const = 0;
206 
207  virtual void evalOpParmInst(
208  int64 &v, NodeIdx node, const char *parmname,
209  const int *inst, const int *offsets, fpreal time,
210  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
211  virtual void evalOpParmInst(
212  bool &v, NodeIdx node, const char *parmname,
213  const int *inst, const int *offsets, fpreal time,
214  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
215  virtual void evalOpParmInst(
216  fpreal64 &v, NodeIdx node, const char *parmname,
217  const int *inst, const int *offsets, fpreal time,
218  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
219  virtual void evalOpParmInst(
220  UT_Vector2D &v, NodeIdx node, const char *parmname,
221  const int *inst, const int *offsets, fpreal time,
222  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
223  virtual void evalOpParmInst(
224  UT_Vector3D &v, NodeIdx node, const char *parmname,
225  const int *inst, const int *offsets, fpreal time,
226  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
227  virtual void evalOpParmInst(
228  UT_Vector4D &v, NodeIdx node, const char *parmname,
229  const int *inst, const int *offsets, fpreal time,
230  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
231 
232  virtual void evalOpParmInst(
233  UT_Matrix2D &v, NodeIdx node, const char *parmname,
234  const int *inst, const int *offsets, fpreal time,
235  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
236  virtual void evalOpParmInst(
237  UT_Matrix3D &v, NodeIdx node, const char *parmname,
238  const int *inst, const int *offsets, fpreal time,
239  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
240  virtual void evalOpParmInst(
241  UT_Matrix4D &v, NodeIdx node, const char *parmname,
242  const int *inst, const int *offsets, fpreal time,
243  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
244 
245  virtual void evalOpParmInst(
246  UT_Vector2I &v, NodeIdx node, const char *parmname,
247  const int *inst, const int *offsets, fpreal time,
248  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
249  virtual void evalOpParmInst(
250  UT_Vector3I &v, NodeIdx node, const char *parmname,
251  const int *inst, const int *offsets, fpreal time,
252  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
253  virtual void evalOpParmInst(
254  UT_Vector4I &v, NodeIdx node, const char *parmname,
255  const int *inst, const int *offsets, fpreal time,
256  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
257 
258  virtual void evalOpParmInst(
259  UT_StringHolder &v, NodeIdx node, const char *parmname,
260  const int *inst, const int *offsets, fpreal time,
261  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
262  virtual void evalOpParmInst(
263  UT_SharedPtr<UT_Ramp> &v, NodeIdx node, const char *parmname,
264  const int *inst, const int *offsets, fpreal time,
265  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
266  virtual void evalOpParmInst(
267  PRM_DataItemHandle &v, NodeIdx node, const char *parmname,
268  const int *inst, const int *offsets, fpreal time,
269  DEP_MicroNode *depnode, int nestlevel=1) const = 0;
270 
271  /// Returns the override ID that can possibly prescribe different signatures
272  /// to nodes (separate from what the pure network contains). This is
273  /// presently only used by COPs to specify input null states and cable
274  /// structures when traversing a graph.
275  virtual int getOverrideId() const
276  { UT_ASSERT(false); return -1; }
277 };
278 
279 
280 
281 #endif
int getUniqueId() const
Definition: OP_Node.h:777
short * getInput(int size) override
virtual int getOverrideId() const
std::tuple< NodeIdx, OP_OutputIdx, int > COP_NodeOutputPort
GT_API const UT_StringHolder time
const GLdouble * v
Definition: glcorearb.h:837
OP_Node * node() const
Definition: OP_GraphProxy.h:62
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
int OP_InputIdx
Definition: OP_DataTypes.h:184
int64 exint
Definition: SYS_Types.h:125
GLuint GLsizei const GLuint const GLintptr * offsets
Definition: glcorearb.h:2621
< returns > If no error
Definition: snippets.dox:2
double fpreal64
Definition: SYS_Types.h:201
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: APEX_Include.h:55
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
long long int64
Definition: SYS_Types.h:116
GLenum target
Definition: glcorearb.h:1667
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
NodeOrIdx(OP_Node *node)
Definition: OP_GraphProxy.h:45
fpreal64 fpreal
Definition: SYS_Types.h:283
#define OP_API
Definition: OP_API.h:10
GLuint index
Definition: glcorearb.h:786
OP_API const OP_GraphProxy * OPdirectGraphProxy()
OP_API void OPsetDirectGraphProxy(const OP_GraphProxy *proxy)
Sets the global direct graph proxy, used for registration.
OP_EventType
Definition: OP_Value.h:22
A global error manager scope.
int OP_OutputIdx
Definition: OP_DataTypes.h:185
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165
NodeOrIdx(NodeIdx index, OP_Node *node)
Definition: OP_GraphProxy.h:56
NodeIdx index() const
Definition: OP_GraphProxy.h:61
NodeOrIdx(NodeIdx index)
Definition: OP_GraphProxy.h:51