From: g0dil Date: Thu, 13 Aug 2009 14:26:43 +0000 (+0000) Subject: PPI: BUGFIX: Duplicate connector registration X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=d1d92fb783dc558dcf7bdc34ee933c10e1c8d227;p=senf.git PPI: BUGFIX: Duplicate connector registration git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1292 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/Module.cci b/PPI/Module.cci index de184f7..3f0817d 100644 --- a/PPI/Module.cci +++ b/PPI/Module.cci @@ -55,8 +55,11 @@ prefix_ senf::ppi::ModuleManager & senf::ppi::module::Module::moduleManager() prefix_ void senf::ppi::module::Module::registerConnector(connector::Connector & connector) { - connectorRegistry_.push_back(&connector); - connector.setModule(*this); + if (std::find(connectorRegistry_.begin(), connectorRegistry_.end(), &connector) + == connectorRegistry_.end()) { + connectorRegistry_.push_back(&connector); + connector.setModule(*this); + } } prefix_ senf::ppi::RouteBase & diff --git a/PPI/drawmodules.py b/PPI/drawmodules.py index 103431d..51c6aaa 100644 --- a/PPI/drawmodules.py +++ b/PPI/drawmodules.py @@ -6,8 +6,7 @@ mode = "MODULE" sys.stdout.write(""" digraph Modules { -node [shape=box, fontsize=10, fontname="Helvetica", height=.2]; -edge [labelfontsize=8, labelfontname="Helvetica"] +node [shape=Mrecord, fontsize=8, fontname="Helvetica"]; """) modules = {} @@ -19,45 +18,53 @@ for line in sys.stdin: mode = "MODULE" elif mode == "MODULE": moduleid, module = line.split(' ',1); + moduleid = moduleid[1:] connectorid = type = peerid = None modules[moduleid] = (module, []); mode = "CONNECTOR" else: connectorid, type = line.split(' ',1); + connectorid = connectorid[1:] elts = type.rsplit(' ',1); if elts[-1].startswith('0x'): type, peerid = elts + peerid = peerid[1:] else: peerid = None modules[moduleid][1].append((connectorid, type, peerid)) connectors[connectorid] = moduleid -for moduleid, (type, cs) in modules.iteritems(): - type = type.split('<',1)[0] - type = type.rsplit('::',1)[-1] - sys.stdout.write('"%s" [label="%s (%s)"]\n' % (moduleid, type, moduleid)) +for moduleid, (module, cs) in modules.iteritems(): + module = module.split('<',1)[0] + module = module.rsplit('::',1)[-1] + inputs = [] + outputs = [] + for connectorid, type, peerid in cs: + if 'Input' in type: inputs.append("<%s>%s" % (connectorid,connectorid)) + else: outputs.append("<%s>%s" % (connectorid,connectorid)) + rows = [] + if inputs: rows.append("{%s}" % "|".join(inputs)) + rows.append("%s (%s)" % (module, moduleid)) + if outputs: rows.append("{%s}" % "|".join(outputs)) + sys.stdout.write('%s [label="{%s}"]\n' % (moduleid, "|".join(rows) )) anonid = 0 for moduleid, (type, cs) in modules.iteritems(): for connectorid, type, peerid in cs: opts = [] - if "Passive" in type: - opts.append("arrowtail=odot"); - if peerid: - opts.append('headlabel="%s"' % peerid) - opts.append('taillabel="%s"' % connectorid) + if "Passive" in type: opts.append("arrowtail=odot"); opts = ",".join(opts) - if opts: - opts = " [%s]" % opts + if opts: opts = " [%s]" % opts if "Output" in type and peerid is not None: - sys.stdout.write('"%s" -> "%s"%s\n' % (moduleid, connectors[peerid],opts)) + sys.stdout.write('%s:%s -> %s:%s%s\n' + % (moduleid, connectorid, connectors[peerid], peerid, opts)) elif peerid is None: sys.stdout.write('anon%d [label="", shape=point, height=.05];\n' % anonid) if "Output" in type: - sys.stdout.write('"%s" -> anon%d%s;\n' % (moduleid, anonid, opts)) + sys.stdout.write('%s:%s -> anon%d%s;\n' % (moduleid, connectorid, anonid, opts)) else: - sys.stdout.write('anon%d -> "%s"%s;\n' % (anonid, moduleid, opts)) + sys.stdout.write('anon%d -> %s:%s%s;\n' % (anonid, moduleid, connectorid, opts)) anonid += 1 sys.stdout.write("}\n")