本文整理匯總了Golang中github.com/axel-freesp/sge/interface/behaviour.PortIf.AddConnection方法的典型用法代碼示例。如果您正苦於以下問題:Golang PortIf.AddConnection方法的具體用法?Golang PortIf.AddConnection怎麽用?Golang PortIf.AddConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/axel-freesp/sge/interface/behaviour.PortIf
的用法示例。
在下文中一共展示了PortIf.AddConnection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddNewObject
func (p *port) AddNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor, err error) {
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()
} else {
otherPort = conn.To()
thisPort = conn.From()
}
if p != thisPort {
log.Println("p =", p)
log.Println("thisPort =", thisPort)
log.Fatal("port.AddNewObject error: invalid connection ", conn)
}
sgt := thisPort.Node().Context()
if sgt != otherPort.Node().Context() {
log.Fatal("port.AddNewObject error: nodes have different context: ", conn)
}
contextCursor := tree.Parent(tree.Parent(cursor))
thisPort.AddConnection(conn)
newCursor = p.treeAddNewObject(tree, cursor, conn, otherPort)
context := tree.Object(contextCursor)
switch context.(type) {
case bh.SignalGraphIf:
case bh.ImplementationIf:
// propagate new 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)
pCursor.Position = cursor.Position
p.treeAddNewObject(tree, pCursor, conn, otherPort)
}
default:
log.Fatalf("port.AddNewObject error: wrong context type %T: %v\n", context, context)
}
default:
log.Fatalf("port.AddNewObject error: invalid type %T: %v\n", obj, obj)
}
return
}