コード例 #1
0
ファイル: mapping.go プロジェクト: axel-freesp/sge
func MappingApplyHints(m mp.MappingIf, xmlhints *backend.XmlMappingHint) (err error) {
	if m.Filename() != xmlhints.Ref {
		err = fmt.Errorf("MappingApplyHints error: filename mismatch\n")
		return
	}
	//log.Printf("MappingApplyHints: xmlhints = %v\n", xmlhints)
	for _, nId := range m.MappedIds() {
		melem, ok := m.MappedElement(nId)
		if !ok {
			log.Fatalf("MappingApplyHints internal error: %v has no mapping\n", nId)
		}
		log.Printf("MappingApplyHints: %v\n", nId)
		xmlh, ok := findMapHint(xmlhints, nId.String())
		if ok {
			melem.SetExpanded(xmlh.Expanded)
			log.Printf("MappingApplyHints: %v expanded: %v\n", nId, melem.Expanded())
			freesp.ModePositionerApplyHints(melem, xmlh.XmlModeHint)
			for i, xmlp := range xmlh.InPorts {
				freesp.ModePositionerApplyHints(&melem.(*mapelem).inports[i], xmlp.XmlModeHint)
			}
			for i, xmlp := range xmlh.OutPorts {
				freesp.ModePositionerApplyHints(&melem.(*mapelem).outports[i], xmlp.XmlModeHint)
			}
		}
	}
	return
}
コード例 #2
0
ファイル: signalgraph.go プロジェクト: axel-freesp/sge
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
			}
		}
	}
}