1 #ifndef DUNE_ISTL_COMMON_REGISTRY_HH
2 #define DUNE_ISTL_COMMON_REGISTRY_HH
12 #include <dune/common/typelist.hh>
13 #include <dune/common/hybridutilities.hh>
14 #include <dune/common/parameterizedobject.hh>
16 #define registry_put(Tag, id, ...) \
19 struct Registry<Tag, DUNE_GET_COUNTER(Tag)> \
21 static auto getCreator() \
25 static std::string name() { return id; } \
33 template<
class Tag, std::
size_t index>
38 template<
template<
class>
class Base,
class V,
class Tag,
typename... Args>
39 auto registry_get(Tag , std::string name, Args... args)
42 std::shared_ptr<Base<V> > result;
43 Dune::Hybrid::forEach(std::make_index_sequence<count>{},
45 using Reg = Registry<Tag, index>;
46 if(!result && Reg::name() == name) {
47 result = Reg::getCreator()(Dune::MetaType<V>{}, args...);
58 template<
class V,
class Type,
class Tag,
class... Args>
59 int addRegistryToFactory(Dune::ParameterizedObjectFactory<Type(Args...), std::string>& factory,
62 Dune::Hybrid::forEach(std::make_index_sequence<count>{},
67 using Reg = Registry<Tag, index>;
68 auto genericcreator = Reg::getCreator();
69 factory.define(Reg::name(), [genericcreator](Args... args){
70 return genericcreator(V{}, args...);
78 #endif // DUNE_ISTL_COMMON_REGISTRY_HH