Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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
 
- Public Member Functions inherited from fhicl::detail::SequenceBase
 SequenceBase (Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
 
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
 
- Public Member Functions inherited from fhicl::detail::ParameterBase
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
 
 ParameterBase (Name const &name, Comment const &comment, par_style const vt, par_type const type, std::function< bool()> maybeUse=AlwaysUse())
 
virtual ~ParameterBase ()=default
 
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 Member Functions inherited from fhicl::detail::RegisterIfTableMember
 RegisterIfTableMember (ParameterBase *pb)
 

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.

201  : Tuple{std::move(name), Comment("")}
202  {}
std::string const & name() const
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
#define Comment
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.

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

Definition at line 218 of file Tuple.h.

225  maybeUse}
226  , RegisterIfTableMember{this}
227  {
228  finalize_elements(std::index_sequence_for<T...>{});
230  }
std::string const & name() const
Definition: ParameterBase.h:43
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
def move(depos, offset)
Definition: depos.py:107
void finalize_elements(std::index_sequence< I... >)
Definition: Tuple.h:163
std::string const & comment() const
Definition: ParameterBase.h:48
template<typename... T>
fhicl::Tuple< T >::Tuple ( Name &&  name,
default_type const &  defaults 
)
explicit

Definition at line 235 of file Tuple.h.

236  : Tuple{std::move(name), Comment(""), defaults}
237  {}
std::string const & name() const
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
#define Comment
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.

248  , RegisterIfTableMember{this}
249  {
250  fill_tuple_elements(defaults, std::index_sequence_for<T...>());
252  }
std::string const & name() const
Definition: ParameterBase.h:43
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
def move(depos, offset)
Definition: depos.py:107
void fill_tuple_elements(default_type const &default_values, std::index_sequence< I... >)
Definition: Tuple.h:181
std::string const & comment() const
Definition: ParameterBase.h:48
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.

263  maybeUse}
264  , RegisterIfTableMember{this}
265  {
266  fill_tuple_elements(defaults, std::index_sequence_for<T...>());
268  }
std::string const & name() const
Definition: ParameterBase.h:43
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
def move(depos, offset)
Definition: depos.py:107
void fill_tuple_elements(default_type const &default_values, std::index_sequence< I... >)
Definition: Tuple.h:181
std::string const & comment() const
Definition: ParameterBase.h:48

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.

127  {
129  }
void check_nargs_for_bounded_sequences(std::string const &key, std::size_t expected, std::size_t provided)
std::void_t< T > n
std::string const & key() const
Definition: ParameterBase.h:38
std::size_t get_size() const noexcept override
Definition: Tuple.h:103
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
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.

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.

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.

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.

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.

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  }
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.

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.

140  {
141  (pw.walk_over(*std::get<I>(value_)), ...);
142  }
ftype value_
Definition: Tuple.h:100
template<typename... T>
auto fhicl::Tuple< T >::operator() ( ) const

Definition at line 272 of file Tuple.h.

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

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: