3 #ifndef DUNE_ISTL_COMMON_REGISTRY_HH 4 #define DUNE_ISTL_COMMON_REGISTRY_HH 14 #include <dune/common/typelist.hh> 15 #include <dune/common/hybridutilities.hh> 16 #include <dune/common/parameterizedobject.hh> 18 #define DUNE_REGISTRY_PUT(Tag, id, ...) \ 21 struct Registry<Tag, DUNE_GET_COUNTER(Tag)> \ 23 static auto getCreator() \ 27 static std::string name() { return id; } \ 35 template<
class Tag, std::
size_t index>
40 template<
template<
class>
class Base,
class V,
class Tag,
typename... Args>
41 auto registryGet(Tag , std::string name, Args... args)
44 std::shared_ptr<Base<V> > result;
45 Dune::Hybrid::forEach(std::make_index_sequence<count>{},
47 using Reg = Registry<Tag, index>;
48 if(!result && Reg::name() == name) {
49 result = Reg::getCreator()(Dune::MetaType<V>{}, args...);
60 template<
class V,
class Type,
class Tag,
class... Args>
61 int addRegistryToFactory(Dune::ParameterizedObjectFactory<Type(Args...), std::string>& factory,
64 Dune::Hybrid::forEach(std::make_index_sequence<count>{},
69 using Reg = Registry<Tag, index>;
70 auto genericcreator = Reg::getCreator();
71 factory.define(Reg::name(), [genericcreator](Args... args){
72 return genericcreator(V{}, args...);
80 #endif // DUNE_ISTL_COMMON_REGISTRY_HH
#define DUNE_GET_COUNTER(Tag)
Definition: counter.hh:17
Definition: allocator.hh:11