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

#include "type_traits.h"

Inheritance diagram for fhicl::Table< T, KeysToIgnore >:
fhicl::detail::TableBase fhicl::detail::RegisterIfTableMember fhicl::detail::ParameterBase

Classes

struct  Impl
 

Public Types

using default_type = T
 
using value_type = T
 

Public Member Functions

template<typename... TCARGS>
 Table (Name &&name, TCARGS &&...tcargs)
 
template<typename... TCARGS>
 Table (Name &&name, Comment &&comment, TCARGS &&...tcargs)
 
template<typename... TCARGS>
 Table (Name &&name, Comment &&comment, MaybeUseFunction maybeUse, TCARGS &&...tcargs)
 
template<typename K = KeysToIgnore, typename = std::enable_if_t<tt::is_callable<K>::value>>
 Table (ParameterSet const &pset)
 
template<typename K = KeysToIgnore, typename = std::enable_if_t<!tt::is_callable<K>::value>>
 Table (ParameterSet const &pset, std::set< std::string > const &keysToIgnore={})
 
T const & operator() () const
 
ParameterSet const & get_PSet () const
 
void print_allowed_configuration (std::ostream &os, std::string const &tab=std::string(3, ' ')) const
 
std::vector< cet::exempt_ptr< ParameterBase > > const & members () const
 
void validate (ParameterSet const &pset, std::set< std::string > const &ignorable_keys={})
 
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)
 

Protected Member Functions

void finalize_members ()
 
void maybe_implicitly_default ()
 
bool has_value () const
 
ParameterSet const & get_pset () const
 
ParameterSet const & guarantee_pset () const
 

Private Member Functions

 Table (ParameterSet const &, std::set< std::string > const &, Impl)
 

Private Attributes

std::shared_ptr< T > value_ {std::make_shared<T>()}
 

Detailed Description

template<typename T, typename KeysToIgnore = void>
class fhicl::Table< T, KeysToIgnore >

Definition at line 30 of file type_traits.h.

Member Typedef Documentation

template<typename T, typename KeysToIgnore = void>
using fhicl::Table< T, KeysToIgnore >::default_type = T

Definition at line 77 of file Table.h.

template<typename T, typename KeysToIgnore = void>
using fhicl::Table< T, KeysToIgnore >::value_type = T

Definition at line 78 of file Table.h.

Constructor & Destructor Documentation

template<typename T , typename KeysToIgnore >
template<typename... TCARGS>
fhicl::Table< T, KeysToIgnore >::Table ( Name &&  name,
TCARGS &&...  tcargs 
)
explicit

Definition at line 92 of file Table.h.

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

93  : Table{std::move(name), Comment(""), std::forward<TCARGS>(tcargs)...}
94  {}
std::string const & name() const
map< int, array< map< int, double >, 2 >> Table
Definition: plot.C:18
template<typename T , typename KeysToIgnore >
template<typename... TCARGS>
fhicl::Table< T, KeysToIgnore >::Table ( Name &&  name,
Comment &&  comment,
TCARGS &&...  tcargs 
)
explicit

Definition at line 98 of file Table.h.

References fhicl::detail::AlwaysUse(), fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::TableBase::finalize_members(), fhicl::detail::TableBase::maybe_implicitly_default(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::REQUIRED, and fhicl::Table< T, KeysToIgnore >::value_.

101  : TableBase{std::move(name),
102  std::move(comment),
105  , RegisterIfTableMember{this}
106  , value_{std::make_shared<T>(std::forward<TCARGS>(tcargs)...)}
107  {
111  }
std::function< bool()> AlwaysUse()
std::string const & name() const
std::shared_ptr< T > value_
Definition: Table.h:81
std::string const & comment() const
TableBase(Name const &name, Comment const &comment, par_style vt, std::function< bool()> maybeUse)
Definition: TableBase.cc:12
template<typename T , typename KeysToIgnore >
template<typename... TCARGS>
fhicl::Table< T, KeysToIgnore >::Table ( Name &&  name,
Comment &&  comment,
MaybeUseFunction  maybeUse,
TCARGS &&...  tcargs 
)
explicit

Definition at line 115 of file Table.h.

References fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::TableBase::finalize_members(), fhicl::detail::TableBase::maybe_implicitly_default(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::REQUIRED_CONDITIONAL, and fhicl::Table< T, KeysToIgnore >::value_.

119  : TableBase{std::move(name),
120  std::move(comment),
122  maybeUse}
123  , RegisterIfTableMember{this}
124  , value_{std::make_shared<T>(std::forward<TCARGS>(tcargs)...)}
125  {
129  }
std::string const & name() const
std::shared_ptr< T > value_
Definition: Table.h:81
std::string const & comment() const
TableBase(Name const &name, Comment const &comment, par_style vt, std::function< bool()> maybeUse)
Definition: TableBase.cc:12
template<typename T , typename KeysToIgnore >
template<typename , typename >
fhicl::Table< T, KeysToIgnore >::Table ( ParameterSet const &  pset)

Definition at line 133 of file Table.h.

134  : Table{pset, KeysToIgnore{}(), Impl{}}
135  {}
map< int, array< map< int, double >, 2 >> Table
Definition: plot.C:18
template<typename T , typename KeysToIgnore >
template<typename , typename >
fhicl::Table< T, KeysToIgnore >::Table ( ParameterSet const &  pset,
std::set< std::string > const &  keysToIgnore = {} 
)

Definition at line 139 of file Table.h.

141  : Table{pset, keysToIgnore, Impl{}}
142  {}
map< int, array< map< int, double >, 2 >> Table
Definition: plot.C:18
template<typename T , typename KeysToIgnore >
fhicl::Table< T, KeysToIgnore >::Table ( ParameterSet const &  pset,
std::set< std::string > const &  keysToIgnore,
Impl   
)
private

Definition at line 145 of file Table.h.

References fhicl::detail::AlwaysUse(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::TableBase::finalize_members(), fhicl::detail::TableBase::maybe_implicitly_default(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::REQUIRED, and fhicl::detail::TableBase::validate().

148  : TableBase{Name("<top_level>"),
149  Comment(""),
152  , RegisterIfTableMember{this}
153  {
157  validate(pset, keysToIgnore);
158  }
std::function< bool()> AlwaysUse()
void validate(ParameterSet const &pset, std::set< std::string > const &ignorable_keys={})
Definition: TableBase.cc:56
TableBase(Name const &name, Comment const &comment, par_style vt, std::function< bool()> maybeUse)
Definition: TableBase.cc:12

Member Function Documentation

void fhicl::detail::TableBase::finalize_members ( )
protectedinherited

Definition at line 37 of file TableBase.cc.

References fhicl::detail::TableBase::members_, and fhicl::detail::TableMemberRegistry::release_members().

Referenced by fhicl::OptionalTable< T >::OptionalTable(), and fhicl::Table< T, KeysToIgnore >::Table().

38  {
39  // This must be called in a derived class **after** the table's
40  // values has been set.
42  }
std::vector< cet::exempt_ptr< ParameterBase > > members_
Definition: TableBase.h:45
static std::vector< base_ptr > release_members()
ParameterSet const & fhicl::detail::TableBase::get_pset ( ) const
protectedinherited

Definition at line 79 of file TableBase.cc.

References fhicl::detail::TableBase::pset_.

80  {
81  return pset_.value();
82  }
std::optional< ParameterSet > pset_
Definition: TableBase.h:44
template<typename T, typename KeysToIgnore = void>
ParameterSet const& fhicl::Table< T, KeysToIgnore >::get_PSet ( ) const
inline

Definition at line 70 of file Table.h.

Referenced by evgen::ActiveVolumeVertexSampler::ActiveVolumeVertexSampler().

71  {
72  return TableBase::get_pset();
73  }
ParameterSet const & fhicl::detail::TableBase::guarantee_pset ( ) const
protectedinherited

Definition at line 85 of file TableBase.cc.

References fhicl::detail::TableBase::pset_.

86  {
87  static ParameterSet const empty_pset;
88  return pset_.has_value() ? *pset_ : empty_pset;
89  }
std::optional< ParameterSet > pset_
Definition: TableBase.h:44
bool fhicl::detail::TableBase::has_value ( ) const
protectedinherited

Definition at line 73 of file TableBase.cc.

References fhicl::detail::TableBase::pset_.

74  {
75  return pset_.has_value();
76  }
std::optional< ParameterSet > pset_
Definition: TableBase.h:44
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
void fhicl::detail::TableBase::maybe_implicitly_default ( )
protectedinherited

Definition at line 45 of file TableBase.cc.

References fhicl::DEFAULT, fhicl::detail::TableBase::members_, and fhicl::detail::ParameterBase::set_par_style().

Referenced by fhicl::Table< T, KeysToIgnore >::Table().

46  {
47  bool const implicitly_default =
48  std::all_of(members_.begin(), members_.end(), [](auto p) {
49  return p->has_default() || p->is_optional();
50  });
51  if (implicitly_default)
53  }
std::vector< cet::exempt_ptr< ParameterBase > > members_
Definition: TableBase.h:45
void set_par_style(par_style const vt)
std::vector< cet::exempt_ptr< ParameterBase > > const & fhicl::detail::TableBase::members ( ) const
inherited

Definition at line 31 of file TableBase.cc.

References fhicl::detail::TableBase::members_.

32  {
33  return members_;
34  }
std::vector< cet::exempt_ptr< ParameterBase > > members_
Definition: TableBase.h:45
template<typename T, typename KeysToIgnore = void>
T const& fhicl::Table< T, KeysToIgnore >::operator() ( ) const
inline

Definition at line 64 of file Table.h.

65  {
66  return *value_;
67  }
std::shared_ptr< T > value_
Definition: Table.h:81
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::TableBase::print_allowed_configuration ( std::ostream &  os,
std::string const &  tab = std::string(3, ' ') 
) const
inherited

Definition at line 22 of file TableBase.cc.

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

Referenced by art::operator<<(), and fhicl::detail::operator<<().

24  {
25  os << '\n' << tab << optional_parameter_message() << '\n';
26  PrintAllowedConfiguration pc{os, false, tab};
27  pc.walk_over(*this);
28  }
std::string optional_parameter_message(bool const with_comment=true)
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
void fhicl::detail::TableBase::validate ( ParameterSet const &  pset,
std::set< std::string > const &  ignorable_keys = {} 
)
inherited

Definition at line 56 of file TableBase.cc.

References fhicl::NameStackRegistry::clear(), fhicl::detail::TableBase::members_, and fhicl::detail::TableBase::pset_.

Referenced by fhicl::OptionalTable< T >::OptionalTable(), and fhicl::Table< T, KeysToIgnore >::Table().

58  {
59  pset_ = std::make_optional(pset);
60  ValidateThenSet vs{pset, ignorable_keys};
61  cet::for_all(members_, [&vs](auto m) { vs.walk_over(*m); });
62 
63  try {
64  vs.check_keys();
65  }
66  catch (detail::validationException const&) {
68  throw;
69  }
70  }
std::vector< cet::exempt_ptr< ParameterBase > > members_
Definition: TableBase.h:45
std::optional< ParameterSet > pset_
Definition: TableBase.h:44

Member Data Documentation

template<typename T, typename KeysToIgnore = void>
std::shared_ptr<T> fhicl::Table< T, KeysToIgnore >::value_ {std::make_shared<T>()}
private

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