From a7ec68095525cff1fae1000847eacb4e45928ef4 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 24 Nov 2010 06:21:32 +0100 Subject: [PATCH] WIP chewing on the problem how to define a output mapping type --- src/proc/mobject/output-mapping.hpp | 31 ++++++++++++++++++- .../proc/mobject/output-mapping-test.cpp | 19 ++++++++---- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/proc/mobject/output-mapping.hpp b/src/proc/mobject/output-mapping.hpp index ee35cb036..7334d8181 100644 --- a/src/proc/mobject/output-mapping.hpp +++ b/src/proc/mobject/output-mapping.hpp @@ -25,10 +25,39 @@ #define PROC_MOBJECT_OUTPUT_MAPPING_H #include "proc/mobject/output-designation.hpp" +#include "lib/meta/function.hpp" + namespace mobject { - + + namespace { // Helper to extract and rebind definition types + + template + struct _def + { + typedef asset::ID PId; + + template + RET extractFunctionSignature (RET(DEF::*func)(PId)); + + template + struct Rebind; + + template + struct Rebind + { + typedef RET Res; + }; + + + typedef typename Rebind<&DEF::output> Rebinder; + + typedef typename Rebinder::Res Res; + typedef typename function OutputMappingFunc; + }; + + } /** diff --git a/tests/components/proc/mobject/output-mapping-test.cpp b/tests/components/proc/mobject/output-mapping-test.cpp index b0d8a3153..1c3bd397e 100644 --- a/tests/components/proc/mobject/output-mapping-test.cpp +++ b/tests/components/proc/mobject/output-mapping-test.cpp @@ -34,12 +34,13 @@ //#include //#include +#include //using boost::format; //using lumiera::Time; //using util::contains; using util::isnil; -//using std::string; +using std::string; //using std::cout; @@ -50,6 +51,8 @@ namespace test { using asset::Pipe; using asset::PPipe; + typedef asset::ID PID; + namespace { } @@ -66,7 +69,11 @@ namespace test { { struct DummyDef { - + string + output (PID target) + { + return Pipe::lookup(target)->ident.name; + } }; typedef OutputMapping Mapping; @@ -88,7 +95,7 @@ namespace test { PPipe p1 = Pipe::query("id(hairy)"); PPipe p2 = Pipe::query("id(furry)"); - PPipe pX = Pipe::query(""); + PPipe pX = Pipe::query("id(curly)"); map[p1] = p2; CHECK (!isnil (map)); @@ -109,16 +116,16 @@ namespace test { PPipe p1 = Pipe::query("id(hairy)"); PPipe p2 = Pipe::query("id(furry)"); - PPipe pX = Pipe::query(""); + PPipe pi = Pipe::query("id(nappy)"); - m1[pX] = p1; + m1[pi] = p1; Mapping m2(m1); CHECK (!isnil (m2)); CHECK (1 == m2.size()); CHECK (m1[p1] == "hairy"); CHECK (m2[p1] == "hairy"); - m1[pX] = p2; + m1[pi] = p2; CHECK (m1[p1] == "furry"); CHECK (m2[p1] == "hairy");