Example #1
0
func SignalGraphApplyHints(s bh.SignalGraphIf, xmlhints *backend.XmlGraphHint) (err error) {
	if s.Filename() != xmlhints.Ref {
		err = fmt.Errorf("SignalGraphApplyHints error: filename mismatch\n")
		return
	}
	g := s.ItsType()
	for _, xmln := range xmlhints.InputNode {
		n, ok := g.NodeByName(xmln.Name)
		if ok {
			n.SetExpanded(false)
			freesp.PathModePositionerApplyHints(n, xmln.XmlModeHint)
		}
	}
	for _, xmln := range xmlhints.OutputNode {
		n, ok := g.NodeByName(xmln.Name)
		if ok {
			n.SetExpanded(false)
			freesp.PathModePositionerApplyHints(n, xmln.XmlModeHint)
		}
	}
	NodesApplyHints("", g, xmlhints.ProcessingNode)
	return
}
Example #2
0
func NodesApplyHints(path string, g bh.SignalGraphTypeIf, xmlh []backend.XmlNodePosHint) {
	for _, n := range g.ProcessingNodes() {
		var p string
		if len(path) == 0 {
			p = n.Name()
		} else {
			p = fmt.Sprintf("%s/%s", path, n.Name())
		}
		ok := false
		var xmln backend.XmlNodePosHint
		for _, xmln = range xmlh {
			if p == xmln.Name {
				ok = true
				break
			}
		}
		if ok {
			n.SetExpanded(xmln.Expanded)
			freesp.PathModePositionerApplyHints(n, xmln.XmlModeHint)
			for i, p := range n.InPorts() {
				ok = p.Name() == xmln.InPorts[i].Name
				if !ok {
					log.Printf("NodesApplyHints FIXME: name mismatch\n")
					continue
				}
				freesp.ModePositionerApplyHints(p, xmln.InPorts[i].XmlModeHint)
			}
			for i, p := range n.OutPorts() {
				ok = p.Name() == xmln.OutPorts[i].Name
				if !ok {
					log.Printf("NodesApplyHints FIXME: name mismatch\n")
					continue
				}
				freesp.ModePositionerApplyHints(p, xmln.OutPorts[i].XmlModeHint)
			}
		}
		nt := n.ItsType()
		for _, impl := range nt.Implementation() {
			if impl.ImplementationType() == bh.NodeTypeGraph {
				NodesApplyHints(p, impl.Graph(), xmlh)
				break
			}
		}
	}
}