本文整理汇总了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
}