12 #ifndef __UN_GraphTopology_h__
13 #define __UN_GraphTopology_h__
42 {
return findMapEntry( myNodeToParentMap, child_node );}
50 auto parent = findMapEntry(
51 myNodeToParentMap, child_node );
52 return UNisRoot(parent) ? UN_NodeID() : parent;
59 {
return subnetChildNodes( nodeSubnet( parent_node )); }
64 return findMapEntry( mySubnetToChildNodesMap,
65 parent_subnet, myEmptyNodeList );
72 {
return subnetChildWires( nodeSubnet( parent_node )); }
77 return findMapEntry( mySubnetToChildWiresMap,
78 parent_subnet, myEmptyWireList );
83 const UN_StickyNoteIDList &
86 return subnetChildStickyNotes(
87 nodeSubnet( parent_node ));
90 const UN_StickyNoteIDList &
93 return findMapEntry( mySubnetToChildStickyNotesMap,
94 parent_subnet, myEmptyStickyNoteList );
102 {
return findMapEntry( myNodeToSubnetMap, owner_node );}
106 {
return findMapEntry( mySubnetToNodeMap, subnet ); }
113 wireSrcPort( wire ), wireDstPort( wire ));
117 UN_NodeID wireParent( UN_PortID src_port, UN_PortID dst_port )
const;
122 {
return findMapEntry( myWireToSrcPortMap, wire ); }
127 {
return findMapEntry( myWireToDstPortMap, wire ); }
131 const UN_ParmIDList &
134 return findMapEntry( myNodeToParmsMap, node,
140 {
return findMapEntry( myParmToNodeMap, parm ); }
144 const UN_PortIDList &
147 return findMapEntry( myNodeToInputPortsMap,
148 node, myEmptyPortList );
152 const UN_PortIDList &
155 return findMapEntry( myNodeToOutputPortsMap,
156 node, myEmptyPortList );
163 {
return findMapEntry( myPortToNodeMap, port ); }
171 auto it = myPortToKindFlagMap.find( port );
172 if( it == myPortToKindFlagMap.end() )
174 else if( it->second )
182 const UN_WireIDList &
185 return findMapEntry( myPortToSrcWiresMap, port,
191 const UN_WireIDList &
194 return findMapEntry( myPortToDstWiresMap, port,
200 {
return findMapEntry( myStickyNoteToParentMap,
201 child_sticky_note );}
206 void addSubnet( UN_SubnetID new_subnet, UN_NodeID owner_node );
209 void deleteSubnet( UN_SubnetID subnet );
216 void addNode( UN_NodeID new_node, UN_NodeID parent_node );
219 void deleteNode( UN_NodeID node );
222 void moveNode( UN_NodeID node, UN_NodeID new_parent );
225 void moveAllChildNodes( UN_NodeID old_parent,
226 UN_NodeID new_parent );
231 void reorderChildren( UN_SubnetID subnet,
237 void reorderInputPorts( UN_NodeID node,
238 const UN_PortIDList &port_order );
243 void reorderOutputPorts( UN_NodeID node,
244 const UN_PortIDList &port_order );
250 void reorderParms( UN_NodeID node,
251 const UN_ParmIDList &parm_order );
255 void addParm( UN_ParmID new_parm, UN_NodeID node );
258 void deleteParm( UN_ParmID parm );
268 void addInputPort( UN_PortID new_input_port, UN_NodeID node,
277 void addOutputPort( UN_PortID new_output_port, UN_NodeID node,
283 UN_WireIDList deletePort( UN_PortID port );
290 void addWire( UN_WireID new_wire,
292 UN_PortID dst_port );
295 void deleteWire( UN_WireID wire );
299 void updateSubnetWires( UN_SubnetID old_subnet );
305 void addStickyNote( UN_StickyNoteID new_sticky_note,
306 UN_NodeID parent_node );
309 void deleteStickyNote( UN_StickyNoteID sticky_note );
315 void setNodeSubnet( UN_NodeID node, UN_SubnetID subnet )
316 { addMapEntry( myNodeToSubnetMap, node, subnet );}
319 void eraseNodeSubnet( UN_NodeID node )
320 { removeMapEntry( myNodeToSubnetMap, node ); }
325 void setSubnetNode( UN_SubnetID subnet, UN_NodeID node )
326 { addMapEntry( mySubnetToNodeMap, subnet, node );}
329 void eraseSubnetNode( UN_SubnetID subnet )
330 { removeMapEntry( mySubnetToNodeMap, subnet ); }
335 void addSubnetChildNode( UN_SubnetID subnet, UN_NodeID child_node )
337 addElementToMapEntry( mySubnetToChildNodesMap, subnet, child_node );
341 void removeSubnetChildNode( UN_SubnetID subnet, UN_NodeID child_node )
343 findAndRemoveElementFromMapEntry( mySubnetToChildNodesMap,
344 subnet, child_node );
348 void eraseSubnetChildNodes( UN_SubnetID subnet )
350 removeMapEntry( mySubnetToChildNodesMap, subnet );
355 void addSubnetChildWire( UN_SubnetID subnet, UN_WireID child_wire )
357 addElementToMapEntry( mySubnetToChildWiresMap, subnet, child_wire );
361 void removeSubnetChildWire( UN_SubnetID subnet, UN_WireID child_wire )
363 findAndRemoveElementFromMapEntry( mySubnetToChildWiresMap,
364 subnet, child_wire );
368 void eraseSubnetChildWires( UN_SubnetID subnet )
370 removeMapEntry( mySubnetToChildWiresMap, subnet );
375 void addSubnetChildStickyNote( UN_SubnetID subnet,
376 UN_StickyNoteID child_sticky_note )
378 addElementToMapEntry( mySubnetToChildStickyNotesMap,
379 subnet, child_sticky_note );
383 void removeSubnetChildStickyNote( UN_SubnetID subnet,
384 UN_StickyNoteID child_sticky_note )
386 findAndRemoveElementFromMapEntry( mySubnetToChildStickyNotesMap,
387 subnet, child_sticky_note );
391 void eraseSubnetChildStickyNotes( UN_SubnetID subnet )
393 removeMapEntry( mySubnetToChildStickyNotesMap, subnet );
398 void setNodeParent( UN_NodeID child, UN_NodeID parent )
399 { addMapEntry( myNodeToParentMap, child, parent);}
402 void eraseNodeParent( UN_NodeID child )
403 { removeMapEntry( myNodeToParentMap, child ); }
410 void addNodeParm( UN_NodeID node, UN_ParmID parm )
412 addElementToMapEntry( myNodeToParmsMap,
417 void removeNodeParm( UN_NodeID node, UN_ParmID parm )
419 findAndRemoveElementFromMapEntry(
420 myNodeToParmsMap, node, parm );
424 void eraseNodeParms( UN_NodeID node )
425 { removeMapEntry( myNodeToParmsMap, node ); }
430 void setParmNode( UN_ParmID parm, UN_NodeID node )
431 { addMapEntry( myParmToNodeMap, parm, node ); }
434 void eraseParmNode( UN_ParmID parm )
435 { removeMapEntry( myParmToNodeMap, parm ); }
440 void addNodeInputPort( UN_NodeID node, UN_PortID port,
443 addElementToMapEntry( myNodeToInputPortsMap,
448 void removeNodeInputPort( UN_NodeID node, UN_PortID port )
450 findAndRemoveElementFromMapEntry(
451 myNodeToInputPortsMap, node, port );
455 void eraseNodeInputPorts( UN_NodeID node )
456 { removeMapEntry( myNodeToInputPortsMap, node ); }
461 void addNodeOutputPort( UN_NodeID node, UN_PortID port,
464 addElementToMapEntry( myNodeToOutputPortsMap,
469 void removeNodeOutputPort( UN_NodeID node, UN_PortID port )
471 findAndRemoveElementFromMapEntry(
472 myNodeToOutputPortsMap, node, port );
476 void eraseNodeOutputPorts( UN_NodeID node )
477 { removeMapEntry( myNodeToOutputPortsMap, node ); }
482 void setPortNode( UN_PortID port, UN_NodeID node )
483 { addMapEntry( myPortToNodeMap, port, node ); }
486 void erasePortNode( UN_PortID port )
487 { removeMapEntry( myPortToNodeMap, port ); }
492 void setPortKind( UN_PortID port,
UN_PortKind port_kind )
496 addMapEntry( myPortToKindFlagMap, port,
501 void erasePortKind( UN_PortID port )
502 { removeMapEntry( myPortToKindFlagMap, port ); }
508 void addPortSrcWire( UN_PortID port, UN_WireID wire )
512 static constexpr
exint capacity = 1;
514 addElementToMapEntry( myPortToSrcWiresMap,
515 port, wire, std::nullopt, capacity );
519 void removePortSrcWire( UN_PortID port, UN_WireID wire )
521 findAndRemoveElementFromMapEntry(
522 myPortToSrcWiresMap, port, wire );
526 void erasePortSrcWires( UN_PortID port )
527 { removeMapEntry( myPortToSrcWiresMap, port ); }
533 void addPortDstWire( UN_PortID port, UN_WireID wire )
538 static constexpr
exint capacity = 2;
540 addElementToMapEntry( myPortToDstWiresMap,
541 port, wire, std::nullopt, capacity );
545 void removePortDstWire( UN_PortID port, UN_WireID wire )
547 findAndRemoveElementFromMapEntry(
548 myPortToDstWiresMap, port, wire );
552 void erasePortDstWires( UN_PortID port )
553 { removeMapEntry( myPortToDstWiresMap, port ); }
558 void setWireSrcPort( UN_WireID wire, UN_PortID port )
559 { addMapEntry( myWireToSrcPortMap, wire, port ); }
562 void eraseWireSrcPort( UN_WireID wire )
563 { removeMapEntry( myWireToSrcPortMap, wire ); }
567 void setWireDstPort( UN_WireID wire, UN_PortID port )
568 { addMapEntry( myWireToDstPortMap, wire, port ); }
571 void eraseWireDstPort( UN_WireID wire )
572 { removeMapEntry( myWireToDstPortMap, wire ); }
576 void setStickyNoteParent(UN_StickyNoteID child, UN_NodeID parent)
577 { addMapEntry( myStickyNoteToParentMap, child, parent);}
580 void eraseStickyNoteParent( UN_StickyNoteID child )
581 { removeMapEntry( myStickyNoteToParentMap, child ); }
587 template <
typename K,
typename V>
595 template <
typename K,
typename V>
603 template <
typename K,
typename V>
608 auto it = map.
find( key );
609 if( it == map.
end() )
615 template <
typename K,
typename V>
616 static inline const V &
620 return default_value;
621 auto it = map.
find( key );
622 if( it == map.
end() )
623 return default_value;
628 template <
typename K,
typename V>
629 static inline void addElementToMapEntry(
632 exint capacity = -1 )
636 auto &array = map[ key ];
639 array.setCapacityIfNeeded( capacity );
643 array.append( element );
645 array.insert( element, SYSwrapmod( *
index, size ));
649 template <
typename K,
typename V>
650 static inline void findAndRemoveElementFromMapEntry(
655 auto it = map.
find( key );
656 if( it == map.
end() )
658 it->second.findAndRemove( element );
659 UT_ASSERT( it->second.find(element) < 0 );
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();
687 mySubnetToChildStickyNotesMap;
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
UN_NodeID nodeParent(UN_NodeID child_node) const
UT::ArraySet< std::pair< Key, T >, MULTI, MAX_LOAD_FACTOR_256, Clearer, MapKeyHash< Hash, Key, T >, MapKeyEqual< KeyEqual, Key, T > >::end iterator end()
Returns a non-const end iterator for the set.
const UN_StickyNoteIDList & nodeChildStickyNotes(UN_NodeID parent_node) const
Returns child sticky notes of a given parent subnet node.
const UN_PortIDList & nodeOutputPorts(UN_NodeID node) const
Returns output ports of a given node.
iterator find(const Key &key)
UN_NodeID portNode(UN_PortID port) const
Returns an owner node of the given port.
std::optional< T > UT_Optional
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).
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)
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
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)
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.
const UN_WireIDList & subnetChildWires(UN_SubnetID parent_subnet) const
Returns child wires of a given parent subnet node.
UN_PortKind portKind(UN_PortID port) const
Returns the port kind (input or output) of the given port.
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.