Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
fhicl::OptionalTuple< TYPES > Class Template Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/fhiclcpp/v4_06_10/source/fhiclcpp/type_traits.h"

Inheritance diagram for fhicl::OptionalTuple< TYPES >:
fhicl::detail::SequenceBase fhicl::detail::RegisterIfTableMember fhicl::detail::ParameterBase

Public Types

using ftype = std::tuple< std::shared_ptr< tt::fhicl_type< TYPES >>... >
 
using value_type = std::tuple< tt::return_type< TYPES >... >
 

Public Member Functions

 OptionalTuple (Name &&name)
 
 OptionalTuple (Name &&name, Comment &&comment)
 
 OptionalTuple (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
bool operator() (value_type &) const
 
bool hasValue () const
 
bool empty () const
 
std::size_t size () const
 
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 key () const
 
std::string name () const
 
std::string 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 trimParents)
 
void set_par_style (par_style const vt)
 
void set_key (std::string const &key)
 

Private Types

using PW_non_const = detail::ParameterWalker< tt::const_flavor::require_non_const >
 
using PW_const = detail::ParameterWalker< tt::const_flavor::require_const >
 
using TUPLE = std::tuple< tt::fhicl_type< TYPES >... >
 

Private Member Functions

std::size_t get_size () const override
 
void visit_element (PW_non_const &)
 
template<typename E , typename... T>
void visit_element (PW_non_const &pw, E &elem, T &...others)
 
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
 
void visit_element (PW_const &) const
 
template<typename E , typename... T>
void visit_element (PW_const &pw, E const &elem, T const &...others) const
 
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
 
void finalize_tuple_elements (std::size_t)
 
template<typename E , typename... T>
void finalize_tuple_elements (std::size_t i, E &elem, T &...others)
 
template<std::size_t... I>
void finalize_elements (std::index_sequence< I... >)
 
template<size_t I, typename value_type >
std::enable_if_t<(I >=std::tuple_size< TUPLE >::value)> fill_return_element (value_type &) const
 
template<size_t I, typename value_type >
std::enable_if_t<(I< std::tuple_size< TUPLE >::value)> fill_return_element (value_type &result) const
 
void assemble_rtype (value_type &result) const
 
void do_set_value (fhicl::ParameterSet const &, bool const ) override
 

Private Attributes

ftype value_
 
bool has_value_ {false}
 

Detailed Description

template<typename... TYPES>
class fhicl::OptionalTuple< TYPES >

Definition at line 40 of file type_traits.h.

Member Typedef Documentation

template<typename... TYPES>
using fhicl::OptionalTuple< TYPES >::ftype = std::tuple<std::shared_ptr<tt::fhicl_type<TYPES>>...>

Definition at line 30 of file OptionalTuple.h.

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

Definition at line 61 of file OptionalTuple.h.

template<typename... TYPES>
using fhicl::OptionalTuple< TYPES >::PW_non_const = detail::ParameterWalker<tt::const_flavor::require_non_const>
private

Definition at line 60 of file OptionalTuple.h.

template<typename... TYPES>
using fhicl::OptionalTuple< TYPES >::TUPLE = std::tuple<tt::fhicl_type<TYPES>...>
private

Definition at line 163 of file OptionalTuple.h.

template<typename... TYPES>
using fhicl::OptionalTuple< TYPES >::value_type = std::tuple<tt::return_type<TYPES>...>

Definition at line 31 of file OptionalTuple.h.

Constructor & Destructor Documentation

template<typename... TYPES>
fhicl::OptionalTuple< TYPES >::OptionalTuple ( Name &&  name)
explicit

Definition at line 201 of file OptionalTuple.h.

202  : OptionalTuple{std::move(name), Comment("")}
203  {}
const XML_Char * name
Definition: expat.h:151
OptionalTuple(Name &&name)
template<typename... TYPES>
fhicl::OptionalTuple< TYPES >::OptionalTuple ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 206 of file OptionalTuple.h.

References fhicl::detail::AlwaysUse(), fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::OptionalTuple< TYPES >::finalize_elements(), fhicl::OPTIONAL, fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::TUPLE.

207  : SequenceBase{std::move(name),
208  std::move(comment),
212  , RegisterIfTableMember{this}
213  {
214  finalize_elements(std::index_sequence_for<TYPES...>{});
216  }
const XML_Char * name
Definition: expat.h:151
std::function< bool()> AlwaysUse()
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:20
void finalize_elements(std::index_sequence< I... >)
std::string comment() const
Definition: ParameterBase.h:54
template<typename... TYPES>
fhicl::OptionalTuple< TYPES >::OptionalTuple ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 219 of file OptionalTuple.h.

References fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::OptionalTuple< TYPES >::finalize_elements(), fhicl::OPTIONAL_CONDITIONAL, fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::TUPLE.

222  : SequenceBase{std::move(name),
223  std::move(comment),
226  maybeUse}
227  , RegisterIfTableMember{this}
228  {
229  finalize_elements(std::index_sequence_for<TYPES...>{});
231  }
const XML_Char * name
Definition: expat.h:151
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:20
void finalize_elements(std::index_sequence< I... >)
std::string comment() const
Definition: ParameterBase.h:54

Member Function Documentation

template<typename... TYPES>
void fhicl::OptionalTuple< TYPES >::assemble_rtype ( value_type result) const
inlineprivate

Definition at line 179 of file OptionalTuple.h.

Referenced by fhicl::OptionalTuple< TYPES >::operator()().

180  {
181  fill_return_element<0>(result);
182  }
std::string fhicl::detail::ParameterBase::comment ( ) const
inlineinherited
template<typename... TYPES>
void fhicl::OptionalTuple< TYPES >::do_prepare_elements_for_validation ( std::size_t const  n)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 90 of file OptionalTuple.h.

91  {
93  }
void check_nargs_for_bounded_sequences(std::string const &key, std::size_t expected, std::size_t provided)
std::size_t get_size() const override
Definition: OptionalTuple.h:52
std::string key() const
Definition: ParameterBase.h:44
template<typename... TYPES>
void fhicl::OptionalTuple< TYPES >::do_set_value ( fhicl::ParameterSet const &  ,
bool  const 
)
inlineoverrideprivatevirtual

Implements fhicl::detail::ParameterBase.

Definition at line 185 of file OptionalTuple.h.

187  {
188  // We do not explicitly set the sequence values here as the
189  // individual elements are set one at a time. However, this
190  // function is reached in the ValidateThenSet algorithm if the
191  // optional parameter is present. Otherwise, this override is
192  // skipped.
193  has_value_ = true;
194  }
template<typename... TYPES>
void fhicl::OptionalTuple< TYPES >::do_walk_elements ( PW_non_const pw)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 96 of file OptionalTuple.h.

97  {
98  iterate_over_tuple(pw, std::index_sequence_for<TYPES...>{});
99  }
void iterate_over_tuple(PW_non_const &pw, std::index_sequence< I... >)
Definition: OptionalTuple.h:84
template<typename... TYPES>
void fhicl::OptionalTuple< TYPES >::do_walk_elements ( PW_const pw) const
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 128 of file OptionalTuple.h.

129  {
130  iterate_over_tuple(pw, std::index_sequence_for<TYPES...>{});
131  }
void iterate_over_tuple(PW_non_const &pw, std::index_sequence< I... >)
Definition: OptionalTuple.h:84
bool fhicl::detail::SequenceBase::empty ( ) const
inlineinherited

Definition at line 29 of file SequenceBase.h.

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

30  {
31  return size() == 0;
32  }
std::size_t size() const
Definition: SequenceBase.h:34
template<typename... TYPES>
template<size_t I, typename value_type >
std::enable_if_t<(I >= std::tuple_size<TUPLE>::value)> fhicl::OptionalTuple< TYPES >::fill_return_element ( value_type ) const
inlineprivate

Definition at line 167 of file OptionalTuple.h.

168  {}
template<typename... TYPES>
template<size_t I, typename value_type >
std::enable_if_t<(I < std::tuple_size<TUPLE>::value)> fhicl::OptionalTuple< TYPES >::fill_return_element ( value_type result) const
inlineprivate

Definition at line 172 of file OptionalTuple.h.

173  {
174  std::get<I>(result) = (*std::get<I>(value_))();
175  fill_return_element<I + 1>(result);
176  }
template<typename... TYPES>
template<std::size_t... I>
void fhicl::OptionalTuple< TYPES >::finalize_elements ( std::index_sequence< I... >  )
inlineprivate

Definition at line 155 of file OptionalTuple.h.

Referenced by fhicl::OptionalTuple< TYPES >::OptionalTuple().

156  {
157  finalize_tuple_elements(0, std::get<I>(value_)...);
158  }
void finalize_tuple_elements(std::size_t)
template<typename... TYPES>
void fhicl::OptionalTuple< TYPES >::finalize_tuple_elements ( std::size_t  )
inlineprivate
template<typename... TYPES>
template<typename E , typename... T>
void fhicl::OptionalTuple< TYPES >::finalize_tuple_elements ( std::size_t  i,
E elem,
T &...  others 
)
inlineprivate

Definition at line 140 of file OptionalTuple.h.

141  {
142  using elem_ftype = typename E::element_type;
149  elem = std::make_shared<elem_ftype>(Name::sequence_element(i));
150  finalize_tuple_elements(++i, others...);
151  }
#define NO_DELEGATED_PARAMETERS
#define NO_OPTIONAL_TYPES
#define NO_NESTED_TABLE_FRAGMENTS
static Name sequence_element(std::size_t const i)
Definition: Name.h:17
void finalize_tuple_elements(std::size_t)
template<typename... TYPES>
std::size_t fhicl::OptionalTuple< TYPES >::get_size ( ) const
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 52 of file OptionalTuple.h.

Referenced by fhicl::OptionalTuple< ARGS... >::do_prepare_elements_for_validation().

53  {
54  return std::tuple_size<ftype>();
55  }
bool fhicl::detail::ParameterBase::has_default ( ) const
inlineinherited
template<typename... TYPES>
bool fhicl::OptionalTuple< TYPES >::hasValue ( ) const
inline

Definition at line 42 of file OptionalTuple.h.

43  {
44  return has_value_;
45  }
bool fhicl::detail::ParameterBase::is_conditional ( ) const
inlineinherited
bool fhicl::detail::ParameterBase::is_optional ( ) const
inlineinherited
template<typename... TYPES>
template<std::size_t... I>
void fhicl::OptionalTuple< TYPES >::iterate_over_tuple ( PW_non_const pw,
std::index_sequence< I... >   
)
inlineprivate

Definition at line 84 of file OptionalTuple.h.

Referenced by fhicl::OptionalTuple< ARGS... >::do_walk_elements().

85  {
86  visit_element(pw, std::get<I>(value_)...);
87  }
void visit_element(PW_non_const &)
Definition: OptionalTuple.h:64
template<typename... TYPES>
template<std::size_t... I>
void fhicl::OptionalTuple< TYPES >::iterate_over_tuple ( PW_const pw,
std::index_sequence< I... >   
) const
inlineprivate

Definition at line 122 of file OptionalTuple.h.

123  {
124  visit_element(pw, std::get<I>(value_)...);
125  }
void visit_element(PW_non_const &)
Definition: OptionalTuple.h:64
std::string fhicl::detail::ParameterBase::key ( ) const
inlineinherited
std::string fhicl::detail::ParameterBase::name ( ) const
inlineinherited
template<typename... TYPES>
bool fhicl::OptionalTuple< TYPES >::operator() ( value_type r) const

Definition at line 235 of file OptionalTuple.h.

References fhicl::OptionalTuple< TYPES >::assemble_rtype(), fhicl::OptionalTuple< TYPES >::has_value_, fillBadChanDBTables::result, and std::swap().

236  {
237  if (!has_value_)
238  return false;
240  assemble_rtype(result);
241  std::swap(result, r);
242  return true;
243  }
void assemble_rtype(value_type &result) const
std::tuple< tt::return_type< TYPES >... > value_type
Definition: OptionalTuple.h:31
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
TRandom3 r(0)
par_type fhicl::detail::ParameterBase::parameter_type ( ) const
inlineinherited
void fhicl::detail::SequenceBase::prepare_elements_for_validation ( std::size_t const  n)
inlineinherited

Definition at line 40 of file SequenceBase.h.

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

41  {
43  }
virtual void do_prepare_elements_for_validation(std::size_t)=0
void fhicl::detail::ParameterBase::set_key ( std::string const &  key)
inlineinherited
void fhicl::detail::ParameterBase::set_par_style ( par_style const  vt)
inlineinherited
void fhicl::detail::ParameterBase::set_value ( fhicl::ParameterSet const &  ps,
bool  trimParents 
)
inlineinherited

Definition at line 96 of file ParameterBase.h.

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

97  {
98  do_set_value(ps, trimParents);
99  }
virtual void do_set_value(fhicl::ParameterSet const &, bool trimParents)=0
bool fhicl::detail::ParameterBase::should_use ( ) const
inlineinherited

Definition at line 79 of file ParameterBase.h.

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

80  {
81  return maybeUse_();
82  }
std::function< bool()> maybeUse_
std::size_t fhicl::detail::SequenceBase::size ( void  ) const
inlineinherited

Definition at line 34 of file SequenceBase.h.

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

Referenced by fhicl::detail::SequenceBase::empty().

35  {
36  return get_size();
37  }
virtual std::size_t get_size() const =0
template<typename... TYPES>
void fhicl::OptionalTuple< TYPES >::visit_element ( PW_non_const )
inlineprivate
template<typename... TYPES>
template<typename E , typename... T>
void fhicl::OptionalTuple< TYPES >::visit_element ( PW_non_const pw,
E elem,
T &...  others 
)
inlineprivate

Definition at line 69 of file OptionalTuple.h.

70  {
71  using elem_ftype = typename E::element_type;
78  pw.walk_over(*elem);
79  visit_element(pw, others...);
80  }
#define NO_DELEGATED_PARAMETERS
#define NO_OPTIONAL_TYPES
void visit_element(PW_non_const &)
Definition: OptionalTuple.h:64
#define NO_NESTED_TABLE_FRAGMENTS
template<typename... TYPES>
void fhicl::OptionalTuple< TYPES >::visit_element ( PW_const ) const
inlineprivate

Definition at line 102 of file OptionalTuple.h.

103  {}
template<typename... TYPES>
template<typename E , typename... T>
void fhicl::OptionalTuple< TYPES >::visit_element ( PW_const pw,
E const &  elem,
T const &...  others 
) const
inlineprivate

Definition at line 107 of file OptionalTuple.h.

108  {
109  using elem_ftype = typename E::element_type;
116  pw.walk_over(*elem);
117  visit_element(pw, others...);
118  }
#define NO_DELEGATED_PARAMETERS
#define NO_OPTIONAL_TYPES
void visit_element(PW_non_const &)
Definition: OptionalTuple.h:64
#define NO_NESTED_TABLE_FRAGMENTS
void fhicl::detail::SequenceBase::walk_elements ( ParameterWalker< tt::const_flavor::require_non_const > &  pw)
inlineinherited

Definition at line 45 of file SequenceBase.h.

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

46  {
47  do_walk_elements(pw);
48  }
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 50 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().

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

Member Data Documentation

template<typename... TYPES>
bool fhicl::OptionalTuple< TYPES >::has_value_ {false}
private
template<typename... TYPES>
ftype fhicl::OptionalTuple< TYPES >::value_
private

Definition at line 48 of file OptionalTuple.h.


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