本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.PortIf.AddNewObject方法的典型用法代码示例。如果您正苦于以下问题:Golang PortIf.AddNewObject方法的具体用法?Golang PortIf.AddNewObject怎么用?Golang PortIf.AddNewObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/axel-freesp/sge/interface/behaviour.PortIf
的用法示例。
在下文中一共展示了PortIf.AddNewObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddNewObject
func (t *signalGraphType) AddNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor, err error) {
switch obj.(type) {
case bh.NodeIf:
// TODO: Check if IO node and exists: copy position only and return
n := obj.(bh.NodeIf)
err = t.AddNode(n)
if err != nil {
err = fmt.Errorf("signalGraphType.AddNewObject error: %s", err)
nt := n.ItsType().(*nodeType)
if nt != nil {
ok, _ := nt.instances.Find(n)
if ok {
nt.instances.Remove(n)
}
}
return
}
newCursor = t.treeAddNewObject(tree, cursor, n)
parent := tree.Object(cursor)
switch parent.(type) {
case bh.SignalGraphIf:
case bh.ImplementationIf:
// propagate new node to all instances of embracing type
pCursor := tree.Parent(cursor)
nt := tree.Object(pCursor)
for _, nn := range nt.(bh.NodeTypeIf).Instances() {
nCursor := tree.Cursor(nn)
tCursor := tree.CursorAt(nCursor, parent)
tCursor.Position = cursor.Position
t.treeAddNewObject(tree, tCursor, n)
}
default:
log.Fatalf("signalGraphType.AddNewObject error: wrong parent type %T: %v\n", parent, parent)
}
case bh.ConnectionIf:
conn := obj.(bh.ConnectionIf)
var n bh.NodeIf
var p bh.PortIf
for _, n = range t.Nodes() {
if n.Name() == conn.From().Node().Name() {
nCursor := tree.CursorAt(cursor, n)
for _, p = range n.OutPorts() {
if conn.From().Name() == p.Name() {
pCursor := tree.CursorAt(nCursor, p)
return p.AddNewObject(tree, pCursor, obj)
}
}
}
}
default:
log.Fatalf("signalGraphType.AddNewObject error: wrong type %t: %v\n", obj, obj)
}
return
}