本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.LibraryIf类的典型用法代码示例。如果您正苦于以下问题:Golang LibraryIf类的具体用法?Golang LibraryIf怎么用?Golang LibraryIf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LibraryIf类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestLibrary
func TestLibrary(t *testing.T) {
case1 := []struct {
library string
}{
{`<library xmlns="http://www.freesp.de/xml/freeSP" version="1.0">
<signal-type name="s1" scope="" mode="" c-type="" message-id=""></signal-type>
<node-type name="Test">
<intype port="" type="s1"></intype>
<outtype port="" type="s1"></outtype>
</node-type>
</library>
`},
}
for i, c := range case1 {
freesp.Init()
var l bh.LibraryIf = LibraryNew("test.alml", nil)
buf := copyBuf(c.library)
_, err := l.Read(buf)
if err != nil {
t.Errorf("Testcase %d: Failed to read from buffer: %v", i, err)
return
}
}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:25,代码来源:library_test.go
示例2: TestGraph
func TestGraph(t *testing.T) {
case1 := []struct {
library, graph string
nodes, connections int
}{
{`<library xmlns="http://www.freesp.de/xml/freeSP" version="1.0">
<signal-type name="s1" scope="" mode="" c-type="" message-id=""></signal-type>
<node-type name="Test">
<intype port="" type="s1"></intype>
<outtype port="" type="s1"></outtype>
</node-type>
</library>
`, `<?xml version="1.0" encoding="UTF-8"?>
<signal-graph xmlns="http://www.freesp.de/xml/freeSP" version="1.0">
<nodes>
<input name="sensor">
<outtype type="s1"/>
</input>
<output name="actuator">
<intype type="s1"/>
</output>
<processing-node name="test" type="Test"></processing-node>
</nodes>
<connections>
<connect from="sensor" to="test"/>
<connect from="test" to="actuator"/>
</connections>
</signal-graph>
`, 3, 2},
}
for i, c := range case1 {
freesp.Init()
var l bh.LibraryIf = LibraryNew("test.alml", nil)
buf := copyBuf(c.library)
_, err := l.Read(buf)
if err != nil {
t.Errorf("Testcase %d: Failed to read from buffer: %v", i, err)
return
}
var sg bh.SignalGraphIf = SignalGraphNew("test.sml", nil)
buf = copyBuf(c.graph)
_, err = sg.Read(buf)
if err != nil {
t.Errorf("Testcase %d: Failed to read from buffer: %v", i, err)
return
}
var st bh.SignalGraphTypeIf = sg.ItsType()
if len(st.Nodes()) != c.nodes {
t.Errorf("Testcase %d: NodeIf count mismatch", i)
return
}
}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:54,代码来源:signalgraph_test.go
示例3: LibraryUsesNodeType
func LibraryUsesNodeType(l bh.LibraryIf, nt bh.NodeTypeIf) bool {
for _, t := range l.NodeTypes() {
if t.TypeName() == nt.TypeName() {
return true
}
for _, impl := range t.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
if SignalGraphTypeUsesNodeType(impl.Graph(), nt) {
return true
}
}
}
}
return false
}
开发者ID:axel-freesp,项目名称:sge,代码行数:15,代码来源:library.go
示例4: CreateXmlLibrary
func CreateXmlLibrary(l bh.LibraryIf) *backend.XmlLibrary {
fname := l.Filename()
ret := backend.XmlLibraryNew()
reflist := tool.StringListInit()
for _, t := range l.SignalTypes() {
ref := t.DefinedAt()
_, ok := reflist.Find(ref)
if !ok && ref != fname {
reflist.Append(ref)
}
}
for _, t := range l.NodeTypes() {
ref := t.DefinedAt()
_, ok := reflist.Find(ref)
if !ok && ref != fname {
reflist.Append(ref)
}
for _, impl := range t.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, lib := range impl.Graph().Libraries() {
ref := lib.Filename()
_, ok := reflist.Find(ref)
if !ok && ref != fname {
reflist.Append(ref)
}
}
}
}
}
for _, ref := range reflist.Strings() {
ret.Libraries = append(ret.Libraries, *CreateXmlLibraryRef(ref))
}
for _, t := range l.SignalTypes() {
ret.SignalTypes = append(ret.SignalTypes, *CreateXmlSignalType(t))
}
for _, t := range l.NodeTypes() {
ret.NodeTypes = append(ret.NodeTypes, *CreateXmlNodeType(t))
}
return ret
}
开发者ID:axel-freesp,项目名称:sge,代码行数:40,代码来源:backendconversions.go
示例5: RemoveRegisteredLibrary
func RemoveRegisteredLibrary(lib bh.LibraryIf) {
delete(libraries, lib.Filename())
}
开发者ID:axel-freesp,项目名称:sge,代码行数:3,代码来源:globals.go
示例6: RegisterLibrary
func RegisterLibrary(lib bh.LibraryIf) {
libraries[lib.Filename()] = lib
}
开发者ID:axel-freesp,项目名称:sge,代码行数:3,代码来源:globals.go
注:本文中的github.com/axel-freesp/sge/interface/behaviour.LibraryIf类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论