當前位置: 首頁>>代碼示例>>Golang>>正文


Golang PortIf.RemoveConnection方法代碼示例

本文整理匯總了Golang中github.com/axel-freesp/sge/interface/behaviour.PortIf.RemoveConnection方法的典型用法代碼示例。如果您正苦於以下問題:Golang PortIf.RemoveConnection方法的具體用法?Golang PortIf.RemoveConnection怎麽用?Golang PortIf.RemoveConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/axel-freesp/sge/interface/behaviour.PortIf的用法示例。


在下文中一共展示了PortIf.RemoveConnection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: RemoveObject

func (p *port) RemoveObject(tree tr.TreeIf, cursor tr.Cursor) (removed []tr.IdWithObject) {
	parent := tree.Parent(cursor)
	if p != tree.Object(parent) {
		log.Fatal("port.RemoveObject error: not removing child of mine.")
	}
	obj := tree.Object(cursor)
	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()
			if p != thisPort {
				log.Fatal("port.RemoveObject error: invalid connection ", conn)
			}
		} else {
			otherPort = conn.To()
			thisPort = conn.From()
			if p != thisPort {
				log.Fatal("port.RemoveObject error: invalid connection ", conn)
			}
		}
		contextCursor := tree.Parent(tree.Parent(tree.Parent(cursor)))
		removed = p.treeRemoveObject(tree, cursor, conn, otherPort)
		context := tree.Object(contextCursor)
		switch context.(type) {
		case bh.SignalGraphIf:
		case bh.ImplementationIf:
			// propagate removed 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)
				cCursor := tree.CursorAt(pCursor, conn)
				p.treeRemoveObject(tree, cCursor, conn, otherPort)
			}

		default:
			log.Fatalf("port.RemoveObject error: wrong context type %T: %v\n", context, context)
		}
		p.RemoveConnection(otherPort)
		otherPort.RemoveConnection(p)

	default:
		log.Fatalf("bh.PortIf.RemoveObject error: invalid type %T: %v\n", obj, obj)
	}
	return
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:50,代碼來源:port.go


注:本文中的github.com/axel-freesp/sge/interface/behaviour.PortIf.RemoveConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。