本文整理汇总了Golang中github.com/axel-freesp/sge/interface/tree.TreeIf类的典型用法代码示例。如果您正苦于以下问题:Golang TreeIf类的具体用法?Golang TreeIf怎么用?Golang TreeIf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeIf类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: AddToTree
func (p *portType) 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, true, true)
}
var kind tr.Symbol
if p.Direction() == gr.InPort {
kind = tr.SymbolInputPortType
} else {
kind = tr.SymbolOutputPortType
}
err := tree.AddEntry(cursor, kind, p.Name(), p, prop)
if err != nil {
log.Fatal("bh.PortTypeIf.AddToTree: FilesTreeStore.AddEntry() failed: %s\n", err)
}
child := tree.Append(cursor)
p.SignalType().AddToTree(tree, child)
}
开发者ID:axel-freesp,项目名称:sge,代码行数:21,代码来源:porttype.go
示例17: AddToTree
func (t *signalGraphType) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
for _, n := range t.InputNodes() {
child := tree.Append(cursor)
n.AddToTree(tree, child)
}
for _, n := range t.OutputNodes() {
child := tree.Append(cursor)
n.AddToTree(tree, child)
}
for _, n := range t.ProcessingNodes() {
child := tree.Append(cursor)
n.AddToTree(tree, child)
}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:14,代码来源:signalgraphtype.go
示例18: AddToTree
func (p *process) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
prop := freesp.PropertyNew(true, true, true)
err := tree.AddEntry(cursor, tr.SymbolProcess, p.Name(), p, prop)
if err != nil {
log.Fatalf("process.AddToTree error: AddEntry failed: %s\n", err)
}
for _, c := range p.InChannels() {
child := tree.Append(cursor)
c.AddToTree(tree, child)
}
for _, c := range p.OutChannels() {
child := tree.Append(cursor)
c.AddToTree(tree, child)
}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:15,代码来源:process.go
示例19: AddToTree
func (l *library) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
prop := freesp.PropertyNew(true, false, false)
err := tree.AddEntry(cursor, tr.SymbolLibrary, l.Filename(), l, prop)
if err != nil {
log.Fatalf("bh.LibraryIf.AddToTree error: AddEntry failed: %s\n", err)
}
for _, t := range l.SignalTypes() {
child := tree.Append(cursor)
t.AddToTree(tree, child)
}
for _, t := range l.NodeTypes() {
child := tree.Append(cursor)
t.AddToTree(tree, child)
}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:15,代码来源:library.go
示例20: AddToTree
func (a *arch) AddToTree(tree tr.TreeIf, cursor tr.Cursor) {
//log.Printf("arch.AddToTree: %s\n", a.Name())
prop := freesp.PropertyNew(true, true, true)
err := tree.AddEntry(cursor, tr.SymbolArch, a.Name(), a, prop)
if err != nil {
log.Fatalf("arch.AddToTree error: AddEntry failed: %s", err)
}
for _, t := range a.IOTypes() {
child := tree.Append(cursor)
t.AddToTree(tree, child)
}
for _, p := range a.Processes() {
child := tree.Append(cursor)
p.AddToTree(tree, child)
}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:16,代码来源:arch.go
注:本文中的github.com/axel-freesp/sge/interface/tree.TreeIf类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论