Exemple #1
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
}
Exemple #2
0
// TODO: Create namedPortType object first and hand it here?
func newPort(pt bh.PortTypeIf, n bh.NodeIf) *port {
	return &port{*gr.PathModePositionerObjectNew(), pt, portListInit(), nil, n}
}