HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_NodeUtils.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_NodeUtils.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_NodeUtils_h__
13 #define __UN_NodeUtils_h__
14 
15 
16 #include "UN_API.h"
17 #include "UN_GraphData.h"
18 
19 
20 namespace UN_NodeUtils
21 {
22  /// Returns true if the node by the given ID is valid in the given graph.
23  static inline bool
24  isValid( const UN_GraphData *graph_data, UN_NodeID node_id )
25  {
26  return graph_data && graph_data->isValid( node_id );
27  }
28 
29  /// Deletes the given node from the given graph.
30  static inline void
31  deleteNode( UN_GraphData *graph_data, UN_NodeID node_id )
32  {
33  if( isValid( graph_data, node_id ))
34  graph_data->deleteNode( node_id );
35  }
36 
37  /// Sets the node name that differentiates it among its siblings.
38  static inline void
39  setName( UN_GraphData *graph_data, UN_NodeID node_id,
40  const UT_StringRef &name )
41  {
42  if( graph_data )
43  graph_data->setNodeName( node_id, name );
44  }
45 
46  /// Returns the node name that differentiates it among its siblings.
47  static inline const UT_StringHolder &
48  name( const UN_GraphData *graph_data, UN_NodeID node_id )
49  {
50  return graph_data
51  ? graph_data->nodeData().name( node_id )
53  }
54 
55  /// Sets the node's type that determines its functional behavour.
56  static inline void
57  setTypeName( UN_GraphData *graph_data, UN_NodeID node_id,
58  const UT_StringRef &type_name )
59  {
60  if( graph_data )
61  graph_data->nodeData().setTypeName( node_id, type_name );
62  }
63 
64  /// Returns the name of the node's type
65  /// that determines its functional behavour.
66  static inline const UT_StringHolder &
67  typeName( const UN_GraphData *graph_data, UN_NodeID node_id )
68  {
69  return graph_data
70  ? graph_data->nodeData().typeName( node_id )
72  }
73 
74  /// Returns the node's category that groups it with other nodes
75  /// that are operationally compatible (and connectable).
76  static inline const UT_StringHolder &
77  categoryName( const UN_GraphData *graph_data, UN_NodeID node_id )
78  {
79  return graph_data
80  ? graph_data->nodeData().categoryName( node_id )
82  }
83 
84  /// Returns the node path.
86  path( const UN_GraphData *graph_data, UN_NodeID node_id );
87 
88  /// Sets the signature on the node.
89  static inline void
90  setSignature( UN_GraphData *graph_data, UN_NodeID node_id,
91  const UT_StringRef &signature_name )
92  {
93  if( graph_data )
94  graph_data->setNodeSignature( node_id, signature_name );
95  }
96 
97  /// Returns the signature for the node.
98  static inline const UT_StringHolder &
99  signatureName( const UN_GraphData *graph_data, UN_NodeID node_id )
100  {
101  return graph_data
102  ? graph_data->nodeData().signatureName( node_id )
104  }
105 
106  /// Sets the comment on the node. The comment can show up in network editor.
107  static inline void
108  setComment( UN_GraphData *graph_data, UN_NodeID node_id,
109  const UT_StringRef &comment )
110  {
111  if( graph_data )
112  graph_data->nodeData().setComment( node_id, comment );
113  }
114 
115  /// Returns the comment for the node.
116  static inline const UT_StringHolder &
117  comment( const UN_GraphData *graph_data, UN_NodeID node_id )
118  {
119  return graph_data
120  ? graph_data->nodeData().comment( node_id )
122  }
123 
124  /// Sets the node's location. Used for the node position in network editor.
125  static inline void
126  setPosition( UN_GraphData *graph_data, UN_NodeID node_id,
127  const UT_Vector2D &position )
128  {
129  if( graph_data )
130  graph_data->nodeData().setPosition( node_id, position );
131  }
132 
133  /// Returns the node's position in the node editor pane.
134  static inline const UT_Vector2D &
135  position( const UN_GraphData *graph_data, UN_NodeID node_id )
136  {
137  return graph_data
138  ? graph_data->nodeData().position( node_id )
140  }
141 
142  /// Sets the node's color. The color is used in network editor.
143  static inline void
144  setColor( UN_GraphData *graph_data, UN_NodeID node_id,
145  const UT_Color &color )
146  {
147  if( graph_data )
148  graph_data->nodeData().setColor( node_id, color );
149  }
150 
151  /// Returns the node's color.
152  static inline const UT_Color &
153  color( const UN_GraphData *graph_data, UN_NodeID node_id )
154  {
155  return graph_data
156  ? graph_data->nodeData().color( node_id )
158  }
159 
160  /// Sets the tags for the node (copy-assignment).
161  static inline void
162  setTags( UN_GraphData *graph_data, UN_NodeID node_id,
163  const UT_StringArray &tags )
164  {
165  if( graph_data )
166  graph_data->nodeData().setTags( node_id, tags );
167  }
168 
169  /// Sets the tags for the node (move-assignment).
170  static inline void
171  setTags( UN_GraphData *graph_data, UN_NodeID node_id,
172  UT_StringArray &&tags )
173  {
174  if( graph_data )
175  graph_data->nodeData().setTags( node_id, std::move(tags) );
176  }
177 
178  /// Returns the tags moved out of the node data.
179  static inline UT_StringArray
180  stealTags( UN_GraphData *graph_data, UN_NodeID node_id )
181  {
182  return graph_data
183  ? graph_data->nodeData().stealTags( node_id )
184  : UT_StringArray();
185  }
186 
187  /// Sets tags in-place, which is faster than setting the whole dictionary.
188  /// Intended usage:
189  /// updateTags(g, n, [&value](auto &t) { t.set("key", value); });
190  template <typename OP>
191  static inline void
192  updateTags( UN_GraphData *graph_data, UN_NodeID node_id, const OP &op )
193  {
194  if( graph_data )
195  graph_data->nodeData().updateTags( node_id, op );
196  }
197 
198  /// Returns the node's tags.
199  static inline const UT_StringArray &
200  tags( const UN_GraphData *graph_data, UN_NodeID node_id )
201  {
202  return graph_data
203  ? graph_data->nodeData().tags( node_id )
205  }
206 
207  /// Sets the metadata for the node (copy-assignment).
208  static inline void
209  setMetadata( UN_GraphData *graph_data, UN_NodeID node_id,
210  const UN_MetadataHolder &metadata )
211  {
212  if( graph_data )
213  graph_data->nodeData().setMetadata( node_id, metadata );
214  }
215 
216  /// Sets the metadata for the node (move-assignment).
217  static inline void
218  setMetadata( UN_GraphData *graph_data, UN_NodeID node_id,
219  UN_MetadataHolder &&metadata )
220  {
221  if( graph_data )
222  graph_data->nodeData().setMetadata( node_id, std::move(metadata) );
223  }
224 
225  /// Returns the metadata moved out of the node data.
226  static inline UN_MetadataHolder
227  stealMetadata( UN_GraphData *graph_data, UN_NodeID node_id )
228  {
229  return graph_data
230  ? graph_data->nodeData().stealMetadata( node_id )
231  : UN_MetadataHolder();
232  }
233 
234  /// Sets metadata in-place, which is faster than setting whole dictionary.
235  /// Intended usage:
236  /// updateMetadata(g, n, [&value](auto &m) { m->set("key", value) });
237  template <typename OP>
238  static inline void
239  updateMetadata( UN_GraphData *graph_data, UN_NodeID node_id, const OP &op )
240  {
241  if( graph_data )
242  graph_data->nodeData().updateMetadata( node_id, op );
243  }
244 
245  /// Simpler method to update a single metadata value in-place.
246  static inline void
247  updateMetadata( UN_GraphData *graph_data,
248  UN_NodeID node_id,
249  const UT_StringHolder &key,
251  {
252  if( graph_data )
253  graph_data->nodeData().updateMetadata(
254  node_id, key, std::move(value) );
255  }
256 
257  /// Returns the node's metadata.
258  static inline const UN_MetadataHolder &
259  metadata( const UN_GraphData *graph_data, UN_NodeID node_id )
260  {
261  return graph_data
262  ? graph_data->nodeData().metadata( node_id )
264  }
265 
266  /// Adds and returns a new parameter to this node.
267  /// If another parameter of a given name already exists, returns an
268  /// invalid parameter, indicating a failure due to the name collision.
269  UN_API UN_ParmID
270  createParm( UN_GraphData *graph_data, UN_NodeID node_id,
271  const UT_StringRef &parm_name,
272  const UT_StringRef &parm_type_name =
273  UN_UNDEFINED_PARM_TYPE_NAME.asRef());
274 
275  /// Returns the IDs of the given node's parameters.
276  static inline const UN_ParmIDList &
277  parms( const UN_GraphData *graph_data, UN_NodeID node_id )
278  {
279  static UN_ParmIDList theEmpty;
280  return graph_data ? graph_data->parms( node_id ) : theEmpty;
281  }
282 
283  // An iterator and a range for iterating over node parameter IDs.
284  using ParmIterator = UN_ParmIDList::const_iterator;
286 
287  /// Returns a range for traversing the parameters of the given node.
288  /// NOTE, the iterators hold a reference to the underlying parm array,
289  /// and therefore parms can't be added/removed during the iteration.
290  /// For adding/removing parms, use parms() function and make a copy.
291  static inline ParmRange
292  parmRange( const UN_GraphData *graph_data, UN_NodeID node_id )
293  {
294  const UN_ParmIDList &parm_ids = parms( graph_data, node_id );
295  return ParmRange(
296  ParmIterator( parm_ids.begin() ),
297  ParmIterator( parm_ids.end() ));
298  }
299 
300  /// Returns a parameter by the given name, or an invalid param if not found.
301  static inline UN_ParmID
302  findParm( const UN_GraphData *graph_data, UN_NodeID node_id,
303  const UT_StringRef &parm_name )
304  {
305  return graph_data
306  ? graph_data->parm( node_id, parm_name )
307  : UN_ParmID();
308  }
309 
310  /// Returns the names of the node parameters.
312  parmNames( const UN_GraphData *graph_data, UN_NodeID node_id );
313 
314  /// Returns the type names of the node parameters.
316  parmTypeNames( const UN_GraphData *graph_data, UN_NodeID node_id );
317 
318 
319  /// Adds a new port to this node and returns its ID.
320  /// If another port of a given name already exists, returns an
321  /// invalid port, indicating a failure due to the name collision.
322  UN_API UN_PortID
323  createPort( UN_GraphData *graph_data, UN_NodeID node_id,
324  UN_PortKind port_kind,
325  const UT_StringRef &port_name,
326  const UT_StringRef &port_type_name =
327  UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
328  const UT_StringRef &port_label = UT_StringRef(),
329  const UT_Optional<exint> &index = std::nullopt);
330 
331  /// Adds a new input port to this node and returns its ID.
332  /// If another port of a given name already exists, returns an
333  /// invalid port, indicating a failure due to the name collision.
334  static inline UN_PortID
335  createInputPort( UN_GraphData *graph_data, UN_NodeID node_id,
336  const UT_StringRef &port_name,
337  const UT_StringRef &port_type_name =
338  UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
339  const UT_StringRef &port_label = UT_StringRef(),
340  const UT_Optional<exint> &index = std::nullopt)
341  {
342  return createPort( graph_data, node_id, UN_PortKind::Input,
343  port_name, port_type_name, port_label, index );
344  }
345 
346  /// Adds a new output port to this node and returns its ID.
347  /// If another port of a given name already exists, returns an
348  /// invalid port, indicating a failure due to the name collision.
349  static inline UN_PortID
350  createOutputPort( UN_GraphData *graph_data, UN_NodeID node_id,
351  const UT_StringRef &port_name,
352  const UT_StringRef &port_type_name =
353  UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
354  const UT_StringRef &port_label = UT_StringRef(),
355  const UT_Optional<exint> &index = std::nullopt)
356  {
357  return createPort( graph_data, node_id, UN_PortKind::Output,
358  port_name, port_type_name, port_label, index );
359  }
360 
361 
362  /// Returns a node port by the given name, or an invalid ID if not found.
363  static inline UN_PortID
364  findPort( const UN_GraphData *graph_data, UN_NodeID node_id,
365  UN_PortKind port_kind, const UT_StringRef &port_name )
366  {
367  return graph_data
368  ? graph_data->port( node_id, port_kind, port_name )
369  : UN_PortID();
370  }
371 
372  /// Returns an input port by the given name, or invalid ID if not found.
373  static inline UN_PortID
374  findInputPort( const UN_GraphData *graph_data, UN_NodeID node_id,
375  const UT_StringRef &port_name )
376  {
377  return findPort( graph_data, node_id, UN_PortKind::Input, port_name );
378  }
379 
380  /// Returns an output port by the given name, or invalid ID if not found.
381  static inline UN_PortID
382  findOutputPort( const UN_GraphData *graph_data, UN_NodeID node_id,
383  const UT_StringRef &port_name )
384  {
385  return findPort( graph_data, node_id, UN_PortKind::Output, port_name );
386  }
387 
388 
389  /// Returns an existing port by the given name, or creates and
390  /// returns a new one (with the given type and label) if not found.
391  static inline UN_PortID
392  findOrCreatePort( UN_GraphData *graph_data, UN_NodeID node_id,
393  UN_PortKind port_kind,
394  const UT_StringRef &port_name,
395  const UT_StringRef &port_type_name =
396  UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
397  const UT_StringRef &port_label = UT_StringRef() )
398  {
399  auto port = findPort( graph_data, node_id, port_kind, port_name );
400  if( !port )
401  port = createPort( graph_data, node_id,
402  port_kind, port_name, port_type_name, port_label );
403  return port;
404  }
405 
406  /// Returns an existing input port by the given name, or creates and
407  /// returns a new one (with the given type and label) if not found.
408  static inline UN_PortID
409  findOrCreateInputPort( UN_GraphData *graph_data, UN_NodeID node_id,
410  const UT_StringRef &port_name,
411  const UT_StringRef &port_type_name =
412  UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
413  const UT_StringRef &port_label = UT_StringRef() )
414  {
415  return findOrCreatePort( graph_data, node_id,
416  UN_PortKind::Input, port_name, port_type_name, port_label );
417  }
418 
419  /// Returns an existing output port by the given name, or creates and
420  /// returns a new one (with the given type and label) if not found.
421  static inline UN_PortID
422  findOrCreateOutputPort( UN_GraphData *graph_data, UN_NodeID node_id,
423  const UT_StringRef &port_name,
424  const UT_StringRef &port_type_name =
425  UN_UNDEFINED_PORT_TYPE_NAME.asRef(),
426  const UT_StringRef &port_label = UT_StringRef() )
427  {
428  return findOrCreatePort( graph_data, node_id,
429  UN_PortKind::Output, port_name, port_type_name, port_label );
430  }
431 
432 
433  /// Returns ports of the given node.
434  static inline const UN_PortIDList &
435  ports( const UN_GraphData *graph_data, UN_NodeID node_id,
436  UN_PortKind port_kind )
437  {
438  static UN_PortIDList theEmpty;
439  return graph_data ? graph_data->ports( node_id, port_kind ) : theEmpty;
440  }
441 
442  /// Returns input ports of the given node.
443  static inline const UN_PortIDList &
444  inputPorts( const UN_GraphData *graph_data, UN_NodeID node_id )
445  {
446  return ports( graph_data, node_id, UN_PortKind::Input );
447  }
448 
449  /// Returns output ports of the given node.
450  static inline const UN_PortIDList &
451  outputPorts( const UN_GraphData *graph_data, UN_NodeID node_id )
452  {
453  return ports( graph_data, node_id, UN_PortKind::Output );
454  }
455 
456 
457  /// An iterator and a range for iterating over node port IDs.
458  using PortIterator = UN_PortIDList::const_iterator;
460 
461  /// Returns a range for traversing the ports of the given node.
462  /// NOTE, the iterators hold a reference to the underlying port array,
463  /// and therefore ports can't be added/removed during the iteration.
464  /// For adding/removing ports, use ports() function and make a copy.
465  static inline PortRange
466  portRange( const UN_GraphData *graph_data, UN_NodeID node_id,
467  UN_PortKind port_kind )
468  {
469  const UN_PortIDList &port_ids = ports( graph_data, node_id, port_kind );
470  return PortRange(
471  PortIterator( port_ids.begin() ),
472  PortIterator( port_ids.end() ));
473  }
474 
475  /// Returns a range for traversing the input ports of the given node.
476  static inline PortRange
477  inputPortRange( const UN_GraphData *graph_data, UN_NodeID node_id )
478  {
479  return portRange( graph_data, node_id, UN_PortKind::Input );
480  }
481 
482  /// Returns a range for traversing the output ports of the given node.
483  static inline PortRange
484  outputPortRange( const UN_GraphData *graph_data, UN_NodeID node_id )
485  {
486  return portRange( graph_data, node_id, UN_PortKind::Output );
487  }
488 
489 
490  /// An iterator and a range for iterating over node port IDs
491  /// in reverse order.
492  using PortReverseIterator = UN_PortIDList::const_reverse_iterator;
494 
495  /// Returns a range for traversing the ports of the given node
496  /// in a reverse order than the one in node's port array.
497  /// NOTE, the iterators hold a reference to the underlying port array,
498  /// and therefore ports can't be added/removed during the iteration.
499  /// For adding/removing ports, use ports() function and make a copy.
500  static inline PortReverseRange
501  portReverseRange( const UN_GraphData *graph_data, UN_NodeID node_id,
502  UN_PortKind port_kind )
503  {
504  const UN_PortIDList &port_ids = ports( graph_data, node_id, port_kind );
505  return PortReverseRange(
506  PortReverseIterator( port_ids.rbegin() ),
507  PortReverseIterator( port_ids.rend() ));
508  }
509 
510  /// Returns a range for traversing the input ports of the given node
511  /// in a reverse order than the one in node's port array.
512  static inline PortReverseRange
513  inputPortReverseRange( const UN_GraphData *graph_data, UN_NodeID node_id )
514  {
515  return portReverseRange( graph_data, node_id, UN_PortKind::Input );
516  }
517 
518  /// Returns a range for traversing the output ports of the given node
519  /// in a reverse order than the one in node's port array.
520  static inline PortReverseRange
521  outputPortReverseRange( const UN_GraphData *graph_data, UN_NodeID node_id )
522  {
523  return portReverseRange( graph_data, node_id, UN_PortKind::Output );
524  }
525 
526 
527  /// Returns the names of the node ports of a given kind.
529  portNames( const UN_GraphData *graph_data, UN_NodeID node_id,
530  UN_PortKind port_kind );
531 
532  /// Returns the input port names of the given node.
533  static inline UT_Array< UT_StringHolder >
534  inputPortNames( const UN_GraphData *graph_data, UN_NodeID node_id )
535  {
536  return portNames( graph_data, node_id, UN_PortKind::Input );
537  }
538 
539  /// Returns the output port names of the given node.
540  static inline UT_Array< UT_StringHolder >
541  outputPortNames( const UN_GraphData *graph_data, UN_NodeID node_id )
542  {
543  return portNames( graph_data, node_id, UN_PortKind::Output );
544  }
545 
546 
547  /// Returns the type names of the node ports of a given kind.
549  portTypeNames( const UN_GraphData *graph_data, UN_NodeID node_id,
550  UN_PortKind port_kind );
551 
552  /// Returns the input port type names of the given node.
553  static inline UT_Array< UT_StringHolder >
554  inputPortTypeNames( const UN_GraphData *graph_data, UN_NodeID node_id )
555  {
556  return portTypeNames( graph_data, node_id, UN_PortKind::Input );
557  }
558 
559  /// Returns the output port type names of the given node.
560  static inline UT_Array< UT_StringHolder >
561  outputPortTypeNames( const UN_GraphData *graph_data, UN_NodeID node_id )
562  {
563  return portTypeNames( graph_data, node_id, UN_PortKind::Output );
564  }
565 
566 
567  /// Returns true if any of the node's input ports has a connected source
568  /// wire (feeding data from a source port).
569  UN_API bool
571  const UN_GraphData *graph_data, UN_NodeID node_id);
572 
573  /// Returns true if any of the node's output ports has a connected
574  /// destination wire feeding data to a destination port.
575  UN_API bool
577  const UN_GraphData *graph_data, UN_NodeID node_id);
578 
579 
580  /// Returns a node name that is not taken by any of this nodes' children,
581  /// given the suggested candidate child name.
583  findValidUniqueChildNodeName( const UN_GraphData *graph_data, UN_NodeID node_id,
584  const UT_StringRef &child_name = UT_StringRef() );
585 
586  /// Returns true if the given node can have child nodes inside.
587  static inline bool
588  isSubnet( const UN_GraphData *graph_data, UN_NodeID node_id )
589  {
590  return graph_data && graph_data->isSubnet( node_id );
591  }
592 
593  /// Creates and returns a new node that is a child of this node.
594  UN_API UN_NodeID
595  createChildNode( UN_GraphData *graph_data, UN_NodeID parent_id,
596  const UT_StringRef &child_name = UT_StringRef(),
597  const UT_StringRef &child_type = UT_StringRef(),
598  const UT_StringRef &child_category = UT_StringRef());
599 
600  /// Returns a child node by the given name, or an invalid ID if not found.
601  static inline UN_NodeID
602  findChildNode( const UN_GraphData *graph_data, UN_NodeID parent_id,
603  const UT_StringRef &node_name )
604  {
605  return graph_data
606  ? graph_data->findChildNode( parent_id, node_name )
607  : UN_NodeID();
608  }
609 
610  /// Returns an ID of a node at a given path, or an invalid ID if not found.
611  ///
612  /// @parm parent - When the given node path is relative,
613  /// this is the anchor node from which the relative path is followed
614  /// to find the desired node.
615  ///
616  /// @parm node_path - The node path identifying the node to find.
617  /// This can be either an absolute path (starting with a slash, '/')
618  /// or a relative path (in which case the parent parameter is used
619  /// as a starting point).
620  /// In particular, when the node path is just a name, this function
621  /// will look for a child by that name directly inside the given parent.
622  /// The path can contain '.' for the current node, and '..' for
623  /// the parent node.
624  static inline UN_NodeID
625  findNode( const UN_GraphData *graph_data, UN_NodeID parent_id,
626  const UT_StringRef &node_path )
627  {
628  return graph_data
629  ? graph_data->findNode( parent_id, node_path )
630  : UN_NodeID();
631  }
632 
633  /// Deletes the child node from the graph (removing it from this network).
634  UN_API void
635  deleteChildNode( UN_GraphData *graph_data, UN_NodeID parent_id,
636  const UT_StringRef &child_name ) ;
637 
638 
639  /// Returns the node IDs of the given node's children.
640  static inline const UN_NodeIDList &
641  childNodes( const UN_GraphData *graph_data, UN_NodeID parent_id )
642  {
643  static UN_NodeIDList theEmpty;
644  return graph_data ? graph_data->childNodes( parent_id ) : theEmpty;
645  }
646 
647  /// An iterator and a range for iterating over child node IDs.
648  using ChildNodeIterator = UN_NodeIDList::const_iterator;
650 
651  /// Returns a range for traversing the child nodes of the given node.
652  /// NOTE, the iterators hold a reference to the underlying node array, and
653  /// therefore child nodes can't be added/removed during the iteration.
654  /// For adding/removing nodes use childNodes() function and make a copy.
655  static inline ChildNodeRange
656  childNodeRange( const UN_GraphData *graph_data, UN_NodeID node_id )
657  {
658  const UN_NodeIDList &child_ids = childNodes( graph_data, node_id );
659  return ChildNodeRange(
660  ChildNodeIterator( child_ids.begin() ),
661  ChildNodeIterator( child_ids.end() ));
662  }
663 
664  /// Returns the names of the children nodes of the given parent node.
666  childNodeNames( const UN_GraphData *graph_data, UN_NodeID node_id );
667 
668 
669  /// An iterator for traversing the descendant nodes (children,
670  /// grandchildren, etc) of a given ancestor node.
672  {
673  public:
674  using iterator_category = std::input_iterator_tag;
675  using value_type = UN_NodeID;
676  using difference_type = std::ptrdiff_t;
677  using pointer = value_type*;
679 
680  /// Constructor for the start iterator of the given node ancestral tree.
681  DescendantNodeIterator( const UN_GraphData *graph_data, UN_NodeID node_id )
682  : myGraphData( graph_data )
683  {
684  pushChildren( node_id );
685  }
686 
687  /// Constructor for the end iterator.
689  : myGraphData( graph_data )
690  {}
691 
692  /// @{ Comparison operators.
693  bool operator ==( const DescendantNodeIterator &other ) const
694  {
695  // Loops compare iterators only against the 'end' iterator,
696  // which has an empty array, so comparing sizes is enough.
697  return myNodeIDs.size() == other.myNodeIDs.size()
698  && myGraphData == other.myGraphData;
699  }
700 
701  bool operator !=( const DescendantNodeIterator &other ) const
702  {
703  return !(operator==(other));
704  }
705  /// @}
706 
707  /// Increment operator.
709  {
710  UN_NodeID node_id = popChild();
711  pushChildren( node_id );
712  return *this;
713  }
714 
715 
716  /// Returns the ID of the current node.
717  UN_NodeID operator*() const
718  {
719  return !myNodeIDs.isEmpty() ? myNodeIDs.last() : UN_NodeID();
720  }
721 
722  /// Returns the underlying graph in which the current node exists.
723  const UN_GraphData *graph() const
724  {
725  return myGraphData;
726  }
727 
728 
729  private:
730  /// Adds the children of the given node to the stack for traversal.
731  void pushChildren( UN_NodeID parent_id )
732  {
733  if( !myGraphData )
734  return;
735 
736  myNodeIDs.concat( myGraphData->childNodes( parent_id ));
737  }
738 
739  /// Removes and returns the top (the current) child (or descendant)
740  /// node on the traversal stack.
741  UN_NodeID popChild()
742  {
743  UN_NodeID data_id;
744  if( !myNodeIDs.isEmpty() )
745  {
746  data_id = myNodeIDs.last();
747  myNodeIDs.removeLast();
748  }
749 
750  return data_id;
751  }
752 
753  private:
754  /// The graph that owns the node objects.
755  const UN_GraphData *myGraphData = nullptr;
756 
757  /// The stack of pending node IDs to traverse.
758  /// The top of the stack is considered to be the "current" node.
759  UN_NodeIDList myNodeIDs;
760  }; // end: DescendantNodeIterator
761 
762  /// A range for traversing the descendant nodes of a given ancestor node.
764 
765  /// Returns a range for traversing the descendant nodes (children,
766  /// grandchildren, etc) of a given ancestor node.
767  static inline DescendantNodeRange
768  descendantNodeRange( const UN_GraphData *graph_data, UN_NodeID node_id )
769  {
770  return DescendantNodeRange(
771  DescendantNodeIterator( graph_data, node_id ),
772  DescendantNodeIterator( graph_data ));
773  }
774 
775 
776  /// Returns the source wires connected to all of the ports
777  /// of the given kind on the given node.
778  /// Source wires carry data to the given node.
779  UN_API UN_WireIDList
780  srcWires( const UN_GraphData *graph_data, UN_NodeID node_id,
781  UN_PortKind port_kind );
782 
783  /// Returns the source wires connected to all of the input ports
784  /// on the given node. These are the wires that carry the data received
785  /// (and consumed) by the given node.
786  static inline const UN_WireIDList
787  inputSrcWires( const UN_GraphData *graph_data, UN_NodeID node_id )
788  {
789  return srcWires( graph_data, node_id, UN_PortKind::Input );
790  }
791 
792  /// Returns the source wires connected to all of the output ports
793  /// on the given node.
794  /// These are the wires that carry the data received by the given node,
795  /// on output ports, although the node usually does not consume
796  /// that data; it forwards it to any dst wires connected to the output
797  /// ports. This is most commonly applies to the subnet nodes.
798  static inline const UN_WireIDList
799  outputSrcWires( const UN_GraphData *graph_data, UN_NodeID node_id )
800  {
801  return srcWires( graph_data, node_id, UN_PortKind::Output );
802  }
803 
804 
805  /// Returns the destination wires connected to the of all the ports
806  /// of the given kind on the given node.
807  /// Destination wires carry data from the given node.
808  UN_API UN_WireIDList
809  dstWires( const UN_GraphData *graph_data, UN_NodeID node_id,
810  UN_PortKind port_kind );
811 
812  /// Returns the destination wires connected to all of the input ports
813  /// on the given node.
814  /// These are the wires that carry the data sent by the given node,
815  /// on input ports, although the node usually does not produce that data;
816  /// it forwards it from any src wires connected to the input ports.
817  /// This is most commonly applies to the subnet nodes.
818  static inline const UN_WireIDList
819  inputDstWires( const UN_GraphData *graph_data, UN_NodeID node_id )
820  {
821  return dstWires( graph_data, node_id, UN_PortKind::Input );
822  }
823 
824  /// Returns the destination wires connected to all of the output ports
825  /// on the given node. These are the wires that carry the data produced
826  /// (and sent) by the given node.
827  static inline const UN_WireIDList
828  outputDstWires( const UN_GraphData *graph_data, UN_NodeID node_id )
829  {
830  return dstWires( graph_data, node_id, UN_PortKind::Output );
831  }
832 
833 
834 
835  /// Returns the IDs of the given node's child wires
836  /// (ie wires directly inside the node).
837  static inline const UN_WireIDList &
838  childWires( const UN_GraphData *graph_data, UN_NodeID parent_id )
839  {
840  static UN_WireIDList theEmpty;
841  return graph_data ? graph_data->childWires( parent_id ) : theEmpty;
842  }
843 
844  /// A range for traversing the wires contained directly inside a node.
845  using ChildWireIterator = UN_WireIDList::const_iterator;
847 
848  /// Returns a range for traversing the wires contained directly inside
849  /// the given node node.
850  static inline ChildWireRange
851  childWireRange( const UN_GraphData *graph_data, UN_NodeID node_id )
852  {
853  const UN_WireIDList &child_ids = childWires( graph_data, node_id );
854  return ChildWireRange(
855  ChildWireIterator( child_ids.begin() ),
856  ChildWireIterator( child_ids.end() ));
857  }
858 
859 
860  /// An iterator for traversing the wires deep inside the given node.
862  {
863  public:
864  using iterator_category = std::input_iterator_tag;
865  using value_type = UN_WireID;
866  using difference_type = std::ptrdiff_t;
867  using pointer = value_type*;
869 
870  /// Constructor for the start and end iterator for node's wires.
871  DescendantWireIterator( const UN_GraphData *graph_data, UN_NodeID node_id )
872  : myGraphData( graph_data )
873  {
874  myNodeIDs.append( node_id );
875  advance();
876  }
877 
878  /// Constructor for the end iterator.
880  : myGraphData( graph_data )
881  {}
882 
883 
884  /// Increment operator.
886  {
887  advance();
888  return *this;
889  }
890 
891  /// @{ Comparison operators.
892  bool operator ==( const DescendantWireIterator &other ) const
893  {
894  // Loops compare iterators only against the 'end' iterator,
895  // which has an empty array, so comparing sizes is enough.
896  return myWireIDs.size() == other.myWireIDs.size()
897  && myGraphData == other.myGraphData;
898  }
899 
900  bool operator !=( const DescendantWireIterator &other ) const
901  {
902  return !(operator==(other));
903  }
904  /// @}
905 
906  /// Returns the ID of the current wire.
907  UN_WireID operator*() const
908  {
909  return !myWireIDs.isEmpty() ? myWireIDs.last() : UN_WireID();
910  }
911 
912  /// Returns the underlying graph in which the current node exists.
913  const UN_GraphData *graph() const
914  {
915  return myGraphData;
916  }
917 
918  private:
919  /// Moves to the next wire in the iteration.
920  void advance()
921  {
922  if( !myWireIDs.isEmpty() )
923  myWireIDs.removeLast();
924 
925  // If needed, get the next batch of wires to traverse.
926  while( myWireIDs.isEmpty() && !myNodeIDs.isEmpty() )
927  {
928  auto next_node_id = myNodeIDs.last();
929  myNodeIDs.removeLast();
930 
931  if( myGraphData )
932  {
933  myNodeIDs.concat( myGraphData->childNodes( next_node_id ));
934  myWireIDs.concat( myGraphData->childWires( next_node_id ));
935  }
936  }
937  }
938 
939  private:
940  /// The graph that owns the node objects.
941  const UN_GraphData *myGraphData = nullptr;
942 
943  /// The list of pending wires in the current node to traverse.
944  /// The top of the stack is considered to be the "current" wire.
945  UN_WireIDList myWireIDs;
946 
947  /// The stack of pending nodes to traverse.
948  UN_NodeIDList myNodeIDs;
949  }; // end: DescendantWireIterator
950 
951 
952  /// An range for traversing the wires between the descendants
953  /// (children, grandchildren, etc) inside a node.
955 
956  /// Returns a range for traversing the wires between the descendants
957  /// (children, grandchildren, etc) inside the given node.
958  static inline DescendantWireRange
959  descendantWireRange( const UN_GraphData *graph_data, UN_NodeID node_id )
960  {
961  return DescendantWireRange(
962  DescendantWireIterator( graph_data, node_id ),
963  DescendantWireIterator( graph_data ));
964  }
965 
966 
967  /// Creates and returns a new sticky note that is a child of this node.
968  UN_API UN_StickyNoteID
969  createChildStickyNote( UN_GraphData *graph_data, UN_NodeID parent_id,
970  const UT_StringRef &sticky_note_name = UT_StringRef(),
971  const UT_StringRef &sticky_note_text = UT_StringRef());
972 
973  /// Returns a child sticky note by the given name,
974  /// or an invalid ID if not found.
975  static inline UN_StickyNoteID
976  findChildStickyNote( const UN_GraphData *graph_data, UN_NodeID parent_id,
977  const UT_StringRef &sticky_note_name )
978  {
979  return graph_data
980  ? graph_data->findChildStickyNote( parent_id, sticky_note_name )
981  : UN_StickyNoteID();
982  }
983 
984  /// Deletes the child sticky note from the graph
985  /// (removing it from this network).
986  UN_API void
987  deleteChildStickyNote( UN_GraphData *graph_data, UN_NodeID parent_id,
988  const UT_StringRef &child_sticky_note_name );
989 
990  /// Returns the sticky notes IDs directly inside the given parent node.
991  static inline const UN_StickyNoteIDList &
992  childStickyNotes( const UN_GraphData *graph_data, UN_NodeID parent_id )
993  {
994  static UN_StickyNoteIDList theEmpty;
995  return graph_data ? graph_data->childStickyNotes(parent_id) : theEmpty;
996  }
997 
998 
999  /// Returns the options object representing this node.
1000  /// This can be then used for serialization to JSON, etc.
1002  asOptions( const UN_GraphData *graph_data, UN_NodeID node_id );
1003 
1004  /// Load and set the node based on the given options.
1005  UN_API void
1006  setFromOptions( UN_GraphData *graph_data, UN_NodeID node_id,
1007  const UN_Options &node_opts );
1008 }
1009 
1010 #endif
1011 
void setMetadata(UN_NodeID node_id, const UN_MetadataHolder &metadata)
Sets node's new metadata via copy-assignment.
Definition: UN_NodeData.h:349
void updateMetadata(UN_NodeID node_id, const OP &op)
Definition: UN_NodeData.h:329
UN_WireIDList::const_iterator ChildWireIterator
A range for traversing the wires contained directly inside a node.
Definition: UN_NodeUtils.h:845
const UT_StringHolder & signatureName(UN_NodeID node_id) const
Returns the node's signature.
Definition: UN_NodeData.h:243
const UT_Vector2D & position(UN_NodeID node_id) const
Returns the node's location in the graph editor.
Definition: UN_NodeData.h:267
static const auto theDefPos
Definition: UN_NodeData.h:491
void setNodeSignature(UN_NodeID node_id, const UT_StringRef &signature_name)
Sets the signature for the given node.
UN_API UN_OptionsPtr asOptions(const UN_GraphData *graph_data, UN_NodeID node_id)
DescendantNodeIterator(const UN_GraphData *graph_data, UN_NodeID node_id)
Constructor for the start iterator of the given node ancestral tree.
Definition: UN_NodeUtils.h:681
UN_API void deleteChildStickyNote(UN_GraphData *graph_data, UN_NodeID parent_id, const UT_StringRef &child_sticky_note_name)
bool operator!=(const DescendantWireIterator &other) const
Comparison operators.
Definition: UN_NodeUtils.h:900
const UT_StringHolder & categoryName(UN_NodeID node_id) const
Definition: UN_NodeData.h:236
GLsizei const GLfloat * value
Definition: glcorearb.h:824
const UN_GraphData * graph() const
Returns the underlying graph in which the current node exists.
Definition: UN_NodeUtils.h:723
void setPosition(UN_NodeID node_id, const UT_Vector2D &position)
Sets the node's location in the graph editor.
Definition: UN_NodeData.h:261
UN_MetadataHolder stealMetadata(UN_NodeID node_id)
Returns node's metadata moved from the data buffer entry.
Definition: UN_NodeData.h:367
static const UN_MetadataHolder theDefMetadata
Definition: UN_NodeData.h:489
#define UN_API
Definition: UN_API.h:11
static const auto theDefColor
Definition: UN_NodeData.h:490
UN_ParmID parm(UN_NodeID node, const UT_StringRef &parm_name) const
Returns the parameter of a given name on a given node.
UT_IteratorRange< ChildWireIterator > ChildWireRange
Definition: UN_NodeUtils.h:846
std::optional< T > UT_Optional
Definition: UT_Optional.h:26
UN_NodeID operator*() const
Returns the ID of the current node.
Definition: UN_NodeUtils.h:717
UN_API UT_Array< UT_StringHolder > childNodeNames(const UN_GraphData *graph_data, UN_NodeID node_id)
Returns the names of the children nodes of the given parent node.
UN_API void setFromOptions(UN_GraphData *graph_data, UN_NodeID node_id, const UN_Options &node_opts)
Load and set the node based on the given options.
const UN_WireIDList & childWires(UN_NodeID parent) const
Returns a list of wires directly inside the given node (subnet).
Definition: UN_GraphData.h:280
UT_IteratorRange< DescendantNodeIterator > DescendantNodeRange
A range for traversing the descendant nodes of a given ancestor node.
Definition: UN_NodeUtils.h:763
UT_IteratorRange< DescendantWireIterator > DescendantWireRange
Definition: UN_NodeUtils.h:954
UN_API bool isAnyOutputPortConnectedToDst(const UN_GraphData *graph_data, UN_NodeID node_id)
bool isValid(UN_NodeID node) const
Definition: UN_GraphData.h:472
bool operator==(const DescendantWireIterator &other) const
Comparison operators.
Definition: UN_NodeUtils.h:892
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_ParmIDList::const_iterator ParmIterator
Definition: UN_NodeUtils.h:284
UN_NodeData & nodeData()
Returns the container of data for the nodes in the graph.
Definition: UN_GraphData.h:488
DescendantNodeIterator(const UN_GraphData *graph_data)
Constructor for the end iterator.
Definition: UN_NodeUtils.h:688
UN_API UT_StringHolder path(const UN_GraphData *graph_data, UN_NodeID node_id)
Returns the node path.
UN_API UN_NodeID createChildNode(UN_GraphData *graph_data, UN_NodeID parent_id, const UT_StringRef &child_name=UT_StringRef(), const UT_StringRef &child_type=UT_StringRef(), const UT_StringRef &child_category=UT_StringRef())
Creates and returns a new node that is a child of this node.
static const UT_StringHolder theDefComment
Definition: UN_NodeData.h:487
static const UT_StringHolder theEmptyString
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
UN_API UT_Array< UT_StringHolder > parmTypeNames(const UN_GraphData *graph_data, UN_NodeID node_id)
Returns the type names of the node parameters.
DescendantWireIterator(const UN_GraphData *graph_data, UN_NodeID node_id)
Constructor for the start and end iterator for node's wires.
Definition: UN_NodeUtils.h:871
void setTypeName(UN_NodeID node_id, const UT_StringRef &type_name)
Sets the node's type that determines its functional behavour.
Definition: UN_NodeData.h:223
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
Definition: UNI_Include.h:21
UT_IteratorRange< PortReverseIterator > PortReverseRange
Definition: UN_NodeUtils.h:493
void setNodeName(UN_NodeID node_id, const UT_StringRef &name)
Sets the name of the given node.
UN_API UT_Array< UT_StringHolder > parmNames(const UN_GraphData *graph_data, UN_NodeID node_id)
Returns the names of the node parameters.
UN_API UT_Array< UT_StringHolder > portTypeNames(const UN_GraphData *graph_data, UN_NodeID node_id, UN_PortKind port_kind)
Returns the type names of the node ports of a given kind.
GLuint const GLchar * name
Definition: glcorearb.h:786
UN_PortID port(UN_NodeID node, UN_PortKind kind, const UT_StringRef &port_name) const
Returns the port of a given kind on a given node.
UN_StickyNoteID findChildStickyNote(UN_NodeID parent, const UT_StringRef &child_name) const
Returns a node ID of a child in a given subnet given its name.
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
UT_OptionsHolder UN_MetadataHolder
void updateTags(UN_NodeID node_id, const OP &op)
Definition: UN_NodeData.h:297
UN_NodeID findNode(UN_NodeID current_node, const UT_StringRef &node_path) const
UT_StringArray stealTags(UN_NodeID node_id)
Returns node tags moved from the data buffer entry.
Definition: UN_NodeData.h:321
UT_IteratorRange< PortIterator > PortRange
Definition: UN_NodeUtils.h:459
UN_NodeID findChildNode(UN_NodeID parent, const UT_StringRef &child_name) const
Returns a node ID of a child in a given subnet given its name.
DescendantWireIterator(const UN_GraphData *graph_data)
Constructor for the end iterator.
Definition: UN_NodeUtils.h:879
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
A map of string to various well defined value types.
Definition: UT_Options.h:87
const UT_StringHolder & name(UN_NodeID node_id) const
Returns the name that identifies the node among its siblings.
Definition: UN_NodeData.h:216
std::input_iterator_tag iterator_category
Definition: UN_NodeUtils.h:674
UN_API bool isAnyInputPortConnectedToSrc(const UN_GraphData *graph_data, UN_NodeID node_id)
GLuint color
Definition: glcorearb.h:1261
UT_IteratorRange< ParmIterator > ParmRange
Definition: UN_NodeUtils.h:285
DescendantWireIterator & operator++()
Increment operator.
Definition: UN_NodeUtils.h:885
GLuint index
Definition: glcorearb.h:786
UN_WireID operator*() const
Returns the ID of the current wire.
Definition: UN_NodeUtils.h:907
UN_API void deleteChildNode(UN_GraphData *graph_data, UN_NodeID parent_id, const UT_StringRef &child_name)
Deletes the child node from the graph (removing it from this network).
const UN_MetadataHolder & metadata(UN_NodeID node_id) const
Returns nodes's metadata.
Definition: UN_NodeData.h:361
UT_IteratorRange< ChildNodeIterator > ChildNodeRange
Definition: UN_NodeUtils.h:649
UN_API UT_StringHolder findValidUniqueChildNodeName(const UN_GraphData *graph_data, UN_NodeID node_id, const UT_StringRef &child_name=UT_StringRef())
const UN_ParmIDList & parms(UN_NodeID node) const
Returns the parameters of the given node.
Definition: UN_GraphData.h:327
void setColor(UN_NodeID node_id, const UT_Color &color)
Sets the node's color in the graph editor.
Definition: UN_NodeData.h:273
UN_PortIDList::const_reverse_iterator PortReverseIterator
Definition: UN_NodeUtils.h:492
std::input_iterator_tag iterator_category
Definition: UN_NodeUtils.h:864
UN_API UN_StickyNoteID createChildStickyNote(UN_GraphData *graph_data, UN_NodeID parent_id, const UT_StringRef &sticky_note_name=UT_StringRef(), const UT_StringRef &sticky_note_text=UT_StringRef())
Creates and returns a new sticky note that is a child of this node.
UN_NodeIDList::const_iterator ChildNodeIterator
An iterator and a range for iterating over child node IDs.
Definition: UN_NodeUtils.h:648
void deleteNode(UN_NodeID node)
Deletes the node given its index.
const UT_StringHolder & typeName(UN_NodeID node_id) const
Returns the name of node's type that determines its functional behavour.
Definition: UN_NodeData.h:229
void setComment(UN_NodeID node_id, const UT_StringRef &comment)
Sets the node's comment.
Definition: UN_NodeData.h:249
UN_PortIDList::const_iterator PortIterator
An iterator and a range for iterating over node port IDs.
Definition: UN_NodeUtils.h:458
UN_API UN_WireIDList srcWires(const UN_GraphData *graph_data, UN_NodeID node_id, UN_PortKind port_kind)
DescendantNodeIterator & operator++()
Increment operator.
Definition: UN_NodeUtils.h:708
static const UT_StringArray theDefTags
Definition: UN_NodeData.h:488
const UT_Color & color(UN_NodeID node_id) const
Returns the node's color in the graph editor.
Definition: UN_NodeData.h:279
const UT_StringArray & tags(UN_NodeID node_id) const
Returns node tags.
Definition: UN_NodeData.h:315
const UT_StringHolder & comment(UN_NodeID node_id) const
Returns the node's comment.
Definition: UN_NodeData.h:255
An iterator for traversing the wires deep inside the given node.
Definition: UN_NodeUtils.h:861
const UN_GraphData * graph() const
Returns the underlying graph in which the current node exists.
Definition: UN_NodeUtils.h:913
UN_API UN_WireIDList dstWires(const UN_GraphData *graph_data, UN_NodeID node_id, UN_PortKind port_kind)
bool operator==(const DescendantNodeIterator &other) const
Comparison operators.
Definition: UN_NodeUtils.h:693
UT_UniquePtr< UT_OptionEntry > UT_OptionEntryPtr
UN_API UT_Array< UT_StringHolder > portNames(const UN_GraphData *graph_data, UN_NodeID node_id, UN_PortKind port_kind)
Returns the names of the node ports of a given kind.
void setTags(UN_NodeID node_id, const UT_StringArray &tags)
Sets new tags on a node via copy-assignment.
Definition: UN_NodeData.h:303
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())
bool operator!=(const DescendantNodeIterator &other) const
Comparison operators.
Definition: UN_NodeUtils.h:701
static const UT_StringHolder theDefSignatureName
Definition: UN_NodeData.h:486