1 #ifndef fhiclcpp_types_OptionalSequence_h 2 #define fhiclcpp_types_OptionalSequence_h 17 #include <type_traits> 26 template <
typename T, std::size_t N = -1ull>
27 class OptionalSequence final :
public detail::SequenceBase,
28 private detail::RegisterIfTableMember {
35 using ftype = std::array<std::shared_ptr<tt::fhicl_type<T>>, N>;
42 std::function<
bool()> maybeUse);
52 value_, result.begin(), [](
auto const& elem) {
return (*elem)(); });
84 cet::for_all(value_, [&pw](
auto&
e) { pw.
walk_over(*
e); });
91 cet::for_all(value_, [&pw](
auto const&
e) { pw.
walk_over(*
e); });
95 bool const trimParents)
override;
101 template <
typename T>
111 using ftype = std::vector<std::shared_ptr<tt::fhicl_type<T>>>;
118 std::function<
bool()> maybeUse);
128 cet::transform_all(
value_, std::back_inserter(result), [](
auto const&
e) {
132 std::swap(result, t);
143 if (n < value_.size()) {
145 }
else if (n > value_.size()) {
147 std::string key_fragment{
key()};
153 std::string
const& current_stem = nsr.current();
154 std::size_t
const pos =
155 key_fragment.find(current_stem) != std::string::npos ?
156 current_stem.size() + 1ul :
158 key_fragment.replace(0ul, pos,
"");
161 for (
auto i = value_.size(); i !=
n; ++i) {
171 return value_.size();
178 cet::for_all(value_, [&pw](
auto&
e) { pw.
walk_over(*
e); });
185 cet::for_all(value_, [&pw](
auto const&
e) { pw.
walk_over(*
e); });
189 bool const trimParents)
override;
void do_prepare_elements_for_validation(std::size_t const n) override
static NameStackRegistry & instance()
std::array< tt::return_type< Table< T >< art::RootInputFileSequence::Config::SecondaryFile > >,-1ull > value_type
#define NO_DELEGATED_PARAMETERS
void check_nargs_for_bounded_sequences(std::string const &key, std::size_t expected, std::size_t provided)
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_non_const > &pw) override
#define NO_OPTIONAL_TYPES
std::array< std::shared_ptr< tt::fhicl_type< Table< T >< art::RootInputFileSequence::Config::SecondaryFile > >>,-1ull > ftype
void walk_over(tt::maybe_const_t< ParameterBase, C > &)
typename fhicl_type_impl< T >::type fhicl_type
void do_set_value(fhicl::ParameterSet const &, bool const trimParents) override
bool operator()(value_type &t) const
void do_prepare_elements_for_validation(std::size_t const n) override
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_const > &pw) const override
#define NO_NESTED_TABLE_FRAGMENTS
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_non_const > &pw) override
bool operator()(value_type &t) const
static Name sequence_element(std::size_t const i)
std::size_t get_size() const override
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_const > &pw) const override
std::vector< tt::return_type< T >> value_type
typename return_type_impl< ARGS... >::value_type return_type
std::vector< std::shared_ptr< tt::fhicl_type< T >>> ftype
std::string comment() const
std::size_t get_size() const override
OptionalSequence(Name &&name)