本文整理匯總了Golang中github.com/axel-freesp/sge/interface/behaviour.PortIf.AddToTree方法的典型用法代碼示例。如果您正苦於以下問題:Golang PortIf.AddToTree方法的具體用法?Golang PortIf.AddToTree怎麽用?Golang PortIf.AddToTree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/axel-freesp/sge/interface/behaviour.PortIf
的用法示例。
在下文中一共展示了PortIf.AddToTree方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: treeInstObject
func (t *nodeType) treeInstObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor) {
switch obj.(type) {
case bh.ImplementationIf:
impl := obj.(bh.ImplementationIf)
// update all instance nodes in the tree with new implementation
for _, n := range t.Instances() {
nCursor := tree.Cursor(n)
tCursor := tree.CursorAt(nCursor, t)
tCursor.Position = len(t.Implementation()) - 1
newICursor := tree.Insert(tCursor)
impl.AddToTree(tree, newICursor)
}
case bh.PortTypeIf:
pt := obj.(bh.PortTypeIf)
// update all instance nodes in the tree with new port
for _, n := range t.Instances() {
var p bh.PortIf
var ok bool
if pt.Direction() == gr.InPort {
p, ok, _ = n.(*node).inPort.Find(n.Name(), pt.Name())
} else {
p, ok, _ = n.(*node).outPort.Find(n.Name(), pt.Name())
}
if !ok {
log.Fatalf("nodeType.treeInstObject error: port %s not found.\n", pt.Name())
}
nCursor := tree.Cursor(n)
// Insert new port at the same position as in the type:
// Need to deal with implementations in type VS type in node
if cursor.Position >= 0 {
nCursor.Position = cursor.Position - len(t.Implementation()) + 1
}
newNCursor := tree.Insert(nCursor)
p.AddToTree(tree, newNCursor)
// Update mirrored type in node:
tCursor := tree.CursorAt(nCursor, t)
tCursor.Position = cursor.Position
t.treeNewObject(tree, tCursor, obj)
}
default:
log.Fatalf("nodeType.AddNewObject error: invalid type %T\n", obj)
}
return
}