From 645ddd284c32084283291f928b97f3d3c035505c Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 25 Nov 2010 04:52:49 +0100 Subject: [PATCH] WIP Solution draft for defining an output mapping type --- src/lib/meta/duck-detector.hpp | 2 +- src/proc/assetmanager.cpp | 11 ++++++----- src/proc/mobject/output-mapping.hpp | 21 ++++++++++++--------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/lib/meta/duck-detector.hpp b/src/lib/meta/duck-detector.hpp index 70bec2a18..9ee864880 100644 --- a/src/lib/meta/duck-detector.hpp +++ b/src/lib/meta/duck-detector.hpp @@ -41,7 +41,7 @@ ** ** Most of these trait templates rely on a creative use of function overloading. The C++ standard ** requires the compiler silently to drop any candidate of overload resolution which has - ** gotten an invalid function signature as a result of instantiating a template (type). This allow + ** gotten an invalid function signature as a result of instantiating a template (type). This allows ** us to set up kind of a "trap" for the compiler: we present two overloaded candidate functions ** with a different return type; by investigating the resulting return type we're able to figure ** out the overload actually picked by the compiler. diff --git a/src/proc/assetmanager.cpp b/src/proc/assetmanager.cpp index 8e562dc26..ec7421b4a 100644 --- a/src/proc/assetmanager.cpp +++ b/src/proc/assetmanager.cpp @@ -245,11 +245,12 @@ namespace asset { template ID AssetManager::reg (Asset* obj, const Asset::Ident& idi); - template P AssetManager::getAsset (const ID& id) throw(lumiera::error::Invalid); - template P AssetManager::getAsset (const ID& id) throw(lumiera::error::Invalid); - template P AssetManager::getAsset (const ID& id) throw(lumiera::error::Invalid); - template P AssetManager::getAsset (const ID& id) throw(lumiera::error::Invalid); - template P AssetManager::getAsset (const ID& id) throw(lumiera::error::Invalid); + template P AssetManager::getAsset (const ID& id); + template P AssetManager::getAsset (const ID& id); + template P AssetManager::getAsset (const ID& id); + template P AssetManager::getAsset (const ID& id); + template P AssetManager::getAsset (const ID& id); + template P AssetManager::getAsset (const ID& id); template P AssetManager::wrap (const Asset& asset); template P AssetManager::wrap (const Media& asset); diff --git a/src/proc/mobject/output-mapping.hpp b/src/proc/mobject/output-mapping.hpp index 7334d8181..d0495ddc2 100644 --- a/src/proc/mobject/output-mapping.hpp +++ b/src/proc/mobject/output-mapping.hpp @@ -33,13 +33,12 @@ namespace mobject { namespace { // Helper to extract and rebind definition types + using std::tr1::function; + template - struct _def + class _def { - typedef asset::ID PId; - - template - RET extractFunctionSignature (RET(DEF::*func)(PId)); + typedef asset::ID PId; template struct Rebind; @@ -50,11 +49,12 @@ namespace mobject { typedef RET Res; }; + typedef typeof(&DEF::output) OutputMappingMemberFunc; // GCC extension: "typeof" + typedef Rebind Rebinder; - typedef typename Rebind<&DEF::output> Rebinder; - - typedef typename Rebinder::Res Res; - typedef typename function OutputMappingFunc; + public: + typedef typename Rebinder::Res Target; + typedef function OutputMappingFunc; }; } @@ -73,7 +73,10 @@ namespace mobject { template class OutputMapping { + typedef _def Setup; + public: + typedef typename Setup::Target Target; };