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

#include "type_traits.h"

Inheritance diagram for fhicl::Tuple< T >:
fhicl::detail::SequenceBase fhicl::detail::RegisterIfTableMember fhicl::detail::ParameterBase

Public Types

using default_type = tuple_detail::ValueHolder< typename tt::fhicl_type< T >::default_type... >
 
using value_type = std::tuple< tt::return_type< T >... >
 
using ftype = std::tuple< std::shared_ptr< tt::fhicl_type< T >>... >
 

Public Member Functions

 Tuple (Name &&name)
 
 Tuple (Name &&name, Comment &&comment)
 
 Tuple (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
 Tuple (Name &&name, default_type const &defaults)
 
 Tuple (Name &&name, Comment &&comment, default_type const &defaults)
 
 Tuple (Name &&name, Comment &&comment, std::function< bool()> maybeUse, default_type const &defaults)
 
auto operator() () const
 
template<std::size_t I>
auto get () 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 Types

using PW_non_const = detail::ParameterWalker< tt::const_flavor::require_non_const >
 
using PW_const = detail::ParameterWalker< tt::const_flavor::require_const >
 

Private Member Functions

std::size_t get_size () const noexcept override
 
void do_set_value (ParameterSet const &) override
 
template<std::size_t... I>
void iterate_over_tuple (PW_non_const &pw, std::index_sequence< I... >)
 
void do_prepare_elements_for_validation (std::size_t const n) override
 
void do_walk_elements (PW_non_const &pw) override
 
template<std::size_t... I>
void iterate_over_tuple (PW_const &pw, std::index_sequence< I... >) const
 
void do_walk_elements (PW_const &pw) const override
 
template<std::size_t I>
void finalize_element ()
 
template<std::size_t... I>
void finalize_elements (std::index_sequence< I... >)
 
template<size_t I>
void fill_tuple_element (default_type const &defaults)
 
template<std::size_t... I>
void fill_tuple_elements (default_type const &default_values, std::index_sequence< I... >)
 
template<std::size_t... I>
value_type get_rtype_result (std::index_sequence< I... >) const
 

Private Attributes

ftype value_
 

Detailed Description

template<typename... T>
class fhicl::Tuple< T >

Definition at line 38 of file type_traits.h.

Member Typedef Documentation

template<typename... T>
using fhicl::Tuple< T >::default_type = tuple_detail::ValueHolder<typename tt::fhicl_type<T>::default_type...>

Definition at line 60 of file Tuple.h.

template<typename... T>
using fhicl::Tuple< T >::ftype = std::tuple<std::shared_ptr<tt::fhicl_type<T>>...>

Definition at line 62 of file Tuple.h.

template<typename... T>
using fhicl::Tuple< T >::PW_const = detail::ParameterWalker<tt::const_flavor::require_const>
private

Definition at line 116 of file Tuple.h.

Definition at line 115 of file Tuple.h.

template<typename... T>
using fhicl::Tuple< T >::value_type = std::tuple<tt::return_type<T>...>

Definition at line 61 of file Tuple.h.

Constructor & Destructor Documentation

template<typename... T>
fhicl::Tuple< T >::Tuple ( Name &&  name)
explicit

Definition at line 201 of file Tuple.h.

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

201  : Tuple{std::move(name), Comment("")}
202  {}
std::string const & name() const
Tuple(Name &&name)
Definition: Tuple.h:201
template<typename... T>
fhicl::Tuple< T >::Tuple ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 205 of file Tuple.h.

References fhicl::detail::AlwaysUse(), fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::Tuple< T >::finalize_elements(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::REQUIRED, and fhicl::TUPLE.

206  : SequenceBase{std::move(name),
207  std::move(comment),
211  , RegisterIfTableMember{this}
212  {
213  finalize_elements(std::index_sequence_for<T...>{});
215  }
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
void finalize_elements(std::index_sequence< I... >)
Definition: Tuple.h:163
std::string const & comment() const
template<typename... T>
fhicl::Tuple< T >::Tuple ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 218 of file Tuple.h.

References fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::Tuple< T >::finalize_elements(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::REQUIRED_CONDITIONAL, and fhicl::TUPLE.

221  : SequenceBase{std::move(name),
222  std::move(comment),
225  maybeUse}
226  , RegisterIfTableMember{this}
227  {
228  finalize_elements(std::index_sequence_for<T...>{});
230  }
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
void finalize_elements(std::index_sequence< I... >)
Definition: Tuple.h:163
std::string const & comment() const
template<typename... T>
fhicl::Tuple< T >::Tuple ( Name &&  name,
default_type const &  defaults 
)
explicit

Definition at line 235 of file Tuple.h.

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

236  : Tuple{std::move(name), Comment(""), defaults}
237  {}
std::string const & name() const
Tuple(Name &&name)
Definition: Tuple.h:201
template<typename... T>
fhicl::Tuple< T >::Tuple ( Name &&  name,
Comment &&  comment,
default_type const &  defaults 
)
explicit

Definition at line 240 of file Tuple.h.

References fhicl::detail::AlwaysUse(), fhicl::detail::ParameterBase::comment(), fhicl::DEFAULT, fhicl::NameStackRegistry::end_of_ctor(), fhicl::Tuple< T >::fill_tuple_elements(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::TUPLE.

243  : SequenceBase{std::move(name),
244  std::move(comment),
248  , RegisterIfTableMember{this}
249  {
250  fill_tuple_elements(defaults, std::index_sequence_for<T...>());
252  }
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
void fill_tuple_elements(default_type const &default_values, std::index_sequence< I... >)
Definition: Tuple.h:181
std::string const & comment() const
template<typename... T>
fhicl::Tuple< T >::Tuple ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse,
default_type const &  defaults 
)
explicit

Definition at line 255 of file Tuple.h.

References fhicl::detail::ParameterBase::comment(), fhicl::DEFAULT_CONDITIONAL, fhicl::NameStackRegistry::end_of_ctor(), fhicl::Tuple< T >::fill_tuple_elements(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::TUPLE.

259  : SequenceBase{std::move(name),
260  std::move(comment),
263  maybeUse}
264  , RegisterIfTableMember{this}
265  {
266  fill_tuple_elements(defaults, std::index_sequence_for<T...>());
268  }
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
void fill_tuple_elements(default_type const &default_values, std::index_sequence< I... >)
Definition: Tuple.h:181
std::string const & comment() const

Member Function Documentation

template<typename... T>
void fhicl::Tuple< T >::do_prepare_elements_for_validation ( std::size_t const  n)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 126 of file Tuple.h.

References fhicl::detail::check_nargs_for_bounded_sequences().

127  {
129  }
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
std::size_t get_size() const noexcept override
Definition: Tuple.h:103
Char_t n[5]
template<typename... T>
void fhicl::Tuple< T >::do_set_value ( ParameterSet const &  )
inlineoverrideprivatevirtual

Implements fhicl::detail::ParameterBase.

Definition at line 109 of file Tuple.h.

110  {}
template<typename... T>
void fhicl::Tuple< T >::do_walk_elements ( PW_non_const pw)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 132 of file Tuple.h.

133  {
134  iterate_over_tuple(pw, std::index_sequence_for<T...>{});
135  }
void iterate_over_tuple(PW_non_const &pw, std::index_sequence< I... >)
Definition: Tuple.h:120
template<typename... T>
void fhicl::Tuple< T >::do_walk_elements ( PW_const pw) const
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 145 of file Tuple.h.

146  {
147  iterate_over_tuple(pw, std::index_sequence_for<T...>{});
148  }
void iterate_over_tuple(PW_non_const &pw, std::index_sequence< I... >)
Definition: Tuple.h:120
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>
template<size_t I>
void fhicl::Tuple< T >::fill_tuple_element ( default_type const &  defaults)
inlineprivate

Definition at line 172 of file Tuple.h.

References fhicl::Name::sequence_element().

173  {
174  using elem_ftype = typename std::tuple_element_t<I, ftype>::element_type;
175  std::get<I>(value_) = std::make_shared<elem_ftype>(
176  Name::sequence_element(I), defaults.template get<I>());
177  }
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
ftype value_
Definition: Tuple.h:100
template<typename... T>
template<std::size_t... I>
void fhicl::Tuple< T >::fill_tuple_elements ( default_type const &  default_values,
std::index_sequence< I... >   
)
inlineprivate

Definition at line 181 of file Tuple.h.

Referenced by fhicl::Tuple< T >::Tuple().

183  {
184  (fill_tuple_element<I>(default_values), ...);
185  }
template<typename... T>
template<std::size_t I>
void fhicl::Tuple< T >::finalize_element ( )
inlineprivate

Definition at line 154 of file Tuple.h.

References fhicl::Name::sequence_element().

155  {
156  using elem_ftype = typename std::tuple_element_t<I, ftype>::element_type;
157  std::get<I>(value_) =
158  std::make_shared<elem_ftype>(Name::sequence_element(I));
159  }
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
ftype value_
Definition: Tuple.h:100
template<typename... T>
template<std::size_t... I>
void fhicl::Tuple< T >::finalize_elements ( std::index_sequence< I... >  )
inlineprivate

Definition at line 163 of file Tuple.h.

Referenced by fhicl::Tuple< T >::Tuple().

164  {
165  (finalize_element<I>(), ...);
166  }
template<typename... T>
template<std::size_t I>
auto fhicl::Tuple< T >::get ( ) const
inline

Definition at line 94 of file Tuple.h.

95  {
96  return (*std::get<I>(value_))();
97  }
ftype value_
Definition: Tuple.h:100
template<typename... T>
template<std::size_t... I>
value_type fhicl::Tuple< T >::get_rtype_result ( std::index_sequence< I... >  ) const
inlineprivate

Definition at line 191 of file Tuple.h.

Referenced by fhicl::Tuple< T >::operator()().

192  {
193  return value_type{(*std::get<I>(value_))()...};
194  }
std::tuple< tt::return_type< T >... > value_type
Definition: Tuple.h:61
ftype value_
Definition: Tuple.h:100
template<typename... T>
std::size_t fhicl::Tuple< T >::get_size ( ) const
inlineoverrideprivatevirtualnoexcept

Implements fhicl::detail::SequenceBase.

Definition at line 103 of file Tuple.h.

104  {
105  return std::tuple_size<ftype>();
106  }
bool fhicl::detail::ParameterBase::is_conditional ( ) const
inherited
template<typename... T>
template<std::size_t... I>
void fhicl::Tuple< T >::iterate_over_tuple ( PW_non_const pw,
std::index_sequence< I... >   
)
inlineprivate

Definition at line 120 of file Tuple.h.

References fhicl::detail::ParameterWalker< C >::walk_over().

121  {
122  (pw.walk_over(*std::get<I>(value_)), ...);
123  }
ftype value_
Definition: Tuple.h:100
template<typename... T>
template<std::size_t... I>
void fhicl::Tuple< T >::iterate_over_tuple ( PW_const pw,
std::index_sequence< I... >   
) const
inlineprivate

Definition at line 139 of file Tuple.h.

References fhicl::detail::ParameterWalker< C >::walk_over().

140  {
141  (pw.walk_over(*std::get<I>(value_)), ...);
142  }
ftype value_
Definition: Tuple.h:100
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>
auto fhicl::Tuple< T >::operator() ( ) const

Definition at line 272 of file Tuple.h.

References fhicl::Tuple< T >::get_rtype_result().

273  {
274  return get_rtype_result(std::index_sequence_for<T...>());
275  }
value_type get_rtype_result(std::index_sequence< I... >) const
Definition: Tuple.h:191
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>
ftype fhicl::Tuple< T >::value_
private

Definition at line 100 of file Tuple.h.


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