From 847cc9c267b4a917d380b2d8f1c2165be2b2d1a3 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 30 Jul 2008 03:56:13 +0200 Subject: [PATCH] WIP rearranged some headers --- src/common/configrules.hpp | 2 +- src/common/meta/configflags.hpp | 180 +++++++++ .../{typelistutil.hpp => meta/generator.hpp} | 46 +-- src/common/{ => meta}/typelist.hpp | 4 +- src/common/meta/typelistutil.hpp | 213 ++++++++++ src/common/meta/util.hpp | 74 ++++ src/common/variant.hpp | 2 +- src/common/visitor.hpp | 2 +- src/common/wrapperptr.hpp | 2 +- src/proc/engine/nodeoperation.hpp | 13 +- src/proc/engine/nodewiringconfig.hpp | 376 ++---------------- src/tool/try.cpp | 2 +- .../{typelist => meta}/configflagstest.cpp | 10 +- .../generatortest.cpp} | 12 +- .../{typelist => meta}/typelistmaniptest.cpp | 4 +- .../{typelist => meta}/typelisttest.cpp | 2 +- 16 files changed, 535 insertions(+), 409 deletions(-) create mode 100644 src/common/meta/configflags.hpp rename src/common/{typelistutil.hpp => meta/generator.hpp} (86%) rename src/common/{ => meta}/typelist.hpp (98%) create mode 100644 src/common/meta/typelistutil.hpp create mode 100644 src/common/meta/util.hpp rename tests/common/{typelist => meta}/configflagstest.cpp (97%) rename tests/common/{typelist/typelistutiltest.cpp => meta/generatortest.cpp} (94%) rename tests/common/{typelist => meta}/typelistmaniptest.cpp (98%) rename tests/common/{typelist => meta}/typelisttest.cpp (98%) diff --git a/src/common/configrules.hpp b/src/common/configrules.hpp index 0968c88d4..e80ccfa8a 100644 --- a/src/common/configrules.hpp +++ b/src/common/configrules.hpp @@ -48,7 +48,7 @@ #include "common/p.hpp" #include "common/query.hpp" -#include "common/typelistutil.hpp" +#include "common/meta/generator.hpp" #include "common/singletonsubclass.hpp" //TODO: is it sensible to bring in the types explicitly here? (it's not necessary, but may be convenient...) diff --git a/src/common/meta/configflags.hpp b/src/common/meta/configflags.hpp new file mode 100644 index 000000000..daf8917de --- /dev/null +++ b/src/common/meta/configflags.hpp @@ -0,0 +1,180 @@ +/* + CONFIGFLAGS.hpp - Building classes based on configuration cases + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + 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. + +*/ + + +/** @file configflags.hpp + ** Under some circumstances it is necessary to assemble functionality + ** out of elementary building blocks. Especially, this assembly can be + ** expressed as template specialisations directed by a configuration type. + ** Thus, the purpose of this header is to encode a flag-like configuraiton + ** as distinct types, which can be used to select such specialisations. + ** Each possible configuration can be encoded as a list of flags, which allows + ** to generate, filter and process those configurations. The final goal is to + ** automatically generate a factory which will deliver objects configured + ** according to the configuration in question. + ** + ** @see proc::engine::config::Strategy usage example + ** @see proc::engine::config::ConfigSelector + ** @see typelist.hpp + ** + */ + + +#ifndef LUMIERA_META_CONFIGFLAGS_H +#define LUMIERA_META_CONFIGFLAGS_H + + +#include "common/meta/typelist.hpp" + + +namespace lumiera { + namespace typelist { + + + template struct Flag { typedef Flag ID; }; + template<> struct Flag<0> { typedef NullType ID; }; + + + template< char f1=0 + , char f2=0 + , char f3=0 + , char f4=0 + , char f5=0 + > + struct Flags + { + typedef typename Types< typename Flag::ID + , typename Flag::ID + , typename Flag::ID + , typename Flag::ID + , typename Flag::ID + >::List + Tuple; + typedef Tuple List; + }; + + + template< char f1=0 + , char f2=0 + , char f3=0 + , char f4=0 + , char f5=0 + > + struct Config ///< distinct type representing a configuration + { + typedef typename Flags::Tuple Flags; + typedef Flags List; + }; + + + + template + struct ConfigSetFlag; ///< set (prepend) the Flag to the given config + + template< char Fl + , char f1 + , char f2 + , char f3 + , char f4 + , char IGN + > + struct ConfigSetFlag > + { + typedef Config Config; + }; + + + + /** build a configuration type for the given list-of-flags */ + template > + struct DefineConfigByFlags + { + typedef CONF Config; + typedef Config Type; + }; + template + struct DefineConfigByFlags< Node,FLAGS>, CONF> + { + typedef typename ConfigSetFlag< Fl + , typename DefineConfigByFlags::Config + >::Config Config; + typedef Config Type; + }; + + + /** + * Helper for calculating values and for + * invoking runtime code based on a given FlagTuple. + * Can also be used on a Typelist of several Configs. + * The latter case is typically used to invoke an operation + * while ennumerating all Flag-Configurations defined in Code. + * An example would be to build (at runtime) an dispatcher table. + * Explanation: For the Case covering a List of Configs, we provide + * a templated visitaion function, which can accept a functor object + * to be invoked on each Configuration. + */ + template + struct FlagInfo; + + template + struct FlagInfo, FLAGS> > + { + enum{ BITS = MAX(ff, FlagInfo::BITS) + , CODE = (1<::CODE + }; + }; + template<> + struct FlagInfo + { + enum{ BITS = 0 + , CODE = 0 + }; + + template + static typename FUNC::Ret + accept (FUNC& functor) + { + return functor.done(); + } + }; + template + struct FlagInfo > + { + typedef typename CONF::Flags ThisFlags; + enum{ BITS = MAX (char(FlagInfo::BITS), char(FlagInfo::BITS)) + }; + + template + static typename FUNC::Ret + accept (FUNC& functor) + { + functor.template visit(FlagInfo::CODE); + return FlagInfo::accept (functor); + } + }; + + + + } // namespace typelist + +} // namespace lumiera +#endif diff --git a/src/common/typelistutil.hpp b/src/common/meta/generator.hpp similarity index 86% rename from src/common/typelistutil.hpp rename to src/common/meta/generator.hpp index 3fb6a531e..59f340b5d 100644 --- a/src/common/typelistutil.hpp +++ b/src/common/meta/generator.hpp @@ -1,5 +1,5 @@ /* - TYPELISTUTIL.hpp - metaprogramming utilities for lists-of-types + GENERATOR.hpp - metaprogramming utilities for generating classes and interfaces Copyright (C) Lumiera.org 2008, Hermann Vosseler @@ -38,7 +38,7 @@ This code is heavily inspired by */ -/** @file typelistutil.hpp +/** @file generator.hpp ** Helpers for working with lumiera::typelist::Types (i.e. lists-of-types). ** The main purpose is to build interfaces and polymorphic implementations ** (using virtual functions) based on templated Types or Collections of types, @@ -50,10 +50,10 @@ This code is heavily inspired by */ -#ifndef LUMIERA_TYPELISTUTIL_H -#define LUMIERA_TYPELISTUTIL_H +#ifndef LUMIERA_META_GENERATOR_H +#define LUMIERA_META_GENERATOR_H -#include "common/typelist.hpp" +#include "common/meta/typelist.hpp" @@ -196,42 +196,6 @@ namespace lumiera }; - /** - * Metafunction counting the number of Types in the collection - */ - template - struct count; - template<> - struct count - { - enum{ value = 0 }; - }; - template - struct count > - { - enum{ value = 1 + count::value }; - }; - - /** - * Metafunction " max( sizeof(T) ) for T in TYPES " - */ - template - struct maxSize; - template<> - struct maxSize - { - enum{ value = 0 }; - }; - template - struct maxSize > - { - enum{ thisval = sizeof(TY) - , nextval = maxSize::value - , value = nextval > thisval? nextval:thisval - }; - }; - - } // namespace typelist } // namespace lumiera diff --git a/src/common/typelist.hpp b/src/common/meta/typelist.hpp similarity index 98% rename from src/common/typelist.hpp rename to src/common/meta/typelist.hpp index 2f45ae85b..c2d4568d0 100644 --- a/src/common/typelist.hpp +++ b/src/common/meta/typelist.hpp @@ -53,8 +53,8 @@ This code is heavily inspired by */ -#ifndef LUMIERA_TYPELIST_H -#define LUMIERA_TYPELIST_H +#ifndef LUMIERA_META_TYPELIST_H +#define LUMIERA_META_TYPELIST_H diff --git a/src/common/meta/typelistutil.hpp b/src/common/meta/typelistutil.hpp new file mode 100644 index 000000000..3a0d56284 --- /dev/null +++ b/src/common/meta/typelistutil.hpp @@ -0,0 +1,213 @@ +/* + TYPELISTUTIL.hpp - Utils for working with lists-of-types + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + 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 LUMIERA_META_TYPELISTUTIL_H +#define LUMIERA_META_TYPELISTUTIL_H + + + +#include "common/meta/typelist.hpp" + +namespace lumiera { + namespace typelist { + + + /** + * Metafunction counting the number of Types in the collection + */ + template + struct count; + template<> + struct count + { + enum{ value = 0 }; + }; + template + struct count > + { + enum{ value = 1 + count::value }; + }; + + /** + * Metafunction " max( sizeof(T) ) for T in TYPES " + */ + template + struct maxSize; + template<> + struct maxSize + { + enum{ value = 0 }; + }; + template + struct maxSize > + { + enum{ thisval = sizeof(TY) + , nextval = maxSize::value + , value = nextval > thisval? nextval:thisval + }; + }; + + + /** apply a transformation (template) to each type in the list */ + template class _TRANS_> + struct Apply { typedef TY List; }; + + template< class TY, class TYPES + , template class _TRANS_ + > + struct Apply, _TRANS_ > { typedef Node< typename _TRANS_::Type + , typename Apply::List + > List; }; + + + template + struct CondNode { typedef TAIL Next; }; + + template + struct CondNode { typedef Node Next; }; + + /** filter away those types which don't fulfill a predicate metafunction */ + template< class TYPES + , template class _P_ ///< a template providing a boolean member \c ::value + > + struct Filter; + + template class _P_> + struct Filter { typedef NullType List; }; + + template< class TY, class TYPES + , template class _P_ + > + struct Filter,_P_> { typedef typename CondNode< _P_::value + , TY + , typename Filter::List + >::Next + List; }; + + + /** append lists-of-types */ + template + struct Append { typedef Node::List> List; }; + + template< class TY, class TYPES + , class TAIL + > + struct Append, TAIL> { typedef Node::List> List; }; + + template + struct Append > { typedef Node List; }; + + template + struct Append, NullType> { typedef Node List; }; + + template + struct Append { typedef Node List; }; + + template + struct Append { typedef Node List; }; + + template<> + struct Append { typedef NullType List; }; + + + + /** + * prefix each of the elements, + * yielding a list-of lists-of-types + */ + template + struct PrefixAll { typedef Node< typename Append::List, NullType> List; }; + + template + struct PrefixAll { typedef NullType List; }; + + template + struct PrefixAll { typedef Node< typename Append::List, NullType> List; }; + + template< class T + , class TY, class TYPES + > + struct PrefixAll > { typedef Node< typename Append::List + , typename PrefixAll::List + > List; }; + + + + + template + struct Distribute { typedef typename PrefixAll::List List; }; + + template + struct Distribute { typedef NullType List; }; + + template< class TY, class TYPES + , class TAIL + > + struct Distribute,TAIL> { typedef typename Append< typename PrefixAll::List + , typename Distribute::List + >::List + List; }; + + + + /** use a permutation generator + * for creating a list of all possible combinations + */ + template< class X + , template class _PERMU_> + struct Combine { typedef typename Distribute< typename _PERMU_::List + , Node + >::List List; }; + template< template class _PERMU_> + struct Combine { typedef Node List; }; + + template< class TY, class TYPES + , template class _PERMU_> + struct Combine,_PERMU_> { typedef typename Distribute< typename _PERMU_::List + , typename Combine::List + >::List List; }; + + /** permutation generator for the Combine metafunction, + * yielding an "on" and "off" case + */ + template + struct FlagOnOff + { + typedef Node > List; + }; + + + /** generate all possible on-off combinations of the given flags */ + template + struct CombineFlags + { + typedef typename Combine::List List; + }; + + + + + } // namespace typelist + +} // namespace lumiera +#endif diff --git a/src/common/meta/util.hpp b/src/common/meta/util.hpp new file mode 100644 index 000000000..3c2d985f2 --- /dev/null +++ b/src/common/meta/util.hpp @@ -0,0 +1,74 @@ +/* + UTIL.hpp - metaprogramming helpers and utilities + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + 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 LUMIERA_META_UTIL_H +#define LUMIERA_META_UTIL_H + + + +namespace lumiera { + namespace typelist { + + + /* types for figuring out the overload resolution chosen by the compiler */ + + typedef char Yes_t; + struct No_t { char padding[8]; }; + + + /** semi-automatic detection if an instantiation is possible. + * Requires help by the template to be tested, which needs to define + * a typedef member \c is_defined. The embedded metafunction Test can be used + * as a predicate for filtering types which may yield a valid instantiation + * of the candidate template in question. + * \par + * A fully automated solution for this problem is impossible by theoretic reasons. + * Any non trivial use of such a \c is_defined trait would break the "One Definition Rule", + * as the state of any type can change from "partially defined" to "fully defined" over + * the course of any translation unit. Thus, even if there may be a \em solution out there, + * we can expect it to break at some point by improvements/fixes to the C++ Language. + */ + template class _CandidateTemplate_> + struct Instantiation + { + + template + class Test + { + typedef _CandidateTemplate_ Instance; + + template + static Yes_t check(typename U::is_defined *); + template + static No_t check(...); + + public: + static const bool value = (sizeof(Yes_t)==sizeof(check(0))); + }; + }; + + + } // namespace typelist + +} // namespace lumiera +#endif diff --git a/src/common/variant.hpp b/src/common/variant.hpp index 561b7149c..48f813e19 100644 --- a/src/common/variant.hpp +++ b/src/common/variant.hpp @@ -41,7 +41,7 @@ #define LUMIERA_VARIANT_H -#include "common/typelistutil.hpp" +#include "common/meta/generator.hpp" #include diff --git a/src/common/visitor.hpp b/src/common/visitor.hpp index 3d22f11e6..49bbcedb5 100644 --- a/src/common/visitor.hpp +++ b/src/common/visitor.hpp @@ -79,7 +79,7 @@ Credits for many further implementation ideas go to #include "common/visitorpolicies.hpp" #include "common/visitordispatcher.hpp" -#include "common/typelist.hpp" +#include "common/meta/typelist.hpp" namespace lumiera diff --git a/src/common/wrapperptr.hpp b/src/common/wrapperptr.hpp index e17963eff..81afa1177 100644 --- a/src/common/wrapperptr.hpp +++ b/src/common/wrapperptr.hpp @@ -29,7 +29,7 @@ #include "common/variant.hpp" #include "common/accesscasted.hpp" -#include "common/typelist.hpp" +#include "common/meta/typelist.hpp" #include "proc/mobject/placement.hpp" #include "common/p.hpp" diff --git a/src/proc/engine/nodeoperation.hpp b/src/proc/engine/nodeoperation.hpp index 144050d39..40be62c35 100644 --- a/src/proc/engine/nodeoperation.hpp +++ b/src/proc/engine/nodeoperation.hpp @@ -62,7 +62,6 @@ #include "proc/engine/buffhandle.hpp" #include "proc/engine/bufftable.hpp" #include "proc/engine/nodeinvocation.hpp" -#include "proc/engine/nodewiringconfig.hpp" @@ -230,6 +229,18 @@ namespace engine { /* === declare the possible Assembly of these elementary steps === */ + enum Cases + { + CACHING = 1, + PROCESS, + INPLACE, + + NOT_SET = 0, + NUM_Cases = INPLACE + }; + + + template struct SelectBuffProvider; diff --git a/src/proc/engine/nodewiringconfig.hpp b/src/proc/engine/nodewiringconfig.hpp index 9223f5633..fe1a24856 100644 --- a/src/proc/engine/nodewiringconfig.hpp +++ b/src/proc/engine/nodewiringconfig.hpp @@ -19,369 +19,49 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - +/** @file nodewiringconfig.hpp + ** Sometimes we need to coose a different implementation for dealing with + ** some special cases. While for simple cases, just testing a flag or using a + ** switch statement will do the job, matters get more difficult when we have to + ** employ a completely different execution path for each of the different cases, + ** while using a set of common building blocks. + ** \par + ** In the Lumiera render engine, right on the critical path, we need some glue code + ** for invoking the predecessor nodes when pulling a given processing node. The actual + ** sequence is quite dependant on the specific situation each node is wired up, regarding + ** buffer allocation, cache querying and the possible support for GPU processing and + ** render farms. The solution is to define specialisations of a Strategy template + ** using the specific configuration as template argument. Based on these, we can + ** create a collection of factories, which in turn will build the internal wiring + ** for the individual ProcNode instances in accordance to the situation determined + ** for this node, expressed as a set of flags. As a net result, each node has an + ** indivudual configuration (as opposed to creating a lot of hand-written individual + ** ProcNode subclasses), but parts of this configuration assembly is done already at + ** compile time, allowing for additional checks by typing and for possible optimisation. + ** + ** @see proc::engine::config::Strategy + ** @see nodewiring.hpp + ** @see configflags.hpp + ** + */ #ifndef ENGINE_NODEWIRINGCONFIG_H #define ENGINE_NODEWIRINGCONFIG_H #include "common/util.hpp" +#include "common/meta/configflags.hpp" -//#include -#include -#include -#include -#include -#include #include - - /////////////////TODO: library - -#include "common/typelistutil.hpp" -namespace lumiera { - namespace typelist { - - template class _TRANS_> - struct Apply { typedef TY List; }; - - template< class TY, class TYPES - , template class _TRANS_ - > - struct Apply, _TRANS_ > { typedef Node< typename _TRANS_::Type - , typename Apply::List - > List; }; - - - template - struct CondNode { typedef TAIL Next; }; - - template - struct CondNode { typedef Node Next; }; - - - template< class TYPES , template class _P_> - struct Filter; - - template class _P_> - struct Filter { typedef NullType List; }; - - template< class TY, class TYPES - , template class _P_ - > - struct Filter,_P_> { typedef typename CondNode< _P_::value - , TY - , typename Filter::List - >::Next - List; }; - - - - template - struct Append { typedef Node::List> List; }; - - template< class TY, class TYPES - , class TAIL - > - struct Append, TAIL> { typedef Node::List> List; }; - - template - struct Append > { typedef Node List; }; - - template - struct Append, NullType> { typedef Node List; }; - - template - struct Append { typedef Node List; }; - - template - struct Append { typedef Node List; }; - - template<> - struct Append { typedef NullType List; }; - - - - - template - struct PrefixAll { typedef Node< typename Append::List, NullType> List; }; - - template - struct PrefixAll { typedef NullType List; }; - - template - struct PrefixAll { typedef Node< typename Append::List, NullType> List; }; - - template< class T - , class TY, class TYPES - > - struct PrefixAll > { typedef Node< typename Append::List - , typename PrefixAll::List - > List; }; - - - - - template - struct Distribute { typedef typename PrefixAll::List List; }; - - template - struct Distribute { typedef NullType List; }; - - template< class TY, class TYPES - , class TAIL - > - struct Distribute,TAIL> { typedef typename Append< typename PrefixAll::List - , typename Distribute::List - >::List - List; }; - - - - - template< class X - , template class _PERMU_> - struct Combine { typedef typename Distribute< typename _PERMU_::List - , Node - >::List List; }; - template< template class _PERMU_> - struct Combine { typedef Node List; }; - - template< class TY, class TYPES - , template class _PERMU_> - struct Combine,_PERMU_> { typedef typename Distribute< typename _PERMU_::List - , typename Combine::List - >::List List; }; - - - template - struct FlagOnOff - { - typedef Node > List; - }; - - template - struct CombineFlags - { - typedef typename Combine::List List; - }; - - - - /////////// meta utils - - typedef char Yes_t; - struct No_t { char padding[8]; }; - - - /** semi-automatic detection if an instantiation is possible. - * Requires help by the template to be tested, which needs to define - * a typedef member \c is_defined. The embedded metafunction Test can be used - * as a predicate for filtering types which may yield a valid instantiation - * of the candidate template in question. - * \par - * A fully automated solution for this problem is impossible by theoretic reasons. - * Any non trivial use of such a \c is_defined trait would break the "One Definition Rule", - * as the state of any type can change from "partially defined" to "fully defined" over - * the course of any translation unit. Thus, even if there may be a \em solution out there, - * we can expect it to break at some point by improvements/fixes to the C++ Language. - */ - template class _CandidateTemplate_> - struct Instantiation - { - - template - class Test - { - typedef _CandidateTemplate_ Instance; - - template - static Yes_t check(typename U::is_defined *); - template - static No_t check(...); - - public: - static const bool value = (sizeof(Yes_t)==sizeof(check(0))); - }; - }; - - - - - - - template struct Flag { typedef Flag ID; }; - template<> struct Flag<0> { typedef NullType ID; }; - - - template< char f1=0 - , char f2=0 - , char f3=0 - , char f4=0 - , char f5=0 - > - struct Flags - { - typedef typename Types< typename Flag::ID - , typename Flag::ID - , typename Flag::ID - , typename Flag::ID - , typename Flag::ID - >::List - Tuple; - typedef Tuple List; - }; - - - template< char f1=0 - , char f2=0 - , char f3=0 - , char f4=0 - , char f5=0 - > - struct Config - { - typedef typename Flags::Tuple Flags; - typedef Flags List; - }; - - - template - struct ConfigSetFlag; - - template< char Fl - , char f1 - , char f2 - , char f3 - , char f4 - , char IGN - > - struct ConfigSetFlag > - { - typedef Config Config; - }; - - template > - struct DefineConfigByFlags - { - typedef CONF Config; - typedef Config Type; - }; - template - struct DefineConfigByFlags< Node,FLAGS>, CONF> - { - typedef typename ConfigSetFlag< Fl - , typename DefineConfigByFlags::Config - >::Config Config; - typedef Config Type; - }; - - - /** - * Helper for calculating values and for - * invoking runtime code based on a given FlagTuple. - * Can also be used on a Typelist of several Configs. - * The latter case is typically used to invoke an operation - * while ennumerating all Flag-Configurations defined in Code. - * An example would be to build (at runtime) an dispatcher table. - * Explanation: For the Case covering a List of Configs, we provide - * a templated visitaion function, which can accept a functor object - * to be invoked on each Configuration. - */ - template - struct FlagInfo; - - template - struct FlagInfo, FLAGS> > - { - enum{ BITS = MAX(ff, FlagInfo::BITS) - , CODE = (1<::CODE - }; - }; - template<> - struct FlagInfo - { - enum{ BITS = 0 - , CODE = 0 - }; - - template - static typename FUNC::Ret - accept (FUNC& functor) - { - return functor.done(); - } - }; - template - struct FlagInfo > - { - typedef typename CONF::Flags ThisFlags; - enum{ BITS = MAX (char(FlagInfo::BITS), char(FlagInfo::BITS)) - }; - - template - static typename FUNC::Ret - accept (FUNC& functor) - { - functor.template visit(FlagInfo::CODE); - return FlagInfo::accept (functor); - } - }; - - - - - - } // namespace typelist - -} // namespace lumiera - - /////////////////TODO: library(end) - +#include namespace engine { - - class WiringFactory; - - ///////TODO - using lumiera::typelist::Config; using lumiera::typelist::FlagInfo; - using lumiera::typelist::DefineConfigByFlags; - ///////TODO using boost::lexical_cast; using util::contains; - enum Cases - { - CACHING = 1, - PROCESS, - INPLACE, - - NOT_SET = 0, - NUM_Cases = INPLACE - }; - typedef std::bitset Bits; - - - - - /** - * Helper type used to describe the \em situation on which to base - * the selection of the wiring and configuration of a ProcNode. - * It is based on a tuple of elementary parameters (here of type bool); - * a combination of these describes the situation and is used to select - * a strategy, which in turn determines what concret operations to use - * while pulling the node, and how to combine these operations. - * @see engine::Strategy ///TODO namespace.... - */ -// template -// struct Config -// { -// static Bits getRepr () { return getCaseRepresentation(caching,process,inplace); } -// }; - /** * Helper for fabricating ProcNode Wiring configurations. @@ -439,7 +119,7 @@ namespace engine { }; - typedef boost::shared_ptr PFunc; + typedef std::tr1::shared_ptr PFunc; typedef std::map ConfigTable; ConfigTable possibleConfig_; ///< Table of factories diff --git a/src/tool/try.cpp b/src/tool/try.cpp index 7d9d99000..3f51bcaf6 100644 --- a/src/tool/try.cpp +++ b/src/tool/try.cpp @@ -32,7 +32,7 @@ using boost::is_base_of; #include -#include "common/typelistutil.hpp" +#include "common/meta/generator.hpp" using lumiera::typelist::NullType; using lumiera::typelist::Node; using lumiera::typelist::Types; diff --git a/tests/common/typelist/configflagstest.cpp b/tests/common/meta/configflagstest.cpp similarity index 97% rename from tests/common/typelist/configflagstest.cpp rename to tests/common/meta/configflagstest.cpp index 1c9dbdf83..63ac834d9 100644 --- a/tests/common/typelist/configflagstest.cpp +++ b/tests/common/meta/configflagstest.cpp @@ -38,10 +38,10 @@ #include "common/test/run.hpp" -#include "common/typelistutil.hpp" +#include "common/meta/generator.hpp" +#include "common/meta/typelistutil.hpp" +#include "proc/engine/nodewiringconfig.hpp" #include "common/util.hpp" -//#include "common/typelist/typelistmanip.hpp" -#include "proc/engine/nodewiringconfig.hpp" ///////////TODO move to configflags.hpp #include #include @@ -343,6 +343,10 @@ namespace lumiera { }; + /** @test use the ConfigSelector template to build a set of factories, + * based on a set of configurations. Then invoke the apropriate + * factory by specifying the configuration bit code + */ void check_ConfigSelector() { cout << "\n==== check_ConfigSelector()\n"; diff --git a/tests/common/typelist/typelistutiltest.cpp b/tests/common/meta/generatortest.cpp similarity index 94% rename from tests/common/typelist/typelistutiltest.cpp rename to tests/common/meta/generatortest.cpp index 73cab939e..2909b076d 100644 --- a/tests/common/typelist/typelistutiltest.cpp +++ b/tests/common/meta/generatortest.cpp @@ -1,5 +1,5 @@ /* - TypeListUtil(Test) - check the typelist helpers + Generator(Test) - build an interface + implementation directed by a typelis Copyright (C) Lumiera.org 2008, Hermann Vosseler @@ -21,7 +21,7 @@ * *****************************************************/ -/** @file typelistutiltest.cpp +/** @file generatortest.cpp ** \par what are we doing here?? ** ** the following test composes both an interface and the corresponding implementation @@ -31,14 +31,14 @@ ** need to be absolutely fixed in the class definition) ** ** @see typelisttest.cpp - ** @see typelistutil.hpp + ** @see generator.hpp ** @see lumiera::query::ConfigRules a real world usage example ** */ #include "common/test/run.hpp" -#include "common/typelistutil.hpp" +#include "common/meta/generator.hpp" #include #include @@ -118,7 +118,7 @@ namespace lumiera * for a collection of classes * */ - class TypeListUtil_test : public Test + class TypeListGenerator_test : public Test { virtual void run(Arg arg) { @@ -144,7 +144,7 @@ namespace lumiera /** Register this test class... */ - LAUNCHER (TypeListUtil_test, "unit common"); + LAUNCHER (TypeListGenerator_test, "unit common"); diff --git a/tests/common/typelist/typelistmaniptest.cpp b/tests/common/meta/typelistmaniptest.cpp similarity index 98% rename from tests/common/typelist/typelistmaniptest.cpp rename to tests/common/meta/typelistmaniptest.cpp index 7b285d205..9d2321299 100644 --- a/tests/common/typelist/typelistmaniptest.cpp +++ b/tests/common/meta/typelistmaniptest.cpp @@ -39,9 +39,9 @@ #include "common/test/run.hpp" -#include "common/typelistutil.hpp" +#include "common/meta/generator.hpp" +#include "common/meta/typelistutil.hpp" #include "common/util.hpp" -#include "proc/engine/nodewiringconfig.hpp" ///////////TODO move to typelistutil.hpp #include #include diff --git a/tests/common/typelist/typelisttest.cpp b/tests/common/meta/typelisttest.cpp similarity index 98% rename from tests/common/typelist/typelisttest.cpp rename to tests/common/meta/typelisttest.cpp index 42159d96c..5c942b1e0 100644 --- a/tests/common/typelist/typelisttest.cpp +++ b/tests/common/meta/typelisttest.cpp @@ -22,7 +22,7 @@ #include "common/test/run.hpp" -#include "common/typelist.hpp" +#include "common/meta/typelist.hpp" #include