本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.PortIf.RemoveConnection方法的典型用法代码示例。如果您正苦于以下问题:Golang PortIf.RemoveConnection方法的具体用法?Golang PortIf.RemoveConnection怎么用?Golang PortIf.RemoveConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/axel-freesp/sge/interface/behaviour.PortIf
的用法示例。
在下文中一共展示了PortIf.RemoveConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RemoveObject
func (p *port) RemoveObject(tree tr.TreeIf, cursor tr.Cursor) (removed []tr.IdWithObject) {
parent := tree.Parent(cursor)
if p != tree.Object(parent) {
log.Fatal("port.RemoveObject error: not removing child of mine.")
}
obj := tree.Object(cursor)
switch obj.(type) {
case bh.ConnectionIf:
conn := obj.(bh.ConnectionIf)
var thisPort, otherPort bh.PortIf
if p.Direction() == gr.InPort {
otherPort = conn.From()
thisPort = conn.To()
if p != thisPort {
log.Fatal("port.RemoveObject error: invalid connection ", conn)
}
} else {
otherPort = conn.To()
thisPort = conn.From()
if p != thisPort {
log.Fatal("port.RemoveObject error: invalid connection ", conn)
}
}
contextCursor := tree.Parent(tree.Parent(tree.Parent(cursor)))
removed = p.treeRemoveObject(tree, cursor, conn, otherPort)
context := tree.Object(contextCursor)
switch context.(type) {
case bh.SignalGraphIf:
case bh.ImplementationIf:
// propagate removed edge to all instances of embracing type
nt := tree.Object(tree.Parent(contextCursor))
for _, nn := range nt.(bh.NodeTypeIf).Instances() {
nCursor := tree.Cursor(nn)
tCursor := tree.CursorAt(nCursor, context)
pCursor := tree.CursorAt(tCursor, p)
cCursor := tree.CursorAt(pCursor, conn)
p.treeRemoveObject(tree, cCursor, conn, otherPort)
}
default:
log.Fatalf("port.RemoveObject error: wrong context type %T: %v\n", context, context)
}
p.RemoveConnection(otherPort)
otherPort.RemoveConnection(p)
default:
log.Fatalf("bh.PortIf.RemoveObject error: invalid type %T: %v\n", obj, obj)
}
return
}