HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_GraphTopology.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_GraphTopology.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_GraphTopology_h__
13 #define __UN_GraphTopology_h__
14 
15 #include "UN_API.h"
16 #include "UN_Include.h"
17 #include <UT/UT_ArrayMap.h>
18 #include <UT/UT_Optional.h>
19 
20 // ============================================================================
21 /// Container for the information about connections between various
22 /// graph elements:
23 /// - which node has which ports, and which ports are connected with which wires
24 /// - which node has which parent, and which node has which children
25 
27 {
28 public:
29  /// Clear all the relationships between graph elements.
30  void clear();
31 
32  /// Merges in the graph element relationships from another topology.
33  void merge( const UN_GraphTopology &other,
34  const UN_IDRemapInfo &id_remap_info );
35 
36  // TODO: FIXME: unify method names to allow easier template programming
37  /// Returns a parent node of the given child node.
38  /// This may include an implicitly created graph's root node,
39  /// which is isn't really a real user-created node.
40  /// Use nonRootNodeParent() to get a parent that was explicitly created.
41  UN_NodeID nodeParent( UN_NodeID child_node ) const
42  { return findMapEntry( myNodeToParentMap, child_node );}
43 
44  /// Returns an explicitly created parent node of the given child node.
45  /// Ie, for top-level graph nodes whose parent is the implicitly created
46  /// graph's root, this method will return an invalid node ID.
47  /// Use nodeParent() to include the root node too.
48  UN_NodeID nonRootNodeParent( UN_NodeID child_node ) const
49  {
50  auto parent = findMapEntry(
51  myNodeToParentMap, child_node );
52  return UNisRoot(parent) ? UN_NodeID() : parent;
53  }
54 
55 
56  /// @{ Returns child nodes of a given parent subnet node.
57  const UN_NodeIDList &
58  nodeChildNodes( UN_NodeID parent_node ) const
59  { return subnetChildNodes( nodeSubnet( parent_node )); }
60 
61  const UN_NodeIDList &
62  subnetChildNodes( UN_SubnetID parent_subnet ) const
63  {
64  return findMapEntry( mySubnetToChildNodesMap,
65  parent_subnet, myEmptyNodeList );
66  }
67  /// @}
68 
69  /// @{ Returns child wires of a given parent subnet node.
70  const UN_WireIDList &
71  nodeChildWires( UN_NodeID parent_node ) const
72  { return subnetChildWires( nodeSubnet( parent_node )); }
73 
74  const UN_WireIDList &
75  subnetChildWires( UN_SubnetID parent_subnet ) const
76  {
77  return findMapEntry( mySubnetToChildWiresMap,
78  parent_subnet, myEmptyWireList );
79  }
80  /// @}
81 
82  /// @{ Returns child sticky notes of a given parent subnet node.
83  const UN_StickyNoteIDList &
84  nodeChildStickyNotes( UN_NodeID parent_node ) const
85  {
86  return subnetChildStickyNotes(
87  nodeSubnet( parent_node ));
88  }
89 
90  const UN_StickyNoteIDList &
91  subnetChildStickyNotes( UN_SubnetID parent_subnet ) const
92  {
93  return findMapEntry( mySubnetToChildStickyNotesMap,
94  parent_subnet, myEmptyStickyNoteList );
95  }
96  /// @}
97 
98 
99  /// Returns a subnet object of the given (owner parent) node.
100  /// The subnet contains information about the given node's children, etc.
101  UN_SubnetID nodeSubnet( UN_NodeID owner_node ) const
102  { return findMapEntry( myNodeToSubnetMap, owner_node );}
103 
104  /// Returns an owner node of the given subnet.
105  UN_NodeID subnetNode( UN_SubnetID subnet ) const
106  { return findMapEntry( mySubnetToNodeMap, subnet ); }
107 
108 
109  /// Returns a parent node of the given wire.
110  UN_NodeID wireParent( UN_WireID wire ) const
111  {
112  return wireParent(
113  wireSrcPort( wire ), wireDstPort( wire ));
114  }
115 
116  /// Returns a parent node of the wire that connects the given ports.
117  UN_NodeID wireParent( UN_PortID src_port, UN_PortID dst_port ) const;
118 
119  /// Returns a source port of the given wire.
120  /// Ie, a port from which this wire takes (receives) data.
121  UN_PortID wireSrcPort( UN_WireID wire ) const
122  { return findMapEntry( myWireToSrcPortMap, wire ); }
123 
124  /// Returns a destination port of the given wire.
125  /// Ie, a port to which this wire provides (sends) data.
126  UN_PortID wireDstPort( UN_WireID wire ) const
127  { return findMapEntry( myWireToDstPortMap, wire ); }
128 
129 
130  /// Returns parameters of a given node.
131  const UN_ParmIDList &
132  nodeParms( UN_NodeID node ) const
133  {
134  return findMapEntry( myNodeToParmsMap, node,
135  myEmptyParmList );
136  }
137 
138  /// Returns an owner node of the given parameter.
139  UN_NodeID parmNode( UN_ParmID parm ) const
140  { return findMapEntry( myParmToNodeMap, parm ); }
141 
142 
143  /// Returns input ports of the given node.
144  const UN_PortIDList &
145  nodeInputPorts( UN_NodeID node ) const
146  {
147  return findMapEntry( myNodeToInputPortsMap,
148  node, myEmptyPortList );
149  }
150 
151  /// Returns output ports of a given node.
152  const UN_PortIDList &
153  nodeOutputPorts( UN_NodeID node ) const
154  {
155  return findMapEntry( myNodeToOutputPortsMap,
156  node, myEmptyPortList );
157  }
158 
159 
160 
161  /// Returns an owner node of the given port.
162  UN_NodeID portNode( UN_PortID port ) const
163  { return findMapEntry( myPortToNodeMap, port ); }
164 
165  /// Returns the port kind (input or output) of the given port.
166  UN_PortKind portKind( UN_PortID port ) const
167  {
168  if( !port )
169  return UN_PortKind::Invalid;
170 
171  auto it = myPortToKindFlagMap.find( port );
172  if( it == myPortToKindFlagMap.end() )
173  return UN_PortKind::Invalid;
174  else if( it->second )
175  return UN_PortKind::Output;
176  else
177  return UN_PortKind::Input;
178  }
179 
180  /// Returns source wires connected to the given port.
181  /// Ie, connection wires from which this port takes (receives) data.
182  const UN_WireIDList &
183  portSrcWires( UN_PortID port ) const
184  {
185  return findMapEntry( myPortToSrcWiresMap, port,
186  myEmptyWireList );
187  }
188 
189  /// Returns destination wires connected to the given port.
190  /// Ie, connection wires to which this port provides (sends) data.
191  const UN_WireIDList &
192  portDstWires( UN_PortID port ) const
193  {
194  return findMapEntry( myPortToDstWiresMap, port,
195  myEmptyWireList );
196  }
197 
198  /// Returns a parent node of the given child sticky note.
199  UN_NodeID stickyNoteParent( UN_StickyNoteID child_sticky_note ) const
200  { return findMapEntry( myStickyNoteToParentMap,
201  child_sticky_note );}
202 
203 
204  /// Adds a new subnet to the topology, and links it with the given node,
205  /// making that node a subnet (a parent) that can contain children.
206  void addSubnet( UN_SubnetID new_subnet, UN_NodeID owner_node );
207 
208  /// Removes the subnet from the topology data structures.
209  void deleteSubnet( UN_SubnetID subnet );
210 
211 
212 
213  /// Adds a new node to the topology, and links it as a child
214  /// of the given parent node, which already exists in the topology
215  /// along with a subnet object associated with it.
216  void addNode( UN_NodeID new_node, UN_NodeID parent_node );
217 
218  /// Removes the node from the topology data structures.
219  void deleteNode( UN_NodeID node );
220 
221  /// Moves a node from one parent to another.
222  void moveNode( UN_NodeID node, UN_NodeID new_parent );
223 
224  /// Moves all children of the given parent node to another one.
225  void moveAllChildNodes( UN_NodeID old_parent,
226  UN_NodeID new_parent );
227 
228  /// Sets the new order for the children of the given parent subnet.
229  /// The new order must contain exactly the same child node IDs as
230  /// the current child list of the subnet, just in a different order.
231  void reorderChildren( UN_SubnetID subnet,
232  const UT_Array<UN_NodeID> &child_order );
233 
234  /// Sets the new order for input ports on the given node.
235  /// The new order must contain exactly the same port IDs as the current
236  /// input port list for the node, just in a different order.
237  void reorderInputPorts( UN_NodeID node,
238  const UN_PortIDList &port_order );
239 
240  /// Sets the new order for output ports on the given node.
241  /// The new order must contain exactly the same port IDs as the current
242  /// output port list for the node, just in a different order.
243  void reorderOutputPorts( UN_NodeID node,
244  const UN_PortIDList &port_order );
245 
246 
247  /// Sets the new order for parameters on the given node.
248  /// The new order must contain exactly the same parm IDs as the current
249  /// parm list for the node, just in a different order.
250  void reorderParms( UN_NodeID node,
251  const UN_ParmIDList &parm_order );
252 
253  /// Adds a new parameter to the topology, and
254  /// links (adds) it as a parameter of the given node.
255  void addParm( UN_ParmID new_parm, UN_NodeID node );
256 
257  /// Removes the parameter from the topology data structures.
258  void deleteParm( UN_ParmID parm );
259 
260 
261 
262  /// Adds a new input port to the topology, and
263  /// links it as an input of the given node.
264  /// @param index If given, this is the index position at which
265  /// to insert the new port. Negative numbers are wrapped around,
266  /// and counted backwards (ie, -1 corresponds to the *current*
267  /// last port). If not given, the new port is appended to the node.
268  void addInputPort( UN_PortID new_input_port, UN_NodeID node,
269  const UT_Optional<exint> &index = std::nullopt);
270 
271  /// Adds a new output port to the topology, and
272  /// links it as an output of the given node.
273  /// @param index If given, this is the index position at which
274  /// to insert the new port. Negative numbers are wrapped around,
275  /// and counted backwards (ie, -1 corresponds to the *current*
276  /// last port). If not given, the new port is appended to the node.
277  void addOutputPort( UN_PortID new_output_port, UN_NodeID node,
278  const UT_Optional<exint> &index = std::nullopt);
279 
280  /// Removes the port from the topology data structures.
281  /// Returns the list of wires that also got removed (deleted),
282  /// because they were connected to the port being deleted.
283  UN_WireIDList deletePort( UN_PortID port );
284 
285 
286 
287  /// Adds a new wire to the topology, and links it with the two ports. Ie,
288  /// creates a connection between the two given ports,
289  /// from the source port to the destination port.
290  void addWire( UN_WireID new_wire,
291  UN_PortID src_port,
292  UN_PortID dst_port );
293 
294  /// Removes the wire from the topology data structures.
295  void deleteWire( UN_WireID wire );
296 
297  /// Updates the internal dictionaries after nodes have been moved to a
298  /// new subnet.
299  void updateSubnetWires( UN_SubnetID old_subnet );
300 
301 
302  /// Adds a new sticky note to the topology, and links it as a child
303  /// of the given parent node, which already exists in the topology
304  /// along with a subnet object associated with it.
305  void addStickyNote( UN_StickyNoteID new_sticky_note,
306  UN_NodeID parent_node );
307 
308  /// Removes the sticky note from the topology data structures.
309  void deleteStickyNote( UN_StickyNoteID sticky_note );
310 
311 
312 private:
313 
314  /// Links the given parent node to a subnet, allowing it to have children.
315  void setNodeSubnet( UN_NodeID node, UN_SubnetID subnet )
316  { addMapEntry( myNodeToSubnetMap, node, subnet );}
317 
318  /// Deletes the node entry that links it to its subnet.
319  void eraseNodeSubnet( UN_NodeID node )
320  { removeMapEntry( myNodeToSubnetMap, node ); }
321 
322 
323 
324  /// Links the given subnet to a node (a parent).
325  void setSubnetNode( UN_SubnetID subnet, UN_NodeID node )
326  { addMapEntry( mySubnetToNodeMap, subnet, node );}
327 
328  /// Deletes the subnet entry that links it to its node.
329  void eraseSubnetNode( UN_SubnetID subnet )
330  { removeMapEntry( mySubnetToNodeMap, subnet ); }
331 
332 
333 
334  /// Adds a node to a given subnet.
335  void addSubnetChildNode( UN_SubnetID subnet, UN_NodeID child_node )
336  {
337  addElementToMapEntry( mySubnetToChildNodesMap, subnet, child_node );
338  }
339 
340  /// Removes a node from a given subnet.
341  void removeSubnetChildNode( UN_SubnetID subnet, UN_NodeID child_node )
342  {
343  findAndRemoveElementFromMapEntry( mySubnetToChildNodesMap,
344  subnet, child_node );
345  }
346 
347  /// Deletes the subnet entry that links it to its children.
348  void eraseSubnetChildNodes( UN_SubnetID subnet )
349  {
350  removeMapEntry( mySubnetToChildNodesMap, subnet );
351  }
352 
353 
354  /// Adds a wire to a given subnet.
355  void addSubnetChildWire( UN_SubnetID subnet, UN_WireID child_wire )
356  {
357  addElementToMapEntry( mySubnetToChildWiresMap, subnet, child_wire );
358  }
359 
360  /// Removes a wire from a given subnet.
361  void removeSubnetChildWire( UN_SubnetID subnet, UN_WireID child_wire )
362  {
363  findAndRemoveElementFromMapEntry( mySubnetToChildWiresMap,
364  subnet, child_wire );
365  }
366 
367  /// Deletes the subnet entry that links it to its wires.
368  void eraseSubnetChildWires( UN_SubnetID subnet )
369  {
370  removeMapEntry( mySubnetToChildWiresMap, subnet );
371  }
372 
373 
374  /// Adds a sticky note to a given subnet.
375  void addSubnetChildStickyNote( UN_SubnetID subnet,
376  UN_StickyNoteID child_sticky_note )
377  {
378  addElementToMapEntry( mySubnetToChildStickyNotesMap,
379  subnet, child_sticky_note );
380  }
381 
382  /// Removes a node from a given subnet.
383  void removeSubnetChildStickyNote( UN_SubnetID subnet,
384  UN_StickyNoteID child_sticky_note )
385  {
386  findAndRemoveElementFromMapEntry( mySubnetToChildStickyNotesMap,
387  subnet, child_sticky_note );
388  }
389 
390  /// Deletes the subnet entry that links it to its children.
391  void eraseSubnetChildStickyNotes( UN_SubnetID subnet )
392  {
393  removeMapEntry( mySubnetToChildStickyNotesMap, subnet );
394  }
395 
396 
397  /// Links the given child node to a parent node.
398  void setNodeParent( UN_NodeID child, UN_NodeID parent )
399  { addMapEntry( myNodeToParentMap, child, parent);}
400 
401  /// Deletes the node entry that links it to its parent.
402  void eraseNodeParent( UN_NodeID child )
403  { removeMapEntry( myNodeToParentMap, child ); }
404 
405 
406 
407  /// Adds a parameter to a given node.
408  // Note, all nodes can have parameters, so we automatically create
409  // a parm list entry in the map just-in-time, if it does not exist yet.
410  void addNodeParm( UN_NodeID node, UN_ParmID parm )
411  {
412  addElementToMapEntry( myNodeToParmsMap,
413  node, parm );
414  }
415 
416  /// Removes a parameter from a given node.
417  void removeNodeParm( UN_NodeID node, UN_ParmID parm )
418  {
419  findAndRemoveElementFromMapEntry(
420  myNodeToParmsMap, node, parm );
421  }
422 
423  /// Deletes the node entry that links it to its parameters.
424  void eraseNodeParms( UN_NodeID node )
425  { removeMapEntry( myNodeToParmsMap, node ); }
426 
427 
428 
429  /// Links a given parameter to a node it belongs to.
430  void setParmNode( UN_ParmID parm, UN_NodeID node )
431  { addMapEntry( myParmToNodeMap, parm, node ); }
432 
433  /// Deletes the parameter entry that links it to its owner node.
434  void eraseParmNode( UN_ParmID parm )
435  { removeMapEntry( myParmToNodeMap, parm ); }
436 
437 
438 
439  /// Adds an input port to a given node.
440  void addNodeInputPort( UN_NodeID node, UN_PortID port,
441  const UT_Optional<exint> &index = std::nullopt )
442  {
443  addElementToMapEntry( myNodeToInputPortsMap,
444  node, port, index );
445  }
446 
447  /// Removes an input port from a given node.
448  void removeNodeInputPort( UN_NodeID node, UN_PortID port )
449  {
450  findAndRemoveElementFromMapEntry(
451  myNodeToInputPortsMap, node, port );
452  }
453 
454  /// Deletes the node entry that links it to its input ports.
455  void eraseNodeInputPorts( UN_NodeID node )
456  { removeMapEntry( myNodeToInputPortsMap, node ); }
457 
458 
459 
460  /// Adds an output port to a given node.
461  void addNodeOutputPort( UN_NodeID node, UN_PortID port,
462  const UT_Optional<exint> &index = std::nullopt )
463  {
464  addElementToMapEntry( myNodeToOutputPortsMap,
465  node, port, index );
466  }
467 
468  /// Removes an output port from a given node.
469  void removeNodeOutputPort( UN_NodeID node, UN_PortID port )
470  {
471  findAndRemoveElementFromMapEntry(
472  myNodeToOutputPortsMap, node, port );
473  }
474 
475  /// Deletes the node entry that links it to its output ports.
476  void eraseNodeOutputPorts( UN_NodeID node )
477  { removeMapEntry( myNodeToOutputPortsMap, node ); }
478 
479 
480 
481  /// Links a given port to a node it belongs to.
482  void setPortNode( UN_PortID port, UN_NodeID node )
483  { addMapEntry( myPortToNodeMap, port, node ); }
484 
485  /// Deletes the port entry that links it to its owner node.
486  void erasePortNode( UN_PortID port )
487  { removeMapEntry( myPortToNodeMap, port ); }
488 
489 
490 
491  /// Marks port as an output.
492  void setPortKind( UN_PortID port, UN_PortKind port_kind )
493  {
494  UT_ASSERT( port_kind == UN_PortKind::Input ||
495  port_kind == UN_PortKind::Output );
496  addMapEntry( myPortToKindFlagMap, port,
497  port_kind == UN_PortKind::Output );
498  }
499 
500  /// Deletes the port entry that indicates its kind.
501  void erasePortKind( UN_PortID port )
502  { removeMapEntry( myPortToKindFlagMap, port ); }
503 
504 
505 
506  /// Adds a wire as a data source of the given port.
507  /// Ie, connection wire from which this port takes (receives) data.
508  void addPortSrcWire( UN_PortID port, UN_WireID wire )
509  {
510  // In virtually all contexts, an input port will
511  // have at most one source. Set size to reduce mem.
512  static constexpr exint capacity = 1;
513  UT_ASSERT( wire );
514  addElementToMapEntry( myPortToSrcWiresMap,
515  port, wire, std::nullopt, capacity );
516  }
517 
518  /// Removes a source wire from the given port.
519  void removePortSrcWire( UN_PortID port, UN_WireID wire )
520  {
521  findAndRemoveElementFromMapEntry(
522  myPortToSrcWiresMap, port, wire );
523  }
524 
525  /// Deletes the port entry that links it to its source wire.
526  void erasePortSrcWires( UN_PortID port )
527  { removeMapEntry( myPortToSrcWiresMap, port ); }
528 
529 
530 
531  /// Adds a wire as a data destination for the given port.
532  /// Ie, connection wire to which this port provides (sends) data.
533  void addPortDstWire( UN_PortID port, UN_WireID wire )
534  {
535  // In most contexts, the guess is that output port
536  // will have about two destination wires.
537  // So pre-emptively set capacity before adding one.
538  static constexpr exint capacity = 2;
539  UT_ASSERT( wire );
540  addElementToMapEntry( myPortToDstWiresMap,
541  port, wire, std::nullopt, capacity );
542  }
543 
544  /// Removes a destination wire from the given port.
545  void removePortDstWire( UN_PortID port, UN_WireID wire )
546  {
547  findAndRemoveElementFromMapEntry(
548  myPortToDstWiresMap, port, wire );
549  }
550 
551  /// Deletes the port entry that links it to its destination wire.
552  void erasePortDstWires( UN_PortID port )
553  { removeMapEntry( myPortToDstWiresMap, port ); }
554 
555 
556 
557  /// Links a given wire to a source port it connects.
558  void setWireSrcPort( UN_WireID wire, UN_PortID port )
559  { addMapEntry( myWireToSrcPortMap, wire, port ); }
560 
561  /// Deletes the wire entry that links it to its source port.
562  void eraseWireSrcPort( UN_WireID wire )
563  { removeMapEntry( myWireToSrcPortMap, wire ); }
564 
565 
566  /// Links a given wire to a source port it connects.
567  void setWireDstPort( UN_WireID wire, UN_PortID port )
568  { addMapEntry( myWireToDstPortMap, wire, port ); }
569 
570  /// Deletes the wire entry that links it to its destination port.
571  void eraseWireDstPort( UN_WireID wire )
572  { removeMapEntry( myWireToDstPortMap, wire ); }
573 
574 
575  /// Links the given child sticky note to a parent node.
576  void setStickyNoteParent(UN_StickyNoteID child, UN_NodeID parent)
577  { addMapEntry( myStickyNoteToParentMap, child, parent);}
578 
579  /// Deletes the node entry that links it to its parent.
580  void eraseStickyNoteParent( UN_StickyNoteID child )
581  { removeMapEntry( myStickyNoteToParentMap, child ); }
582 
583 
584 
585 private:
586  /// Helper function to add an entry for the value given its key in the map.
587  template <typename K, typename V>
588  static inline void addMapEntry( UT_ArrayMap<K, V> &map, K key, V value )
589  {
590  if( key )
591  map[ key ] = value;
592  }
593 
594  /// Helper function to remove an entry given the key in the map.
595  template <typename K, typename V>
596  static inline void removeMapEntry( UT_ArrayMap<K, V> &map, K key )
597  {
598  if( key )
599  map.erase( key );
600  }
601 
602  /// Helper function to look up a value given the key in to the given map.
603  template <typename K, typename V>
604  static inline V findMapEntry( const UT_ArrayMap<K, V> &map, K key )
605  {
606  if( !key )
607  return V();
608  auto it = map.find( key );
609  if( it == map.end() )
610  return V();
611  return it->second;
612  }
613 
614  /// Helper function to look up a value given the key in to the given map.
615  template <typename K, typename V>
616  static inline const V &
617  findMapEntry( const UT_ArrayMap<K, V> &map, K key, const V &default_value )
618  {
619  if( !key )
620  return default_value;
621  auto it = map.find( key );
622  if( it == map.end() )
623  return default_value;
624  return it->second;
625  }
626 
627  /// Helper function to append an element to the array entry in the map.
628  template <typename K, typename V>
629  static inline void addElementToMapEntry(
630  UT_ArrayMap<K, UT_Array<V>> &map, K key, const V& element,
631  const UT_Optional<exint> &index = std::nullopt,
632  exint capacity = -1 )
633  {
634  if( !key )
635  return;
636  auto &array = map[ key ];
637  UT_ASSERT_SLOW( array.find(element) < 0 );
638  if( capacity > 0 )
639  array.setCapacityIfNeeded( capacity );
640 
641  exint size = array.size();
642  if( !index || *index == size )
643  array.append( element );
644  else
645  array.insert( element, SYSwrapmod( *index, size ));
646  }
647 
648  /// Helper function to remove an element from the array entry in the map.
649  template <typename K, typename V>
650  static inline void findAndRemoveElementFromMapEntry(
651  UT_ArrayMap<K, UT_Array<V>> &map, K key, const V& element )
652  {
653  if( !key )
654  return;
655  auto it = map.find( key );
656  if( it == map.end() )
657  return;
658  it->second.findAndRemove( element );
659  UT_ASSERT( it->second.find(element) < 0 );
660  }
661 
662  /// Empty lists used for returning empty const references from methods.
663  static inline const auto myEmptyNodeList = UN_NodeIDList();
664  static inline const auto myEmptyStickyNoteList = UN_StickyNoteIDList();
665  static inline const auto myEmptyParmList = UN_ParmIDList();
666  static inline const auto myEmptyPortList = UN_PortIDList();
667  static inline const auto myEmptyWireList = UN_WireIDList();
668 
669 
670 private:
671  /// A map from a node (ie, a parent) to its subnet data (ie, children info).
672  UT_ArrayMap< UN_NodeID, UN_SubnetID > myNodeToSubnetMap;
673 
674  // A map from a subnet data to the (subnet) node it belongs to.
675  UT_ArrayMap< UN_SubnetID, UN_NodeID > mySubnetToNodeMap;
676 
677  /// A map from a subnet to a list of its child nodes.
678  UT_ArrayMap< UN_SubnetID, UN_NodeIDList > mySubnetToChildNodesMap;
679 
680  /// A map from a subnet to a list of the wires it contains (directly).
681  /// The wires belong to (are immediatly inside) the subnet, and
682  /// they connect children, but also connect subnet input and output ports.
683  UT_ArrayMap< UN_SubnetID, UN_WireIDList > mySubnetToChildWiresMap;
684 
685  /// A map from a subnet to a list of its child sticky notes.
687  mySubnetToChildStickyNotesMap;
688 
689  /// A map from a child node to its parent.
690  UT_ArrayMap< UN_NodeID, UN_NodeID > myNodeToParentMap;
691 
692  /// A map from a node to its parameters.
694 
695  /// A map from a parameter to the node it belongs to.
696  UT_ArrayMap< UN_ParmID, UN_NodeID > myParmToNodeMap;
697 
698  /// A map from a node to its input ports.
699  UT_ArrayMap< UN_NodeID, UN_PortIDList > myNodeToInputPortsMap;
700 
701  /// A map from a node to its output ports.
702  UT_ArrayMap< UN_NodeID, UN_PortIDList > myNodeToOutputPortsMap;
703 
704  /// A map from a port to the node it belongs to.
705  UT_ArrayMap< UN_PortID, UN_NodeID > myPortToNodeMap;
706 
707  // TODO: FIXME: UT_ArraySet myOutputPortSet approach was very slow.
708  // Optimized it with UT_ArrayMap, but still 50% slower.
709  // Can we remove this relationship from the topology,
710  // and rely on graph data flag instead? Would it be faster?
711  /// A set of output ports. Any port not in this set is an input.
712  /// Used to determine the port kind based on the port ID.
713  UT_ArrayMap< UN_PortID, bool > myPortToKindFlagMap;
714 
715  /// A map from a port to the list of its source wires.
716  UT_ArrayMap< UN_PortID, UN_WireIDList > myPortToSrcWiresMap;
717 
718  /// A map from a port to the list of its destination wires.
719  UT_ArrayMap< UN_PortID, UN_WireIDList > myPortToDstWiresMap;
720 
721  /// A map from a wire to its source port that it connects.
722  UT_ArrayMap< UN_WireID, UN_PortID > myWireToSrcPortMap;
723 
724  /// A map from a wire to its destination port that it connects.
725  UT_ArrayMap< UN_WireID, UN_PortID > myWireToDstPortMap;
726 
727  /// A map from a child sticky note to its parent subnet node.
728  UT_ArrayMap< UN_StickyNoteID, UN_NodeID > myStickyNoteToParentMap;
729 };
730 
731 
732 #endif
const UN_WireIDList & portSrcWires(UN_PortID port) const
UN_NodeID parmNode(UN_ParmID parm) const
Returns an owner node of the given parameter.
const UN_NodeIDList & nodeChildNodes(UN_NodeID parent_node) const
Returns child nodes of a given parent subnet node.
GLsizei const GLfloat * value
Definition: glcorearb.h:824
int64 exint
Definition: SYS_Types.h:125
UN_NodeID nodeParent(UN_NodeID child_node) const
const UN_StickyNoteIDList & nodeChildStickyNotes(UN_NodeID parent_node) const
Returns child sticky notes of a given parent subnet node.
#define UN_API
Definition: UN_API.h:11
const UN_PortIDList & nodeOutputPorts(UN_NodeID node) const
Returns output ports of a given node.
iterator find(const Key &key)
Definition: UT_ArrayMap.h:158
UN_NodeID portNode(UN_PortID port) const
Returns an owner node of the given port.
std::optional< T > UT_Optional
Definition: UT_Optional.h:26
UN_NodeID subnetNode(UN_SubnetID subnet) const
Returns an owner node of the given subnet.
const UN_PortIDList & nodeInputPorts(UN_NodeID node) const
Returns input ports of the given node.
Package of remappings for various data ID types (nodes, ports, subnets).
Definition: UN_Include.h:483
const UN_ParmIDList & nodeParms(UN_NodeID node) const
Returns parameters of a given node.
UN_NodeID nonRootNodeParent(UN_NodeID child_node) const
#define UT_ASSERT_SLOW(ZZ)
Definition: UT_Assert.h:163
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
Definition: UNI_Include.h:21
UN_PortID wireSrcPort(UN_WireID wire) const
UN_NodeID wireParent(UN_WireID wire) const
Returns a parent node of the given wire.
const UN_WireIDList & portDstWires(UN_PortID port) const
size_type erase(const Key &key)
Definition: UT_ArrayMap.h:563
UN_PortID wireDstPort(UN_WireID wire) const
const UN_NodeIDList & subnetChildNodes(UN_SubnetID parent_subnet) const
Returns child nodes of a given parent subnet node.
UN_NodeID stickyNoteParent(UN_StickyNoteID child_sticky_note) const
Returns a parent node of the given child sticky note.
GLsizeiptr size
Definition: glcorearb.h:664
const UN_WireIDList & subnetChildWires(UN_SubnetID parent_subnet) const
Returns child wires of a given parent subnet node.
GLuint index
Definition: glcorearb.h:786
UN_PortKind portKind(UN_PortID port) const
Returns the port kind (input or output) of the given port.
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165
OutGridT XformOp bool bool MergePolicy merge
UN_SubnetID nodeSubnet(UN_NodeID owner_node) const
const UN_StickyNoteIDList & subnetChildStickyNotes(UN_SubnetID parent_subnet) const
Returns child sticky notes of a given parent subnet node.
const UN_WireIDList & nodeChildWires(UN_NodeID parent_node) const
Returns child wires of a given parent subnet node.