Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include "DataStructures/TaggedTuple.hpp"
7 : #include "Parallel/InitializationTag.hpp"
8 : #include "Utilities/TMPL.hpp"
9 : #include "Utilities/TypeTraits.hpp"
10 :
11 : namespace Parallel {
12 : namespace detail {
13 : template <typename Metavariables, templated_initialization_tag Tag,
14 : typename... OptionTags>
15 : typename Tag::type create_initialization_item_from_options(
16 : const tuples::TaggedTuple<OptionTags...>& options) {
17 : return tuples::apply<typename Tag::template option_tags<Metavariables>>(
18 : [](const auto&... option) {
19 : return Tag::template create_from_options<Metavariables>(option...);
20 : },
21 : options);
22 : }
23 :
24 : template <typename Metavariables, untemplated_initialization_tag Tag,
25 : typename... OptionTags>
26 : typename Tag::type create_initialization_item_from_options(
27 : const tuples::TaggedTuple<OptionTags...>& options) {
28 : return tuples::apply<typename Tag::option_tags>(
29 : [](const auto&... option) { return Tag::create_from_options(option...); },
30 : options);
31 : }
32 : } // namespace detail
33 :
34 : /// \ingroup ParallelGroup
35 : /// \brief Given a list of tags and a tagged tuple containing items
36 : /// created from input options, return a tagged tuple of items constructed
37 : /// by calls to create_from_options for each tag in the list.
38 : template <typename Metavariables, initialization_tag... Tags,
39 : typename... OptionTags>
40 1 : tuples::TaggedTuple<Tags...> create_from_options(
41 : const tuples::TaggedTuple<OptionTags...>& options,
42 : tmpl::list<Tags...> /*meta*/) {
43 : return {detail::create_initialization_item_from_options<Metavariables, Tags>(
44 : options)...};
45 : }
46 : } // namespace Parallel
|