LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
fhicl::Sequence< T, N > Class Template Reference

#include "type_traits.h"

Inheritance diagram for fhicl::Sequence< T, N >:
fhicl::detail::SequenceBase fhicl::detail::RegisterIfTableMember fhicl::detail::ParameterBase

Public Types

using default_type = sequence_detail::ValueHolder< typename tt::fhicl_type< T >::default_type >
 
using ftype = std::array< std::shared_ptr< tt::fhicl_type< T >>, N >
 
using value_type = std::array< tt::return_type< T >, N >
 

Public Member Functions

 Sequence (Name &&name)
 
 Sequence (Name &&name, Comment &&comment)
 
 Sequence (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
 Sequence (Name &&name, default_type const &defaults)
 
 Sequence (Name &&name, Comment &&comment, default_type const &defaults)
 
 Sequence (Name &&name, Comment &&comment, std::function< bool()> maybeUse, default_type const &defaults)
 
auto operator() () const
 
auto operator() (std::size_t const i) const
 
bool empty () const noexcept
 
std::size_t size () const noexcept
 
void prepare_elements_for_validation (std::size_t const n)
 
void walk_elements (ParameterWalker< tt::const_flavor::require_non_const > &pw)
 
void walk_elements (ParameterWalker< tt::const_flavor::require_const > &pw) const
 
std::string const & key () const
 
std::string const & name () const
 
std::string const & comment () const
 
bool has_default () const
 
bool is_optional () const
 
bool is_conditional () const
 
par_type parameter_type () const
 
bool should_use () const
 
void set_value (fhicl::ParameterSet const &ps)
 
bool preset_value (fhicl::ParameterSet const &ps)
 
void set_par_style (par_style const vt)
 

Private Member Functions

std::size_t get_size () const noexcept override
 
void do_prepare_elements_for_validation (std::size_t const n) override
 
void do_walk_elements (detail::ParameterWalker< tt::const_flavor::require_non_const > &pw) override
 
void do_walk_elements (detail::ParameterWalker< tt::const_flavor::require_const > &pw) const override
 
bool do_preset_value (fhicl::ParameterSet const &ps) override
 
void do_set_value (fhicl::ParameterSet const &) override
 

Private Attributes

std::variant< ftype, value_typevalue_
 

Detailed Description

template<typename T, std::size_t N = -1ull>
class fhicl::Sequence< T, N >

Definition at line 43 of file type_traits.h.

Member Typedef Documentation

template<typename T, std::size_t N = -1ull>
using fhicl::Sequence< T, N >::default_type = sequence_detail::ValueHolder<typename tt::fhicl_type<T>::default_type>

Definition at line 83 of file Sequence.h.

template<typename T, std::size_t N = -1ull>
using fhicl::Sequence< T, N >::ftype = std::array<std::shared_ptr<tt::fhicl_type<T>>, N>

Definition at line 84 of file Sequence.h.

template<typename T, std::size_t N = -1ull>
using fhicl::Sequence< T, N >::value_type = std::array<tt::return_type<T>, N>

Definition at line 85 of file Sequence.h.

Constructor & Destructor Documentation

template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name)
explicit

Definition at line 326 of file Sequence.h.

References fhicl::detail::ParameterBase::name().

326  : Sequence{std::move(name), Comment("")}
327  {}
std::string const & name() const
Sequence(Name &&name)
Definition: Sequence.h:326
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 330 of file Sequence.h.

References fhicl::detail::AlwaysUse(), fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::REQUIRED, fhicl::SEQ_ARRAY, fhicl::Name::sequence_element(), value, and fhicl::Sequence< T, N >::value_.

331  : SequenceBase{std::move(name),
332  std::move(comment),
336  , RegisterIfTableMember{this}
337  , value_{ftype{nullptr}}
338  {
339  auto& value = std::get<ftype>(value_);
340  for (std::size_t i{}; i != N; ++i) {
341  value.at(i) =
342  std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i));
343  }
345  }
std::function< bool()> AlwaysUse()
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
std::string const & name() const
double value
Definition: spectrum.C:18
std::array< std::shared_ptr< tt::fhicl_type< T >>, N > ftype
Definition: Sequence.h:84
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
std::string const & comment() const
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 348 of file Sequence.h.

References fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::REQUIRED_CONDITIONAL, fhicl::SEQ_ARRAY, fhicl::Name::sequence_element(), value, and fhicl::Sequence< T, N >::value_.

351  : SequenceBase{std::move(name),
352  std::move(comment),
355  maybeUse}
356  , RegisterIfTableMember{this}
357  , value_{ftype{nullptr}}
358  {
359  auto& value = std::get<ftype>(value_);
360  for (std::size_t i{}; i != N; ++i) {
361  value.at(i) =
362  std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i));
363  }
365  }
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
std::string const & name() const
double value
Definition: spectrum.C:18
std::array< std::shared_ptr< tt::fhicl_type< T >>, N > ftype
Definition: Sequence.h:84
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
std::string const & comment() const
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
default_type const &  defaults 
)
explicit

Definition at line 369 of file Sequence.h.

References fhicl::detail::ParameterBase::name().

370  : Sequence{std::move(name), Comment{""}, defaults}
371  {}
std::string const & name() const
Sequence(Name &&name)
Definition: Sequence.h:326
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
Comment &&  comment,
default_type const &  defaults 
)
explicit

Definition at line 374 of file Sequence.h.

References fhicl::detail::AlwaysUse(), fhicl::detail::ParameterBase::comment(), fhicl::DEFAULT, fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::SEQ_ARRAY, fhicl::Name::sequence_element(), value, and fhicl::Sequence< T, N >::value_.

377  : SequenceBase{std::move(name),
378  std::move(comment),
382  , RegisterIfTableMember{this}
383  , value_{ftype{nullptr}}
384  {
385  std::size_t i{};
386  auto& value = std::get<ftype>(value_);
387  for (auto const& arg : defaults) {
388  value.at(i) =
389  std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i), arg);
390  ++i;
391  }
393  }
std::function< bool()> AlwaysUse()
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
std::string const & name() const
double value
Definition: spectrum.C:18
std::array< std::shared_ptr< tt::fhicl_type< T >>, N > ftype
Definition: Sequence.h:84
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
std::string const & comment() const
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse,
default_type const &  defaults 
)
explicit

Definition at line 396 of file Sequence.h.

References fhicl::detail::ParameterBase::comment(), fhicl::DEFAULT_CONDITIONAL, fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::SEQ_ARRAY, fhicl::Name::sequence_element(), value, and fhicl::Sequence< T, N >::value_.

400  : SequenceBase{std::move(name),
401  std::move(comment),
404  maybeUse}
405  , RegisterIfTableMember{this}
406  , value_{ftype{nullptr}}
407  {
408  std::size_t i{};
409  auto& value = std::get<ftype>(value_);
410  for (auto const& arg : defaults) {
411  value.at(i) =
412  std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i), arg);
413  ++i;
414  }
416  }
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
std::string const & name() const
double value
Definition: spectrum.C:18
std::array< std::shared_ptr< tt::fhicl_type< T >>, N > ftype
Definition: Sequence.h:84
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
std::string const & comment() const
std::variant< ftype, value_type > value_
Definition: Sequence.h:126

Member Function Documentation

template<typename T, std::size_t N = -1ull>
void fhicl::Sequence< T, N >::do_prepare_elements_for_validation ( std::size_t const  n)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 138 of file Sequence.h.

139  {
141  }
void check_nargs_for_bounded_sequences(std::string const &key, std::size_t expected, std::size_t provided)
std::string const & key() const
Definition: ParameterBase.cc:6
Char_t n[5]
std::size_t get_size() const noexcept override
Definition: Sequence.h:129
template<typename T, std::size_t N = -1ull>
bool fhicl::Sequence< T, N >::do_preset_value ( fhicl::ParameterSet const &  ps)
inlineoverrideprivatevirtual

Reimplemented from fhicl::detail::ParameterBase.

Definition at line 162 of file Sequence.h.

163  {
164  if constexpr (std::is_same_v<tt::fhicl_type<T>, Atom<T>>) {
165  auto const trimmed_key = detail::strip_first_containing_name(key());
166  value_ = ps.get<value_type>(trimmed_key);
167  return true;
168  }
169  return false;
170  }
std::array< tt::return_type< T >, N > value_type
Definition: Sequence.h:85
std::string strip_first_containing_name(std::string const &key)
typename fhicl_type_impl< T >::type fhicl_type
Definition: type_traits.h:315
std::string const & key() const
Definition: ParameterBase.cc:6
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T, std::size_t N = -1ull>
void fhicl::Sequence< T, N >::do_set_value ( fhicl::ParameterSet const &  )
inlineoverrideprivatevirtual

Implements fhicl::detail::ParameterBase.

Definition at line 173 of file Sequence.h.

174  {}
template<typename T, std::size_t N = -1ull>
void fhicl::Sequence< T, N >::do_walk_elements ( detail::ParameterWalker< tt::const_flavor::require_non_const > &  pw)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 144 of file Sequence.h.

146  {
147  // We only enter here if we do not have a preset value.
148  cet::for_all(std::get<ftype>(value_),
149  [&pw](auto& e) { pw.walk_over(*e); });
150  }
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
Float_t e
Definition: plot.C:35
template<typename T, std::size_t N = -1ull>
void fhicl::Sequence< T, N >::do_walk_elements ( detail::ParameterWalker< tt::const_flavor::require_const > &  pw) const
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 153 of file Sequence.h.

155  {
156  // We only enter here if we do not have a preset value.
157  cet::for_all(std::get<ftype>(value_),
158  [&pw](auto const& e) { pw.walk_over(*e); });
159  }
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
Float_t e
Definition: plot.C:35
bool fhicl::detail::SequenceBase::empty ( ) const
inlinenoexceptinherited

Definition at line 28 of file SequenceBase.h.

References fhicl::detail::SequenceBase::size().

Referenced by fhicl::detail::PrintAllowedConfiguration::enter_sequence().

29  {
30  return size() == 0;
31  }
std::size_t size() const noexcept
Definition: SequenceBase.h:33
template<typename T, std::size_t N = -1ull>
std::size_t fhicl::Sequence< T, N >::get_size ( ) const
inlineoverrideprivatevirtualnoexcept

Implements fhicl::detail::SequenceBase.

Definition at line 129 of file Sequence.h.

130  {
131  if (auto value = std::get_if<value_type>(&value_)) {
132  return value->size();
133  }
134  return std::get<ftype>(value_).size();
135  }
std::size_t size() const noexcept
Definition: SequenceBase.h:33
double value
Definition: spectrum.C:18
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
bool fhicl::detail::ParameterBase::is_conditional ( ) const
inherited
std::string const & fhicl::detail::ParameterBase::key ( ) const
inherited

Definition at line 6 of file ParameterBase.cc.

References fhicl::detail::ParameterMetadata::key(), and fhicl::detail::ParameterBase::mdata_.

Referenced by fhicl::detail::PrintAllowedConfiguration::after_action(), fhicl::detail::ValidateThenSet::before_action(), fhicl::detail::PrintAllowedConfiguration::before_action(), fhicl::detail::SearchAllowedConfiguration::before_action(), fhicl::detail::PrintAllowedConfiguration::cacheTopLevelParameter(), detinfo::LArPropertiesStandard::Configure(), fhicl::OptionalTuple< ARGS... >::do_prepare_elements_for_validation(), fhicl::OptionalSequence< art::InputTag >::do_prepare_elements_for_validation(), fhicl::OptionalSequence< T,-1ull >::do_prepare_elements_for_validation(), fhicl::OptionalSequence< T, N >::do_preset_value(), fhicl::OptionalSequence< T,-1ull >::do_preset_value(), fhicl::Atom< T >::do_set_value(), fhicl::OptionalAtom< T >::do_set_value(), fhicl::detail::ValidateThenSet::enter_sequence(), fhicl::detail::PrintAllowedConfiguration::enter_sequence(), fhicl::detail::SearchAllowedConfiguration::form_absolute(), fhicl::DelegatedParameter::get(), fhicl::OptionalDelegatedParameter::get_if_present(), fhicl::OptionalDelegatedParameter::hasValue(), fhicl::detail::MaybeDisplayParent::is_sequence_element(), fhicl::detail::TableBase::maybe_select_pset(), fhicl::detail::PrintAllowedConfiguration::maybeReleaseTopLevelParameter(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::detail::TableBase::select_pset(), and fhicl::detail::PrintAllowedConfiguration::suppressFormat().

7  {
8  return mdata_.key();
9  }
ParameterMetadata mdata_
Definition: ParameterBase.h:63
std::string const & key() const
template<typename T, std::size_t N = -1ull>
auto fhicl::Sequence< T, N >::operator() ( ) const
inline

Definition at line 104 of file Sequence.h.

105  {
106  if (auto value = std::get_if<value_type>(&value_)) {
107  return *value;
108  }
109  value_type result = {{tt::return_type<T>()}};
110  cet::transform_all(std::get<ftype>(value_),
111  result.begin(),
112  [](auto const& elem) { return (*elem)(); });
113  return result;
114  }
std::array< tt::return_type< T >, N > value_type
Definition: Sequence.h:85
double value
Definition: spectrum.C:18
typename return_type_impl< ARGS... >::value_type return_type
Definition: type_traits.h:357
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T, std::size_t N = -1ull>
auto fhicl::Sequence< T, N >::operator() ( std::size_t const  i) const
inline

Definition at line 117 of file Sequence.h.

118  {
119  if (auto value = std::get_if<value_type>(&value_)) {
120  return value->at(i);
121  }
122  return (*std::get<ftype>(value_).at(i))();
123  }
double value
Definition: spectrum.C:18
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
void fhicl::detail::SequenceBase::prepare_elements_for_validation ( std::size_t const  n)
inlineinherited

Definition at line 39 of file SequenceBase.h.

References fhicl::detail::SequenceBase::do_prepare_elements_for_validation().

Referenced by fhicl::detail::ValidateThenSet::enter_sequence().

40  {
42  }
virtual void do_prepare_elements_for_validation(std::size_t)=0
Char_t n[5]
bool fhicl::detail::ParameterBase::preset_value ( fhicl::ParameterSet const &  ps)
inherited

Definition at line 63 of file ParameterBase.cc.

References fhicl::detail::ParameterBase::do_preset_value().

Referenced by fhicl::detail::ValidateThenSet::before_action().

64  {
65  return do_preset_value(ps);
66  }
virtual bool do_preset_value(fhicl::ParameterSet const &)
void fhicl::detail::ParameterBase::set_par_style ( par_style const  vt)
inherited
void fhicl::detail::ParameterBase::set_value ( fhicl::ParameterSet const &  ps)
inherited

Definition at line 58 of file ParameterBase.cc.

References fhicl::detail::ParameterBase::do_set_value().

Referenced by fhicl::detail::ValidateThenSet::after_action().

59  {
60  do_set_value(ps);
61  }
virtual void do_set_value(fhicl::ParameterSet const &)=0
bool fhicl::detail::ParameterBase::should_use ( ) const
inherited

Definition at line 41 of file ParameterBase.cc.

References fhicl::detail::ParameterBase::maybeUse_.

Referenced by fhicl::detail::ValidateThenSet::before_action().

42  {
43  return maybeUse_();
44  }
std::function< bool()> maybeUse_
Definition: ParameterBase.h:64
std::size_t fhicl::detail::SequenceBase::size ( void  ) const
inlinenoexceptinherited
void fhicl::detail::SequenceBase::walk_elements ( ParameterWalker< tt::const_flavor::require_non_const > &  pw)
inlineinherited

Definition at line 44 of file SequenceBase.h.

References fhicl::detail::SequenceBase::do_walk_elements().

45  {
46  do_walk_elements(pw);
47  }
virtual void do_walk_elements(ParameterWalker< tt::const_flavor::require_non_const > &)=0
void fhicl::detail::SequenceBase::walk_elements ( ParameterWalker< tt::const_flavor::require_const > &  pw) const
inlineinherited

Definition at line 49 of file SequenceBase.h.

References fhicl::detail::SequenceBase::do_prepare_elements_for_validation(), fhicl::detail::SequenceBase::do_walk_elements(), and fhicl::detail::SequenceBase::get_size().

50  {
51  do_walk_elements(pw);
52  }
virtual void do_walk_elements(ParameterWalker< tt::const_flavor::require_non_const > &)=0

Member Data Documentation

template<typename T, std::size_t N = -1ull>
std::variant<ftype, value_type> fhicl::Sequence< T, N >::value_
private

The documentation for this class was generated from the following files: