Beispiel #1
0
func RemoveRegisteredNodeType(nt bh.NodeTypeIf) {
	name := nt.TypeName()
	delete(nodeTypes, name)
	_, ok := registeredNodeTypes.Find(name)
	if ok {
		registeredNodeTypes.Remove(name)
	}
}
Beispiel #2
0
func isAutoType(nt bh.NodeTypeIf) bool {
	if strings.HasPrefix(nt.TypeName(), "autoInputNodeType-") {
		return true
	}
	if strings.HasPrefix(nt.TypeName(), "autoOutputNodeType-") {
		return true
	}
	return false
}
Beispiel #3
0
func CreateXmlNodeType(t bh.NodeTypeIf) *backend.XmlNodeType {
	ret := backend.XmlNodeTypeNew(t.TypeName())
	for _, p := range t.InPorts() {
		ret.InPort = append(ret.InPort, *CreateXmlNamedInPort(p))
	}
	for _, p := range t.OutPorts() {
		ret.OutPort = append(ret.OutPort, *CreateXmlNamedOutPort(p))
	}
	for _, impl := range t.Implementation() {
		ret.Implementation = append(ret.Implementation, *CreateXmlImplementation(impl))
	}
	return ret
}
Beispiel #4
0
func SignalGraphTypeUsesNodeType(t bh.SignalGraphTypeIf, nt bh.NodeTypeIf) bool {
	for _, n := range t.Nodes() {
		if n.ItsType().TypeName() == nt.TypeName() {
			return true
		}
		for _, impl := range n.ItsType().Implementation() {
			if impl.ImplementationType() == bh.NodeTypeGraph {
				if SignalGraphTypeUsesNodeType(impl.Graph(), nt) {
					return true
				}
			}
		}
	}
	return false
}
Beispiel #5
0
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
}
Beispiel #6
0
func (l *library) AddNodeType(t bh.NodeTypeIf) error {
	nType, ok := freesp.GetNodeTypeByName(t.TypeName())
	if ok {
		log.Printf(`library.AddNodeType: warning: adding existing node
			type definition %s (taking the existing one)`, t.TypeName())
	} else {
		nType = t.(*nodeType)
		freesp.RegisterNodeType(nType)
		log.Println("library.AddNodeType: registered ", t.TypeName())
	}
	for _, nt := range l.nodeTypes.NodeTypes() {
		if nt.TypeName() == t.TypeName() {
			return fmt.Errorf(`adding duplicate node type definition
				%s (ignored)`, t.TypeName())
		}
	}
	l.nodeTypes.Append(nType)
	return nil
}
Beispiel #7
0
func NodeNew(name string, ntype bh.NodeTypeIf, context bh.SignalGraphTypeIf) (ret *node, err error) {
	for _, n := range context.Nodes() {
		if n.Name() == name {
			err = fmt.Errorf("NodeNew error: node '%s' already exists in context.", name)
			return
		}
	}
	if len(ntype.InPorts())+len(ntype.OutPorts()) == 0 {
		err = fmt.Errorf("NodeNew error: type '%s' has no ports.", ntype.TypeName())
		return
	}
	ret = &node{*gr.PathModePositionerObjectNew(), context, name, ntype,
		portListInit(), portListInit(), nil, false}
	for _, p := range ntype.InPorts() {
		ret.addInPort(p)
	}
	for _, p := range ntype.OutPorts() {
		ret.addOutPort(p)
	}
	ntype.(*nodeType).addInstance(ret)
	return
}
Beispiel #8
0
func RegisterNodeType(nt bh.NodeTypeIf) {
	nodeTypes[nt.TypeName()] = nt
	registeredNodeTypes.Append(nt.TypeName())
}