2010-11-08 04:48:50 +01:00
|
|
|
/*
|
|
|
|
|
OUTPUT-MAPPING.hpp - generic interface for translation of output designations
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2010, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PROC_MOBJECT_OUTPUT_MAPPING_H
|
|
|
|
|
#define PROC_MOBJECT_OUTPUT_MAPPING_H
|
|
|
|
|
|
|
|
|
|
#include "proc/mobject/output-designation.hpp"
|
2010-11-24 06:21:32 +01:00
|
|
|
#include "lib/meta/function.hpp"
|
|
|
|
|
|
2010-11-08 04:48:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace mobject {
|
2010-11-24 06:21:32 +01:00
|
|
|
|
|
|
|
|
namespace { // Helper to extract and rebind definition types
|
|
|
|
|
|
2010-11-25 04:52:49 +01:00
|
|
|
using std::tr1::function;
|
|
|
|
|
|
2010-11-24 06:21:32 +01:00
|
|
|
template<class DEF>
|
2010-11-25 04:52:49 +01:00
|
|
|
class _def
|
2010-11-24 06:21:32 +01:00
|
|
|
{
|
2010-11-25 04:52:49 +01:00
|
|
|
typedef asset::ID<asset::Pipe> PId;
|
2010-11-24 06:21:32 +01:00
|
|
|
|
|
|
|
|
template<typename FUN>
|
|
|
|
|
struct Rebind;
|
|
|
|
|
|
|
|
|
|
template<typename RET>
|
|
|
|
|
struct Rebind<RET(DEF::*)(PId)>
|
|
|
|
|
{
|
|
|
|
|
typedef RET Res;
|
|
|
|
|
};
|
|
|
|
|
|
2010-11-25 04:52:49 +01:00
|
|
|
typedef typeof(&DEF::output) OutputMappingMemberFunc; // GCC extension: "typeof"
|
|
|
|
|
typedef Rebind<OutputMappingMemberFunc> Rebinder;
|
2010-11-24 06:21:32 +01:00
|
|
|
|
2010-11-25 04:52:49 +01:00
|
|
|
public:
|
|
|
|
|
typedef typename Rebinder::Res Target;
|
|
|
|
|
typedef function<Target(PId)> OutputMappingFunc;
|
2010-11-24 06:21:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
2010-11-08 04:48:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* OutputMapping is a facility to resolve output designations.
|
|
|
|
|
* For a given specification, resolution to the desired
|
|
|
|
|
* target specification may be derived. Here, the
|
|
|
|
|
* type of the target specification is defined
|
|
|
|
|
* through the type parameter.
|
|
|
|
|
*
|
|
|
|
|
* This is an Interface, intended to be used in the signature
|
|
|
|
|
* of API functions either providing or requiring a Mapping.
|
|
|
|
|
*/
|
2010-11-23 03:40:11 +01:00
|
|
|
template<class DEF>
|
2010-11-08 04:48:50 +01:00
|
|
|
class OutputMapping
|
|
|
|
|
{
|
2010-11-25 04:52:49 +01:00
|
|
|
typedef _def<DEF> Setup;
|
|
|
|
|
|
2010-11-08 04:48:50 +01:00
|
|
|
public:
|
2010-11-25 04:52:49 +01:00
|
|
|
typedef typename Setup::Target Target;
|
2010-11-08 04:48:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace mobject
|
|
|
|
|
#endif
|