1 #include "fhiclcpp/detail/printing_helpers.h"
5 //==================================================================
6 // e.g. OptionalSequence<int,4> ====> std::array<int,4>
8 template<typename T, std::size_t N>
9 OptionalSequence<T,N>::OptionalSequence(Name&& name)
10 : OptionalSequence{std::move(name), Comment("")}
14 template<typename T, std::size_t N>
15 OptionalSequence<T,N>::OptionalSequence(Name&& name,
17 : SequenceBase{std::move(name), std::move(comment), par_style::OPTIONAL, par_type::SEQ_ARRAY, detail::AlwaysUse()}
18 , RegisterIfTableMember{this}
21 for (std::size_t i{}; i != N; ++i) {
22 value_.at(i) = std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i) );
24 NameStackRegistry::end_of_ctor();
27 template<typename T, std::size_t N>
28 OptionalSequence<T,N>::OptionalSequence(Name&& name,
30 std::function<bool()> maybeUse)
31 : SequenceBase{std::move(name), std::move(comment), par_style::OPTIONAL_CONDITIONAL, par_type::SEQ_ARRAY, maybeUse}
32 , RegisterIfTableMember{this}
35 for (std::size_t i{}; i != N; ++i) {
36 value_.at(i) = std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i) );
38 NameStackRegistry::end_of_ctor();
41 template<typename T, std::size_t N>
43 OptionalSequence<T,N>::do_set_value(fhicl::ParameterSet const&,
44 bool const /*trimParents*/)
46 // We do not explicitly set the sequence values here as the
47 // individual elements are set one at a time. However, this
48 // function is reached in the ValidateThenSet algorithm if the
49 // optional parameter is present. Otherwise, this override is
55 //==================================================================
56 // e.g. OptionalSequence<int> ====> std::vector<int>
60 OptionalSequence<T,-1ull>::OptionalSequence(Name&& name)
61 : OptionalSequence{std::move(name), Comment("")}
65 OptionalSequence<T,-1ull>::OptionalSequence(Name&& name,
67 : SequenceBase{std::move(name), std::move(comment), par_style::OPTIONAL, par_type::SEQ_VECTOR, detail::AlwaysUse()}
68 , RegisterIfTableMember{this}
70 value_.emplace_back(new tt::fhicl_type<T>{Name::sequence_element(0ul)});
71 NameStackRegistry::end_of_ctor();
75 OptionalSequence<T,-1ull>::OptionalSequence(Name&& name,
77 std::function<bool()> maybeUse)
78 : SequenceBase{std::move(name), std::move(comment), par_style::OPTIONAL_CONDITIONAL, par_type::SEQ_VECTOR, maybeUse}
79 , RegisterIfTableMember{this}
81 value_.emplace_back(new tt::fhicl_type<T>{Name::sequence_element(0ul)});
82 NameStackRegistry::end_of_ctor();
87 OptionalSequence<T,-1ull>::do_set_value(fhicl::ParameterSet const&,
88 bool const /*trimParents*/)
90 // We do not explicitly set the sequence values here as the
91 // individual elements are set one at a time. However, this
92 // function is reached in the ValidateThenSet algorithm if the
93 // optional parameter is present. Otherwise, this override is