本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.PortIf.Node方法的典型用法代码示例。如果您正苦于以下问题:Golang PortIf.Node方法的具体用法?Golang PortIf.Node怎么用?Golang PortIf.Node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/axel-freesp/sge/interface/behaviour.PortIf
的用法示例。
在下文中一共展示了PortIf.Node方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Connection
func (p *port) Connection(c bh.PortIf) bh.ConnectionIf {
_, ok, index := p.connected.Find(c.Node().Name(), c.Name())
if !ok {
log.Fatalf("port.bh.ConnectionIf error: port %v not in connected list of port %v\n", c, p)
}
return p.conn[index]
}
示例2: getMatchingPorts
// For connection only: lookup matching ports to connect.
func getMatchingPorts(fts *models.FilesTreeStore, object tr.TreeElementIf) (ret []bh.PortIf) {
var thisPort bh.PortIf
switch object.(type) {
case bh.PortIf:
thisPort = object.(bh.PortIf)
case bh.ConnectionIf:
log.Fatal("getMatchingPorts error: expecting Port, not Connection")
default:
log.Fatal("getMatchingPorts error: expecting Port")
}
thisNode := thisPort.Node()
graph := thisNode.Context()
for _, n := range graph.Nodes() {
var ports []bh.PortIf
if thisPort.Direction() == gr.InPort {
ports = n.OutPorts()
} else {
ports = n.InPorts()
}
for _, p := range ports {
if p.SignalType().TypeName() == thisPort.SignalType().TypeName() {
ret = append(ret, p)
}
}
}
return
}
示例3: RemoveConnection
func (p *port) RemoveConnection(c bh.PortIf) {
_, ok, index := p.connected.Find(c.Node().Name(), c.Name())
if !ok {
log.Fatalf("port.bh.ConnectionIf error: port %v not in connected list of port %v\n", c, p)
}
p.connected.Remove(c)
for index++; index < len(p.conn); index++ {
p.conn[index-1] = p.conn[index]
}
p.conn = p.conn[:len(p.conn)-1]
}
示例4: 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
}
示例5: updateConnections
func updateConnections(p bh.PortIf, fts *models.FilesTreeStore) {
nodeCursor := fts.Cursor(p.Node())
portCursor := fts.CursorAt(nodeCursor, p)
for _, c := range p.Connections() {
conn := p.Connection(c)
connCursor := fts.CursorAt(portCursor, conn)
otherNode := c.Node()
otherNodeCursor := fts.Cursor(otherNode)
otherPortCursor := fts.CursorAt(otherNodeCursor, c)
otherConnCursor := fts.CursorAt(otherPortCursor, conn)
connText := fmt.Sprintf("%s/%s -> %s/%s",
conn.From().Node().Name(), conn.From().Name(),
conn.To().Node().Name(), conn.To().Name())
fts.SetValueById(connCursor.Path, connText)
fts.SetValueById(otherConnCursor.Path, connText)
}
}
示例6: Remove
func (l *portList) Remove(p bh.PortIf) {
var i int
for i = range l.ports {
if p.Node().Name() == l.ports[i].Node().Name() && p.Name() == l.ports[i].Name() {
break
}
}
if i >= len(l.ports) {
for _, v := range l.ports {
log.Printf("portList.RemovePort have bh.PortIf %v\n", v)
}
log.Fatalf("portList.RemovePort error: bh.PortIf %v not in this list\n", p)
}
for i++; i < len(l.ports); i++ {
l.ports[i-1] = l.ports[i]
}
l.ports = l.ports[:len(l.ports)-1]
}