RegisterDerivedClassesWithCharm.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Functions for serializing factory-created classes
6 
7 #pragma once
8 
9 #include <typeinfo>
10 
13 #include "Utilities/TMPL.hpp"
14 
15 namespace Parallel {
16 namespace register_derived_classes_with_charm_detail {
17 template <typename Type>
18 SPECTRE_ALWAYS_INLINE void make_type_pupable() noexcept {
19  // This assumes typeid(Type).name() is different for each registered
20  // type. If we don't trust that we can add a counter or something.
21  PUPable_reg2(Type, typeid(Type).name())
22 }
23 
24 template <typename... Types>
25 SPECTRE_ALWAYS_INLINE void make_list_pupable(
26  const tmpl::list<Types...> /*meta*/) noexcept {
27  expand_pack((make_type_pupable<Types>(), 0)...);
28 }
29 } // namespace register_derived_classes_with_charm_detail
30 
31 template <typename Base>
32 SPECTRE_ALWAYS_INLINE void register_derived_classes_with_charm() noexcept {
33  register_derived_classes_with_charm_detail::make_list_pupable(
34  typename Base::creatable_classes{});
35 }
36 } // namespace Parallel
Defines macros to allow serialization of abstract template base classes.
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
#define SPECTRE_ALWAYS_INLINE
Always inline a function. Only use this if you benchmarked the code.
Definition: ForceInline.hpp:20
Defines macro to always inline a function.
Wraps the template metaprogramming library used (brigand)
constexpr void expand_pack(Ts &&...) noexcept
Allows zero-cost unordered expansion of a parameter.
Definition: TMPL.hpp:545