HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_GraphData.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: UN_GraphData.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_GraphData_h__
13 #define __UN_GraphData_h__
14 
15 #include "UN_API.h"
16 #include "UN_GraphContext.h"
17 #include "UN_GraphTopology.h"
18 #include "UN_Include.h"
19 #include "UN_NodeData.h"
20 #include "UN_ParmData.h"
21 #include "UN_PortData.h"
22 #include "UN_StickyNoteData.h"
23 #include "UN_SubnetData.h"
24 #include "UN_WireData.h"
25 
26 class UN_NodeType;
27 
28 // ============================================================================
29 /// A container and a manager for utility nodes, their parameters and ports,
30 /// and wire connections between them.
31 ///
32 /// This graph object owns the node data containers, and these containers
33 /// own the data buffers. It manages node creation and deletion, and
34 /// maintains the parental relationship between them. This class also
35 /// establishes and maintains connections between the nodes,
36 /// i.e., creates and manages wires via the topology class.
37 ///
38 /// Having such a central manager has several advantages:
39 /// - Better memory management by avoiding numerous small heap allocs.
40 /// It can maintain memory blocks of nodes and wires, and reuse slots
41 /// freed by deleted items, thus avoiding numerous heap memory allocations
42 /// during repeated cycles of node creation/deletion of nodes and wires
43 /// connection/disconnection.
44 /// - Enforces structural integrity of the nodes and connections:
45 /// - No free-floating nodes that belong to nobody.
46 /// - Ensuring wires connect siblings only (no wires to outside of a subnet).
47 /// - Easier management and ownership of wires.
48 /// - Enforces const-correctess: you can edit the graph only if you have
49 /// non-const reference to it; a const graph reference is not editable.
50 /// - Thread safety: allows parallel processing of the node chains only
51 /// if they belong to different graphs; without graphs, it's hard to know
52 /// that two nodes are independent and can be processed in parallel.
53 /// - the struct-of-arrays approach (ie data-oriented-design) is cache friendly
54 /// and optimizes performance when iterating over elements.
55 ///
56 /// Some disadvantages:
57 /// - Overhead that stems from handles holding an ID rather than a direct
58 /// pointer, so access is somewhat slower.
59 /// - Adding a single element (eg, a node) potentially requires several
60 /// allocations of smaller data chunks (data buffer), rather than
61 /// a single allocation of a larger chunk that array-of-structs would
62 /// require. Multiple allocs are slower than a single one.
63 ///
64 /// NOTE: This class is generally not trivially relocatable,
65 /// because its members (eg, myNodeData) are not trivially relocatable
66 /// (see comment there).
67 
69 
71 {
72 public:
73  /// Constructor.
74  //
75  // TODO: FIXME:
76  // Once UN is very stable and solid, update unit test examples,
77  // export headers to HDK, and write HDK examples
78  //
79  /// @param context The context that knows about allowed categories,
80  /// node types, port types, and parm types in this graph.
81  /// Note, UN_GraphData makes a copy of the passed argument,
82  /// so that it's not dependent on the lifespan of this arg.
84 
85  /// Graph data can be very large, so allow the public to use
86  /// only cheap move operations.
87  UN_GraphData( UN_GraphData &&other );
88  UN_GraphData & operator=( UN_GraphData &&other );
89 
90  /// Returns the graph context used by this graph.
91  const UN_GraphContext &context() const
92  { return myContext; }
93 
94 protected:
95  /// Graph data can be very large, so forbid the public to use
96  /// the costly copy operations.
97  /// Knowledgeable friends and derived classes can still use them.
98  UN_GraphData( const UN_GraphData &other ) = default;
99  UN_GraphData & operator=( const UN_GraphData &other ) = default;
100 
101  /// Constructor intended for sub-class graphs that provide custom data.
102  // NB: This does not need to be protected, but for now let's limit exposure.
103  // Currently only used by APEX_GraphData.
104  UN_GraphData( UN_GraphContext context,
105  UN_CustomNodeDataPtr custom_node_data,
106  UN_CustomParmDataPtr custom_parm_data,
107  UN_CustomPortDataPtr custom_port_data,
108  UN_CustomWireDataPtr custom_wire_data,
109  UN_CustomSubnetDataPtr custom_subnet_data,
110  UN_CustomStickyNoteDataPtr custom_stickynote_data );
111 
112 public:
113  /// Clears the graph, bringing it to an empty state.
114  /// @param reset_ids If true, the next data IDs for nodes, ports, etc
115  /// will reset to the initial state. This may be useful
116  /// if a graph loads and clears nodes repeatedly, but has the
117  /// danger of anyone holding the previous IDs thinking that
118  /// that data is still valid. So use this option with great caution!
119  void clearData( bool reset_ids = false );
120 
121  /// @{ Merges another graph (represented as options) into this one.
122  /// @param root_dst_node An existing node in the destination graph
123  /// to which the source root should map to.
124  /// Ie, into which node to merge the other (source) graph.
125  //
126  // TODO: FIXME: pass in policy and other options as a parameter to
127  // indicate what to do with conflicts:
128  // - ignore other values (this takes precedence)
129  // - layer over (other takes precedence)
130  void merge( const UN_Options &graph_opts );
131  UN_GraphMergeInfo merge( const UN_GraphData &src_graph_data,
132  UN_NodeID root_dst_node = UN_ROOT_NODE_ID );
133  /// @}
134 
135  /// Returns options that represent this graph.
136  UN_OptionsPtr asOptions() const;
137 
138 
139  /// Returns an ID of the graph's root node.
140  /// Root is a special node that holds graph's top-level nodes.
141  /// It cannot be deleted or renamed.
142  ///
143  /// NOTE: Within the graph, nodes are arranged in a parental hierarchy,
144  /// where any node can be a parent of other nodes, as long as
145  /// it has UN_SubnetData attached to it. We call such a node a subnet.
146  /// The top-level nodes in a graph don't really have an explicitly
147  /// created parent, however it's convenient to reuse UN_NodeData to
148  /// hold them. We call such implicitly created node a root.
149  /// It holds top-level nodes. All nodes except the root must have
150  /// a valid parent.
151  UN_NodeID rootNode() const
152  { return UN_ROOT_NODE_ID; }
153 
154  /// Returns true if the given name can be used for naming a node.
155  bool isValidNodeName( const UT_StringRef &name ) const;
156 
157  /// Returns a validated name for a graph item (eg, node, sticky note, etc).
158  /// @param force_valid_name If true, the returned name will have valid
159  /// characters (C-style variable, ie, alphanum and '_').
160  /// @param force_unique_name If true, the teturned name will be unique
161  /// among the sibling inside the given @parent_node subnet.
162  /// @parent_node The node inside which to check for the unique node name.
163  /// Used only if @p force_unique_name is true,
164  /// otherwise it can be an invalid ID.
165  /// @default_name The default name to use if forcing a valid name,
166  /// and the child name is an empty string.
167  UT_StringHolder findValidChildItemName(
168  const UT_StringRef &child_name,
169  bool force_valid_name,
170  bool force_unique_name,
171  UN_NodeID parent_node,
172  const UT_StringRef &default_name =
173  UT_StringRef()) const;
174 
175  /// Creates a new node by the given name with the given parent.
176  UN_NodeID createNode(
177  UN_NodeID parent_node,
178  const UT_StringRef &name = UT_StringRef(),
179  const UT_StringRef &type = UT_StringRef(),
180  const UT_StringRef &category = UT_StringRef(),
181  const UT_StringRef &signature = UT_StringRef());
182 
183 
184  /// Returns the node type object for the given node, or null if unavailable.
185  const UN_NodeType * nodeType( UN_NodeID node_id ) const;
186 
187  /// Sets the name of the given node.
188  void setNodeName( UN_NodeID node_id,
189  const UT_StringRef &name );
190 
191  /// Sets the signature for the given node.
192  void setNodeSignature( UN_NodeID node_id,
193  const UT_StringRef &signature_name );
194 
195  /// Returns the list of the signature names provided for the given node.
196  const UT_StringArray &nodeSignatureNames( UN_NodeID node_id ) const;
197 
198  /// Deletes the node given its index.
199  void deleteNode( UN_NodeID node );
200 
201  /// Clears node to a pristine state (no parameters or ports),
202  /// equivalent to node being just created.
203  void clearNode( UN_NodeID node );
204 
205  /// Sets the aspects of the node based on the information given in the
206  /// options dictionary. Leaves other aspects (not present in opt) intact.
207  void mergeNode(
208  UN_NodeID node,
209  const UN_Options &node_opts );
210 
211  /// Returns the representation of a node as options given its data index.
212  UN_OptionsPtr nodeAsOptions( UN_NodeID node ) const;
213 
214  /// @{ Returns a parent node ID of the given child node.
215  /// Note, for top-level nodes, this will return a graph's root node.
216  UN_NodeID parent( UN_NodeID child ) const
217  { return myTopology.nodeParent( child ); }
218  UN_NodeID parent( UN_StickyNoteID child ) const
219  { return myTopology.stickyNoteParent( child ); }
220  /// @}
221 
222 
223  /// Returns a non-root parent node ID of the given child node.
224  /// Note, for top-level nodes, this will return an invalid node ID,
225  /// because their parent is the implicitly created graph's root node.
226  UN_NodeID nonRootParent( UN_NodeID child ) const
227  { return myTopology.nonRootNodeParent( child ); }
228 
229  /// Returns true if the given node is a subnet (ie, can have children).
230  bool isSubnet( UN_NodeID node ) const
231  { return myTopology.nodeSubnet(node).isValid(); }
232 
233  /// Returns an ID iterator range for all the valid subnets in the graph.
235  { return mySubnetData.idRange(); }
236 
237 
238  // TODO: FIXME: rename to reparent
239  /// Moves a node from one parent to another.
240  void moveNode( UN_NodeID node, UN_NodeID new_parent )
241  { myTopology.moveNode( node, new_parent ); }
242 
243  /// Moves all children of the given parent node to another one.
244  void moveAllChildNodes( UN_NodeID old_parent,
245  UN_NodeID new_parent )
246  {
247  myTopology.moveAllChildNodes(
248  old_parent, new_parent );
249  }
250 
251 
252  /// Returns the number of all nodes in the graph.
254  {
255  return UN_DataSize( // account for the root
256  myNodeData.size().exintValue() - 1 );
257  }
258 
259  /// Returns a node ID iterator range for all the valid nodes in the graph.
261  { return myNodeData.idRange(); }
262 
263  /// @{ Returns a list of direct children of the given node (subnet).
264  const UN_NodeIDList & childNodes( UN_NodeID parent ) const
265  { return myTopology.nodeChildNodes( parent ); }
266  const UN_NodeIDList & childNodes( UN_SubnetID parent ) const
267  { return myTopology.subnetChildNodes( parent ); }
268  /// @}
269 
270 
271  /// Returns the number of all wires in the graph.
273  { return myWireData.size(); }
274 
275  /// Returns a wire ID iterator range for all the valid wires in the graph.
277  { return myWireData.idRange(); }
278 
279  /// @{ Returns a list of wires directly inside the given node (subnet).
280  const UN_WireIDList & childWires( UN_NodeID parent ) const
281  { return myTopology.nodeChildWires( parent ); }
282  const UN_WireIDList & childWires( UN_SubnetID parent ) const
283  { return myTopology.subnetChildWires( parent ); }
284  /// @}
285 
286  /// @{ Returns a node ID of a child in a given subnet given its name.
287  UN_NodeID findChildNode(
288  UN_NodeID parent,
289  const UT_StringRef &child_name ) const;
290  UN_StickyNoteID findChildStickyNote(
291  UN_NodeID parent,
292  const UT_StringRef &child_name ) const;
293  /// @}
294 
295  /// @{ Returns an ID of a node at a given path,
296  /// or an invalid ID if not found.
297  ///
298  /// @parm current_node - When the given node path is relative,
299  /// this is the anchor node from which the relative path is followed
300  /// to find the desired node.
301  ///
302  /// @parm node_path - The node path identifying the node to find.
303  /// This can be either an absolute path (starting with a slash, '/')
304  /// or a relative path.
305  /// In particular, when the node path is just a name, this function
306  /// will look for a child by that name directly inside the given parent.
307  /// The path can contain '.' for the current node, and '..' for
308  /// the parent node.
309  UN_NodeID findNode(
310  UN_NodeID current_node,
311  const UT_StringRef &node_path ) const;
312  UN_StickyNoteID findStickyNote(
313  UN_NodeID current_node,
314  const UT_StringRef &sticky_note_path ) const;
315  /// @}
316 
317  /// Creates a parameter data object, and returns its index.
318  UN_ParmID createParm(
319  UN_NodeID node,
320  const UT_StringRef &name = UT_StringRef(),
321  const UT_StringRef &type_name = UT_StringRef());
322 
323  /// Deletes the parameter.
324  void deleteParm( UN_ParmID parm );
325 
326  /// Returns the parameters of the given node.
327  const UN_ParmIDList &parms( UN_NodeID node ) const
328  { return myTopology.nodeParms( node ); }
329 
330  /// Returns the parameter of a given name on a given node.
331  UN_ParmID parm( UN_NodeID node,
332  const UT_StringRef &parm_name ) const;
333 
334  /// Returns the owner node of the given parameter.
335  UN_NodeID node( UN_ParmID parm ) const
336  { return myTopology.parmNode( parm ); }
337 
338 
339 
340  /// Creates a port, and returns its index.
341  /// @param node The owner (parent) node on which the port appears.
342  /// @param kind The port kind (ie, input or output).
343  /// @param name The port name.
344  /// @param type_name The name of the port type.
345  /// @param label The port label that shows up in the graph editor.
346  /// @param index The index at which to insert the port on a node.
347  // This will determine the order of ports that show up in the graph
348  // editor. Note, negative index values are allowed, and denote
349  // the port position counting backwards from the end.
350  // Eg, -1 will insert the new port at the current last port's
351  // position, making it the second last port, since the current
352  // last port will be pushed up by that insertion. To make
353  // the newly created port last, don't pass any index (to append it).
354  UN_PortID createPort(
355  UN_NodeID node,
356  UN_PortKind kind,
357  const UT_StringRef &name = UT_StringRef(),
359  const UT_StringRef &label = UT_StringRef(),
360  const UT_Optional<exint> &index = std::nullopt);
361 
362  /// Sets the name of the given port.
363  void setPortName( UN_PortID port_id,
364  const UT_StringRef &name );
365 
366  /// Deletes the port.
367  void deletePort( UN_PortID port );
368 
369  /// Returns the number of all ports in the graph.
371  { return myPortData.size(); }
372 
373  /// Returns a port ID iterator range for all the valid ports in the graph.
375  { return myPortData.idRange(); }
376 
377  /// Returns the port of a given kind on a given node.
378  UN_PortID port( UN_NodeID node, UN_PortKind kind,
379  const UT_StringRef &port_name ) const;
380 
381  /// Returns the ports of the given kind for the given node.
382  const UN_PortIDList & ports( UN_NodeID node, UN_PortKind kind ) const
383  {
384  return kind == UN_PortKind::Input
385  ? inputPorts( node )
386  : outputPorts( node );
387  }
388 
389  /// Returns input ports of the given node.
390  const UN_PortIDList & inputPorts( UN_NodeID node ) const
391  { return myTopology.nodeInputPorts( node ); }
392 
393  /// Returns output ports of the given node.
394  const UN_PortIDList & outputPorts( UN_NodeID node ) const
395  { return myTopology.nodeOutputPorts( node ); }
396 
397  /// Returns the owner node of the given port.
398  UN_NodeID node( UN_PortID port ) const
399  { return myTopology.portNode( port ); }
400 
401 
402  /// Creates a new connection wire between the two ports.
403  /// Returns the wire data index of the created connection.
404  UN_WireID connectPorts(
405  UN_PortID src_port,
406  UN_PortID dst_port )
407  { return createWire( src_port, dst_port ); }
408 
409  /// Removes the wire connection between the two ports.
410  void disconnectPorts(
411  UN_PortID src_port,
412  UN_PortID dst_port );
413 
414  /// Returns source wires connected to the given port.
415  /// Ie, connection wires from which this port takes (receives) data.
416  const UN_WireIDList & srcWires( UN_PortID port ) const
417  { return myTopology.portSrcWires( port ); }
418 
419  /// Returns destination wires connected to the given port.
420  /// Ie, connection wires to which this port provides (sends) data.
421  const UN_WireIDList & dstWires( UN_PortID port ) const
422  { return myTopology.portDstWires( port ); }
423 
424 
425  /// Creates a connection wire between the two given ports.
426  UN_WireID createWire(
427  UN_PortID src_port,
428  UN_PortID dst_port );
429 
430  /// Returns the wire that connects the two ports, or an invalid wire ID
431  /// if the ports are not connected.
432  UN_WireID findWire(
433  UN_PortID src_port,
434  UN_PortID dst_port ) const;
435 
436  /// Deletes the wire, effectively disconnecting the ports it connects.
437  void deleteWire( UN_WireID wire );
438 
439  /// Returns the source port of the given wire.
440  /// Ie, the port that provides (sends) the data.
441  UN_PortID srcPort( UN_WireID wire ) const
442  { return myTopology.wireSrcPort( wire ); }
443 
444  /// Returns the destination port of the given wire.
445  /// Ie, the port that consumes (receives) the data.
446  UN_PortID dstPort( UN_WireID wire ) const
447  { return myTopology.wireDstPort( wire ); }
448 
449 
450  /// Creates and adds a new sticky note to the graph
451  UN_StickyNoteID createStickyNote( UN_NodeID parent_node,
452  const UT_StringRef &name = UT_StringRef(),
453  const UT_StringRef &text = UT_StringRef() );
454 
455  /// Deletes the node given its index.
456  void deleteStickyNote( UN_StickyNoteID sticky_note );
457 
458  /// Sets the name of the given sticky note.
459  void setStickyNoteName( UN_StickyNoteID sticky_note,
460  const UT_StringRef &name );
461 
462  /// @{ Returns a list of direct children of the given node (subnet).
463  const UN_StickyNoteIDList & childStickyNotes( UN_NodeID parent ) const
464  { return myTopology.nodeChildStickyNotes( parent ); }
465  const UN_StickyNoteIDList & childStickyNotes( UN_SubnetID parent ) const
466  { return myTopology.subnetChildStickyNotes( parent ); }
467  /// @}
468 
469 
470  /// @{ Returns true if the given ID refers to a valid entry
471  /// in the data buffers. Ie, such an item exists and is valid.
472  bool isValid( UN_NodeID node ) const
473  { return myNodeData.isValid( node ); }
474  bool isValid( UN_SubnetID subnet ) const
475  { return mySubnetData.isValid( subnet ); }
476  bool isValid( UN_ParmID parm ) const
477  { return myParmData.isValid( parm ); }
478  bool isValid( UN_PortID port ) const
479  { return myPortData.isValid( port ); }
480  bool isValid( UN_WireID wire ) const
481  { return myWireData.isValid( wire ); }
482  bool isValid( UN_StickyNoteID sticky_note ) const
483  { return myStickyNoteData.isValid( sticky_note ); }
484  /// @}
485 
486 
487  /// @{ Returns the container of data for the nodes in the graph.
489  { return myNodeData; }
490  const UN_NodeData & nodeData() const
491  { return myNodeData; }
492  /// @}
493 
494  /// @{ Returns the container of data for the parameters in the graph.
496  { return myParmData; }
497  const UN_ParmData & parmData() const
498  { return myParmData; }
499  /// @}
500 
501  /// @{ Returns the container of data for the ports in the graph.
503  { return myPortData; }
504  const UN_PortData & portData() const
505  { return myPortData; }
506  /// @}
507 
508  /// @{ Returns the container of data for the wires in the graph.
510  { return myWireData; }
511  const UN_WireData & wireData() const
512  { return myWireData; }
513  /// @}
514 
515  /// @{ Returns the container of data for the subnets in the graph.
517  { return mySubnetData; }
518  const UN_SubnetData & subnetData() const
519  { return mySubnetData; }
520  /// @}
521 
522  /// @{ Returns the container of data for the sticky notes in the graph.
524  { return myStickyNoteData; }
526  { return myStickyNoteData; }
527  /// @}
528 
529  /// @{ Drawing style of the connection wires in the editor
531  { myWireDrawStyle = style; }
533  { return myWireDrawStyle; }
534  /// @}
535 
536 protected:
537  /// Returns the topology object containing info about interconnections
538  /// between graph elements such as nodes, ports, and wires.
539  const UN_GraphTopology &topology() const
540  { return myTopology; }
541 
542  /// Returns a subnet for the given (parent) node,
543  /// either an existing or newly created one.
544  UN_SubnetID findOrCreateSubnet( UN_NodeID node );
545 
546  /// @{ Deletes the subnet structure associated with the given (parent) node.
547  void deleteSubnet( UN_NodeID node );
548  void deleteSubnet( UN_SubnetID subnet );
549  /// @}
550 
551  /// Sets the new order for the children.
552  // This method is needed for APEX. But it is protected, because
553  // it's easy to break topology by passing impostor children.
554  void reorderChildren( UN_SubnetID subnet,
555  const UT_Array<UN_NodeID> &child_order)
556  {
557  myTopology.reorderChildren( subnet, child_order );
558  }
559 
560  /// Updates the internal dictionaries after nodes have been moved to a
561  /// new subnet. This method is needed for APEX.
562  void updateSubnetWires( UN_SubnetID old_subnet )
563  { myTopology.updateSubnetWires( old_subnet ); }
564 
565 private:
566  /// Creates the root node.
567  void createRootNode();
568 
569  /// Makes sure the given (parent) node has an associated subnet structure.
570  void ensureSubnetCreated( UN_NodeID node );
571 
572  /// Returns the representation of a node as options, in a classic format
573  /// (array of struct) which is more human-readable.
574  UN_OptionsPtr nodeAsOptionsClassic( UN_NodeID node ) const;
575  void mergeNodeClassic( UN_NodeID node,
576  const UN_Options &graph_opts );
577 
578 private:
579  /// Contains information about parentage and connections between nodes.
580  /// Also stores relation between nodes and their parms, ports, metadata etc.
581  UN_GraphTopology myTopology;
582 
583  /// A context that describes the graph framework, and knows about
584  /// categories, and types of nodes, ports, and parameters available
585  /// in this graph.
586  UN_GraphContext myContext;
587 
588  /// A container for data of all nodes in the graph.
589  UN_NodeData myNodeData;
590 
591  /// A container for data of all parameters in the graph.
592  UN_ParmData myParmData;
593 
594  /// A container for data of all ports in the graph.
595  UN_PortData myPortData;
596 
597  /// A container for data of all wires in the graph.
598  UN_WireData myWireData;
599 
600  /// A container for data of all subnets in the graph.
601  UN_SubnetData mySubnetData;
602 
603  /// A container for data of all sticky notest in the graph.
604  UN_StickyNoteData myStickyNoteData;
605 
606  /// UI drawing style for the wire connections.
608 };
609 
610 
611 #endif
612 
UN_NodeID rootNode() const
Definition: UN_GraphData.h:151
UT_UniquePtr< UN_CustomNodeData > UN_CustomNodeDataPtr
Definition: UN_NodeData.h:24
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
const UN_NodeData & nodeData() const
Returns the container of data for the nodes in the graph.
Definition: UN_GraphData.h:490
bool isValid(UN_SubnetID subnet) const
Definition: UN_GraphData.h:474
bool isValid(UN_ParmID parm) const
Definition: UN_GraphData.h:476
void reorderChildren(UN_SubnetID subnet, const UT_Array< UN_NodeID > &child_order)
Sets the new order for the children.
Definition: UN_GraphData.h:554
UN_WireData::IDRange allWires() const
Returns a wire ID iterator range for all the valid wires in the graph.
Definition: UN_GraphData.h:276
UN_NodeID parent(UN_NodeID child) const
Definition: UN_GraphData.h:216
UN_WireDrawStyle wireDrawStyle() const
Drawing style of the connection wires in the editor.
Definition: UN_GraphData.h:532
const UN_WireIDList & childWires(UN_SubnetID parent) const
Returns a list of wires directly inside the given node (subnet).
Definition: UN_GraphData.h:282
const UN_StickyNoteIDList & childStickyNotes(UN_SubnetID parent) const
Returns a list of direct children of the given node (subnet).
Definition: UN_GraphData.h:465
const UN_PortIDList & outputPorts(UN_NodeID node) const
Returns output ports of the given node.
Definition: UN_GraphData.h:394
const UN_GraphContext & context() const
Returns the graph context used by this graph.
Definition: UN_GraphData.h:91
#define UN_API
Definition: UN_API.h:11
const UN_PortIDList & inputPorts(UN_NodeID node) const
Returns input ports of the given node.
Definition: UN_GraphData.h:390
GLTFZ_API void setNodeName(const GLTF_Index node_id, GLTF_Writer &writer, const char *name)
UN_NodeData::IDRange allNodes() const
Returns a node ID iterator range for all the valid nodes in the graph.
Definition: UN_GraphData.h:260
bool isValid(UN_PortID port) const
Definition: UN_GraphData.h:478
std::optional< T > UT_Optional
Definition: UT_Optional.h:26
UN_SubnetData::IDRange allSubnets() const
Returns an ID iterator range for all the valid subnets in the graph.
Definition: UN_GraphData.h:234
const UN_WireIDList & childWires(UN_NodeID parent) const
Returns a list of wires directly inside the given node (subnet).
Definition: UN_GraphData.h:280
UN_NodeID nonRootParent(UN_NodeID child) const
Definition: UN_GraphData.h:226
void moveNode(UN_NodeID node, UN_NodeID new_parent)
Moves a node from one parent to another.
Definition: UN_GraphData.h:240
bool isValid(UN_NodeID node) const
Definition: UN_GraphData.h:472
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
UN_SubnetData & subnetData()
Returns the container of data for the subnets in the graph.
Definition: UN_GraphData.h:516
UT_UniquePtr< UN_CustomSubnetData > UN_CustomSubnetDataPtr
Definition: UN_SubnetData.h:22
UN_API UN_PortID createPort(UN_GraphData *graph_data, UN_NodeID node_id, UN_PortKind port_kind, const UT_StringRef &port_name, const UT_StringRef &port_type_name=UN_UNDEFINED_PORT_TYPE_NAME.asRef(), const UT_StringRef &port_label=UT_StringRef(), const UT_Optional< exint > &index=std::nullopt)
UN_NodeData & nodeData()
Returns the container of data for the nodes in the graph.
Definition: UN_GraphData.h:488
UT_UniquePtr< UN_CustomParmData > UN_CustomParmDataPtr
Definition: UN_ParmData.h:22
UN_PortData::IDRange allPorts() const
Returns a port ID iterator range for all the valid ports in the graph.
Definition: UN_GraphData.h:374
const UN_SubnetData & subnetData() const
Returns the container of data for the subnets in the graph.
Definition: UN_GraphData.h:518
constexpr std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size(){return subtype_count< typename std::tuple_element< I, T >::type >::value+tuple_type_size< T, I+1 >);}template< typename T > struct type_count< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size< T, 0 >)};};template< typename T > struct subtype_count{static constexpr int value{is_mutable_container< T >::value?expected_max_vector_size:type_count< T >::value};};template< typename T, typename Enable=void > struct type_count_min{static const int value{0};};template< typename T >struct type_count_min< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_tuple_like< T >::value &&!is_wrapper< T >::value &&!is_complex< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{type_count< T >::value};};template< typename T > struct type_count_min< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr int value{1};};template< typename T >struct type_count_min< T, typename std::enable_if< is_wrapper< T >::value &&!is_complex< T >::value &&!is_tuple_like< T >::value >::type >{static constexpr int value{subtype_count_min< typename T::value_type >::value};};template< typename T, std::size_t I >constexpr typename std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size_min(){return 0;}template< typename T, std::size_t I > constexpr typename std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size_min(){return subtype_count_min< typename std::tuple_element< I, T >::type >::value+tuple_type_size_min< T, I+1 >);}template< typename T > struct type_count_min< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size_min< T, 0 >)};};template< typename T > struct subtype_count_min{static constexpr int value{is_mutable_container< T >::value?((type_count< T >::value< expected_max_vector_size)?type_count< T >::value:0):type_count_min< T >::value};};template< typename T, typename Enable=void > struct expected_count{static const int value{0};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_wrapper< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{1};};template< typename T > struct expected_count< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr int value{expected_max_vector_size};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&is_wrapper< T >::value >::type >{static constexpr int value{expected_count< typename T::value_type >::value};};enum class object_category:int{char_value=1, integral_value=2, unsigned_integral=4, enumeration=6, boolean_value=8, floating_point=10, number_constructible=12, double_constructible=14, integer_constructible=16, string_assignable=23, string_constructible=24, other=45, wrapper_value=50, complex_number=60, tuple_value=70, container_value=80,};template< typename T, typename Enable=void > struct classify_object{static constexpr object_category value{object_category::other};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, char >::value &&std::is_signed< T >::value &&!is_bool< T >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::integral_value};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&!std::is_same< T, char >::value &&!is_bool< T >::value >::type >{static constexpr object_category value{object_category::unsigned_integral};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_same< T, char >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::char_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_bool< T >::value >::type >{static constexpr object_category value{object_category::boolean_value};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_floating_point< T >::value >::type >{static constexpr object_category value{object_category::floating_point};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&std::is_assignable< T &, std::string >::value >::type >{static constexpr object_category value{object_category::string_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&(type_count< T >::value==1)&&std::is_constructible< T, std::string >::value >::type >{static constexpr object_category value{object_category::string_constructible};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::enumeration};};template< typename T > struct classify_object< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr object_category value{object_category::complex_number};};template< typename T > struct uncommon_type{using type=typename std::conditional<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&!std::is_constructible< T, std::string >::value &&!is_complex< T >::value &&!is_mutable_container< T >::value &&!std::is_enum< T >::value, std::true_type, std::false_type >::type;static constexpr bool value=type::value;};template< typename T >struct classify_object< T, typename std::enable_if<(!is_mutable_container< T >::value &&is_wrapper< T >::value &&!is_tuple_like< T >::value &&uncommon_type< T >::value)>::type >{static constexpr object_category value{object_category::wrapper_value};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::number_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&!is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::integer_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::double_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< is_tuple_like< T >::value &&((type_count< T >::value >=2 &&!is_wrapper< T >::value)||(uncommon_type< T >::value &&!is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value)||(uncommon_type< T >::value &&type_count< T >::value >=2))>::type >{static constexpr object_category value{object_category::tuple_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr object_category value{object_category::container_value};};template< typename T, enable_if_t< classify_object< T >::value==object_category::char_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"CHAR";}template< typename T, enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::integer_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"INT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::unsigned_integral, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"UINT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::floating_point||classify_object< T >::value==object_category::number_constructible||classify_object< T >::value==object_category::double_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"FLOAT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::enumeration, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"ENUM";}template< typename T, enable_if_t< classify_object< T >::value==object_category::boolean_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"BOOLEAN";}template< typename T, enable_if_t< classify_object< T >::value==object_category::complex_number, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"COMPLEX";}template< typename T, enable_if_t< classify_object< T >::value >=object_category::string_assignable &&classify_object< T >::value<=object_category::other, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"TEXT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value==1, detail::enabler >=detail::dummy >inline std::string type_name(){return type_name< typename std::decay< typename std::tuple_element< 0, T >::type >::type >);}template< typename T, std::size_t I >inline typename std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_name(){return std::string{};}template< typename T, std::size_t I >inline typename std::enable_if<(I< type_count_base< T >::value), std::string >::type tuple_name(){auto str=std::string{type_name< typename std::decay< typename std::tuple_element< I, T >::type >::type >)}+ ','+tuple_name< T, I+1 >);if(str.back()== ',') str.pop_back();return str;}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler > > std::string type_name()
Recursively generate the tuple type name.
Definition: CLI11.h:1729
const UN_WireIDList & dstWires(UN_PortID port) const
Definition: UN_GraphData.h:421
UT_UniquePtr< UN_CustomWireData > UN_CustomWireDataPtr
Definition: UN_WireData.h:22
UN_WireData & wireData()
Returns the container of data for the wires in the graph.
Definition: UN_GraphData.h:509
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
Definition: UNI_Include.h:21
bool isValid(UN_StickyNoteID sticky_note) const
Definition: UN_GraphData.h:482
UN_WireID connectPorts(UN_PortID src_port, UN_PortID dst_port)
Definition: UN_GraphData.h:404
void updateSubnetWires(UN_SubnetID old_subnet)
Definition: UN_GraphData.h:562
const UN_StickyNoteData & stickyNoteData() const
Returns the container of data for the sticky notes in the graph.
Definition: UN_GraphData.h:525
GLuint const GLchar * name
Definition: glcorearb.h:786
UN_DataSize wireCount() const
Returns the number of all wires in the graph.
Definition: UN_GraphData.h:272
UN_NodeID node(UN_ParmID parm) const
Returns the owner node of the given parameter.
Definition: UN_GraphData.h:335
UN_API UN_OptionsPtr asOptions(const UN_GraphData *graph_data)
const UN_PortIDList & ports(UN_NodeID node, UN_PortKind kind) const
Returns the ports of the given kind for the given node.
Definition: UN_GraphData.h:382
const UN_WireData & wireData() const
Returns the container of data for the wires in the graph.
Definition: UN_GraphData.h:511
UN_StickyNoteData & stickyNoteData()
Returns the container of data for the sticky notes in the graph.
Definition: UN_GraphData.h:523
void setWireDrawStyle(UN_WireDrawStyle style)
Drawing style of the connection wires in the editor.
Definition: UN_GraphData.h:530
const UN_StickyNoteIDList & childStickyNotes(UN_NodeID parent) const
Returns a list of direct children of the given node (subnet).
Definition: UN_GraphData.h:463
bool isSubnet(UN_NodeID node) const
Returns true if the given node is a subnet (ie, can have children).
Definition: UN_GraphData.h:230
const UN_NodeIDList & childNodes(UN_NodeID parent) const
Returns a list of direct children of the given node (subnet).
Definition: UN_GraphData.h:264
UN_PortID srcPort(UN_WireID wire) const
Definition: UN_GraphData.h:441
A map of string to various well defined value types.
Definition: UT_Options.h:87
bool isValid(UN_WireID wire) const
Definition: UN_GraphData.h:480
UNI_WireStyle
Definition: UNI_Include.h:38
UN_ParmData & parmData()
Returns the container of data for the parameters in the graph.
Definition: UN_GraphData.h:495
UT_UniquePtr< UN_CustomPortData > UN_CustomPortDataPtr
Definition: UN_PortData.h:23
Information about the result of a merge from another graph.
Definition: UN_Include.h:532
void moveAllChildNodes(UN_NodeID old_parent, UN_NodeID new_parent)
Moves all children of the given parent node to another one.
Definition: UN_GraphData.h:244
const UN_GraphTopology & topology() const
Definition: UN_GraphData.h:539
const UN_PortData & portData() const
Returns the container of data for the ports in the graph.
Definition: UN_GraphData.h:504
const UN_WireIDList & srcWires(UN_PortID port) const
Definition: UN_GraphData.h:416
LeafData & operator=(const LeafData &)=delete
GLuint index
Definition: glcorearb.h:786
const UN_ParmIDList & parms(UN_NodeID node) const
Returns the parameters of the given node.
Definition: UN_GraphData.h:327
const UN_ParmData & parmData() const
Returns the container of data for the parameters in the graph.
Definition: UN_GraphData.h:497
UN_DataSize portCount() const
Returns the number of all ports in the graph.
Definition: UN_GraphData.h:370
UN_PortData & portData()
Returns the container of data for the ports in the graph.
Definition: UN_GraphData.h:502
OutGridT XformOp bool bool MergePolicy merge
const UN_NodeIDList & childNodes(UN_SubnetID parent) const
Returns a list of direct children of the given node (subnet).
Definition: UN_GraphData.h:266
UN_NodeID node(UN_PortID port) const
Returns the owner node of the given port.
Definition: UN_GraphData.h:398
UN_PortID dstPort(UN_WireID wire) const
Definition: UN_GraphData.h:446
UN_NodeID parent(UN_StickyNoteID child) const
Definition: UN_GraphData.h:218
UT_UniquePtr< UN_CustomStickyNoteData > UN_CustomStickyNoteDataPtr
UT_UniquePtr< UN_Options > UN_OptionsPtr
Definition: UN_Include.h:640
UN_API UN_ParmID createParm(UN_GraphData *graph_data, UN_NodeID node_id, const UT_StringRef &parm_name, const UT_StringRef &parm_type_name=UN_UNDEFINED_PARM_TYPE_NAME.asRef())
UN_DataSize nodeCount() const
Returns the number of all nodes in the graph.
Definition: UN_GraphData.h:253