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


Golang tree.TreeIf類代碼示例

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


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

示例1: AddNewObject

func (l *library) AddNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor, err error) {
	if obj == nil {
		err = fmt.Errorf("library.AddNewObject error: nil object")
		return
	}
	switch obj.(type) {
	case bh.SignalTypeIf:
		t := obj.(bh.SignalTypeIf)
		ok := l.AddSignalType(t)
		if !ok {
			err = fmt.Errorf("library.AddNewObject warning: duplicate")
			return
		}
		cursor.Position = len(l.SignalTypes()) - 1
		newCursor = tree.Insert(cursor)
		t.AddToTree(tree, newCursor)

	case bh.NodeTypeIf:
		t := obj.(bh.NodeTypeIf)
		err = l.AddNodeType(t)
		if err != nil {
			err = fmt.Errorf("library.AddNewObject error: AddNodeType failed: %s", err)
			return
		}
		newCursor = tree.Insert(cursor)
		t.AddToTree(tree, newCursor)

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

示例2: RemoveFromTree

func (s *signalGraph) RemoveFromTree(tree tr.TreeIf) {
	gt := s.ItsType()
	tree.Remove(tree.Cursor(s))
	for len(gt.Nodes()) > 0 {
		gt.RemoveNode(gt.Nodes()[0].(*node))
	}
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:7,代碼來源:signalgraph.go

示例3: AddNewObject

func (a *arch) AddNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor, err error) {
	if obj == nil {
		err = fmt.Errorf("arch.AddNewObject error: nil object")
		return
	}
	switch obj.(type) {
	case pf.IOTypeIf:
		t := obj.(pf.IOTypeIf)
		_, ok := a.iotypes.Find(t.Name())
		if ok {
			err = fmt.Errorf("arch.AddNewObject warning: duplicate ioType name %s (abort)\n", t.Name())
			return
		}
		a.iotypes.Append(t.(*iotype))
		cursor.Position = len(a.IOTypes()) - 1
		newCursor = tree.Insert(cursor)
		t.AddToTree(tree, newCursor)

	case pf.ProcessIf:
		p := obj.(pf.ProcessIf)
		_, ok := a.processes.Find(p.Name())
		if ok {
			err = fmt.Errorf("arch.AddNewObject warning: duplicate process name %s (abort)\n", p.Name())
			return
		}
		a.processes.Append(p.(*process))
		newCursor = tree.Insert(cursor)
		p.AddToTree(tree, newCursor)
		//log.Printf("arch.AddNewObject: successfully added process %v\n", p)

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

示例4: AddToTree

func (p *port) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
	var prop tr.Property
	parentId := tree.Parent(cursor)
	if tree.Property(parentId).IsReadOnly() {
		prop = freesp.PropertyNew(false, false, false)
	} else {
		prop = freesp.PropertyNew(true, false, false)
	}
	var kind tr.Symbol
	if p.Direction() == gr.InPort {
		kind = tr.SymbolInputPort
	} else {
		kind = tr.SymbolOutputPort
	}
	err := tree.AddEntry(cursor, kind, p.Name(), p, prop)
	if err != nil {
		log.Fatalf("port.AddToTree: FilesTreeStore.AddEntry() failed: %s\n", err)
	}
	child := tree.Append(cursor)
	t := p.SignalType()
	t.AddToTree(tree, child)
	for _, c := range p.Connections() {
		child = tree.Append(cursor)
		p.Connection(c).AddToTree(tree, child)
	}
	return
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:27,代碼來源:port.go

示例5: AddToTree

func (t *iotype) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
	prop := freesp.PropertyNew(true, true, true)
	err := tree.AddEntry(cursor, tr.SymbolIOType, t.Name(), t, prop)
	if err != nil {
		log.Fatalf("iotype.AddToTree error: AddEntry failed: %s\n", err)
	}
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:7,代碼來源:iotype.go

示例6: AddToTree

func (t *signalGraph) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
	prop := freesp.PropertyNew(true, false, false)
	err := tree.AddEntry(cursor, tr.SymbolSignalGraph, t.Filename(), t, prop)
	if err != nil {
		log.Fatal("LibraryIf.AddToTree error: AddEntry failed: %s", err)
	}
	t.ItsType().AddToTree(tree, cursor)
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:8,代碼來源:signalgraph.go

示例7: AddToTree

func (c *connection) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
	text := fmt.Sprintf("%s/%s -> %s/%s", c.from.Node().Name(), c.from.Name(),
		c.to.Node().Name(), c.to.Name())
	prop := freesp.PropertyNew(false, false, true)
	err := tree.AddEntry(cursor, tr.SymbolConnection, text, c, prop)
	if err != nil {
		log.Fatalf("connection.AddToTree error: AddEntry failed: %s\n", err)
	}
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:9,代碼來源:connection.go

示例8: treeAddNewObject

func (p *port) treeAddNewObject(tree tr.TreeIf, cursor tr.Cursor, conn bh.ConnectionIf, otherPort bh.PortIf) (newCursor tr.Cursor) {
	newCursor = tree.Insert(cursor)
	conn.AddToTree(tree, newCursor)
	contextCursor := tree.Parent(tree.Parent(cursor))
	cCursor := tree.CursorAt(contextCursor, otherPort)
	cChild := tree.Append(cCursor)
	conn.AddToTree(tree, cChild)
	return
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:9,代碼來源:port.go

示例9: AddToTree

func (m *mapelem) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
	var s tr.Symbol
	if m.process == nil {
		s = tr.SymbolUnmapped
	} else {
		s = tr.SymbolMapped
	}
	err := tree.AddEntry(cursor, s, m.nodeId.String(), m, freesp.MayEdit)
	if err != nil {
		log.Fatalf("mapping.AddToTree error: AddEntry failed: %s\n", err)
	}
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:12,代碼來源:mapelem.go

示例10: AddToTree

func (c *channel) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
	var symbol tr.Symbol
	if c.Direction() == gr.InPort {
		symbol = tr.SymbolInChannel
	} else {
		symbol = tr.SymbolOutChannel
	}
	prop := freesp.PropertyNew(true, true, true)
	err := tree.AddEntry(cursor, symbol, c.Name(), c, prop)
	if err != nil {
		log.Fatalf("channel.AddToTree error: AddEntry failed: %s\n", err)
	}
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:13,代碼來源:channel.go

示例11: RemoveObject

func (n *node) RemoveObject(tree tr.TreeIf, cursor tr.Cursor) (removed []tr.IdWithObject) {
	parentId := tree.Parent(cursor)
	if n != tree.Object(parentId) {
		log.Fatal("node.RemoveObject error: not removing child of mine.")
	}
	nt := n.ItsType()
	obj := tree.Object(cursor)
	switch obj.(type) {
	case bh.PortIf:
		p := obj.(bh.PortIf)
		for index, c := range p.Connections() {
			conn := p.Connection(c)
			removed = append(removed, tr.IdWithObject{cursor.Path, index, conn})
		}
		var list portTypeList
		if p.Direction() == gr.InPort {
			list = nt.(*nodeType).inPorts
		} else {
			list = nt.(*nodeType).outPorts
		}
		_, ok, index := list.Find(p.Name())
		if !ok {
			log.Println("node.RemoveObject: saving removed port", p)
			removed = append(removed, tr.IdWithObject{parentId.Path, index, obj})
		}
		tree.Remove(cursor)

	default:
		log.Fatal("bh.NodeIf.RemoveObject error: invalid type %T", obj)
	}
	return
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:32,代碼來源:node.go

示例12: AddToTree

func (n *node) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
	var prop tr.Property
	if isParentReadOnly(tree, cursor) {
		prop = freesp.PropertyNew(false, false, false)
	} else {
		prop = freesp.PropertyNew(true, true, true)
	}
	var image tr.Symbol
	if len(n.InPorts()) == 0 {
		image = tr.SymbolInputNode
	} else if len(n.OutPorts()) == 0 {
		image = tr.SymbolOutputNode
	} else {
		image = tr.SymbolProcessingNode
	}
	err := tree.AddEntry(cursor, image, n.Name(), n, prop)
	if err != nil {
		log.Fatalf("node.AddToTree error: AddEntry failed: %s\n", err)
	}
	child := tree.Append(cursor)
	n.ItsType().AddToTree(tree, child)
	for _, p := range n.InPorts() {
		child := tree.Append(cursor)
		p.AddToTree(tree, child)
	}
	for _, p := range n.OutPorts() {
		child := tree.Append(cursor)
		p.AddToTree(tree, child)
	}
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:30,代碼來源:node.go

示例13: RemoveObject

func (t *nodeType) RemoveObject(tree tr.TreeIf, cursor tr.Cursor) (removed []tr.IdWithObject) {
	parentId := tree.Parent(cursor)
	if t != tree.Object(parentId) {
		log.Fatal("nodeType.RemoveObject error: not removing child of mine.")
	}
	obj := tree.Object(cursor)
	del := t.treeRemoveObject(tree, cursor)
	for _, d := range del {
		removed = append(removed, d)
	}
	del = t.treeRemoveInstObject(tree, cursor)
	for _, d := range del {
		removed = append(removed, d)
	}
	prefix, index := tree.Remove(cursor)
	removed = append(removed, tr.IdWithObject{prefix, index, obj})

	switch obj.(type) {
	case bh.ImplementationIf:
		impl := obj.(bh.ImplementationIf)
		// Remove obj in freesp model
		t.RemoveImplementation(impl)

	case bh.PortTypeIf:
		nt := obj.(bh.PortTypeIf)
		t.RemoveNamedPortType(nt)

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

示例14: treeNewObject

func (t *nodeType) treeNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor) {
	switch obj.(type) {
	case bh.ImplementationIf:
		cursor.Position = len(t.Implementation()) - 1
		newCursor = tree.Insert(cursor)
		obj.(bh.ImplementationIf).AddToTree(tree, newCursor)

	case bh.PortTypeIf:
		pt := obj.(bh.PortTypeIf)
		newCursor = tree.Insert(cursor)
		pt.AddToTree(tree, newCursor)
		for _, impl := range t.Implementation() {
			if impl.ImplementationType() == bh.NodeTypeGraph {
				// bh.NodeIf linked to outer port
				g := impl.Graph().(*signalGraphType)
				var n bh.NodeIf
				index := -len(t.Implementation())
				if pt.Direction() == gr.InPort {
					n = g.findInputNodeFromPortType(pt)
					if cursor.Position == tr.AppendCursor {
						index += len(g.InputNodes())
					}
				} else {
					n = g.findOutputNodeFromPortType(pt)
					if cursor.Position == tr.AppendCursor {
						index += len(g.InputNodes()) + len(g.OutputNodes())
					}
				}
				if n == nil {
					log.Fatalf("nodeType.AddNewObject error: invalid implementation...\n")
				}
				if cursor.Position != tr.AppendCursor {
					index += cursor.Position
				}
				gCursor := tree.CursorAt(cursor, impl)
				gCursor.Position = index
				n.AddToTree(tree, tree.Insert(gCursor))
			}
		}

	default:
		log.Fatalf("nodeType.AddNewObject error: invalid type %T\n", obj)
	}
	return
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:45,代碼來源:nodetype.go

示例15: AddToTree

func (m *mapping) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
	var child tr.Cursor
	err := tree.AddEntry(cursor, tr.SymbolMappings, m.Filename(), m, freesp.MayAddObject)
	if err != nil {
		log.Fatalf("mapping.AddToTree error: AddEntry failed: %s\n", err)
	}
	child = tree.Append(cursor)
	m.graph.AddToTree(tree, child)
	child = tree.Append(cursor)
	m.platform.AddToTree(tree, child)
	for _, nId := range m.MappedIds() {
		log.Printf("mapping.AddToTree: id=%s\n", nId.String())
		melem, ok := m.MappedElement(nId)
		if !ok {
			log.Fatal("mapping) AddToTree internal error: inconsistent maplist")
		}
		child = tree.Append(cursor)
		melem.AddToTree(tree, child)
	}
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:20,代碼來源:mapping.go


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