Derecho  0.9
Distributed systems toolkit for RDMA
make_kind_map.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include "derecho_internal.hpp"
12 #include <mutils-containers/KindMap.hpp>
13 
14 namespace derecho {
15 
16 template <typename MapType>
17 void kind_map_builder(MapType&){};
18 
26 template <typename MapType, typename FirstType, typename... RestTypes>
27 void kind_map_builder(MapType& map, Factory<FirstType> curr_factory,
28  Factory<RestTypes>... rest_factories) {
29  map.template get<FirstType>() = std::move(curr_factory);
30  kind_map_builder<MapType, RestTypes...>(map, rest_factories...);
31 }
32 
42 template <typename... Types>
43 mutils::KindMap<Factory, Types...> make_kind_map(Factory<Types>... factories) {
44  mutils::KindMap<Factory, Types...> factories_map;
45  kind_map_builder<decltype(factories_map), Types...>(factories_map, factories...);
46  return factories_map;
47 }
48 
49 } // namespace derecho
mutils::KindMap< Factory, Types... > make_kind_map(Factory< Types >... factories)
Constructs a KindMap<Factory, Types...> from a list of factories of those types.
std::function< std::unique_ptr< T >(persistent::PersistentRegistry *)> Factory
The type of factory function the user must provide to the Group constructor, to construct each Replic...
void kind_map_builder(MapType &)