Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
fhicl::Table< T, KeysToIgnore > Class Template Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/fhiclcpp/v4_11_01/source/fhiclcpp/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={})
 
auto const & operator() () const
 
ParameterSet const & get_PSet () const
 
void validate_ParameterSet (ParameterSet const &pset, std::set< std::string > const &keysToIgnore={})
 
void print_allowed_configuration (std::ostream &os, std::string const &tab=std::string(3, ' ')) const
 
std::vector< cet::exempt_ptr< ParameterBase > > const & members () 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 trimParents)
 
void set_par_style (par_style const vt)
 

Private Types

using members_t = std::vector< cet::exempt_ptr< ParameterBase >>
 

Private Member Functions

 Table (ParameterSet const &, std::set< std::string > const &, Impl)
 
void maybe_implicitly_default ()
 
members_t const & get_members () const override
 
void do_set_value (fhicl::ParameterSet const &pset, bool const trimParents) override
 

Private Attributes

std::shared_ptr< Tvalue_ {std::make_shared<T>()}
 
ParameterSet pset_ {}
 
members_t members_
 

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 82 of file Table.h.

template<typename T, typename KeysToIgnore = void>
using fhicl::Table< T, KeysToIgnore >::members_t = std::vector<cet::exempt_ptr<ParameterBase>>
private

Definition at line 86 of file Table.h.

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

Definition at line 83 of file Table.h.

Constructor & Destructor Documentation

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

Definition at line 130 of file Table.h.

131  : Table{std::move(name), Comment(""), std::forward<TCARGS>(tcargs)...}
132  {}
const XML_Char * name
Definition: expat.h:151
template<typename T , typename KeysToIgnore >
template<typename... TCARGS>
Table::Table ( Name &&  name,
Comment &&  comment,
TCARGS &&...  tcargs 
)
explicit

Definition at line 136 of file Table.h.

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

139  : TableBase{std::move(name),
140  std::move(comment),
143  , RegisterIfTableMember{this}
144  , value_{std::make_shared<T>(std::forward<TCARGS>(tcargs)...)}
145  {
148  }
const XML_Char * name
Definition: expat.h:151
void maybe_implicitly_default()
Definition: Table.h:244
std::function< bool()> AlwaysUse()
std::shared_ptr< T > value_
Definition: Table.h:88
std::string const & comment() const
Definition: ParameterBase.h:54
TableBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: TableBase.h:16
template<typename T , typename KeysToIgnore >
template<typename... TCARGS>
Table::Table ( Name &&  name,
Comment &&  comment,
MaybeUseFunction  maybeUse,
TCARGS &&...  tcargs 
)
explicit

Definition at line 152 of file Table.h.

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

156  : TableBase{std::move(name),
157  std::move(comment),
159  maybeUse}
160  , RegisterIfTableMember{this}
161  , value_{std::make_shared<T>(std::forward<TCARGS>(tcargs)...)}
162  {
165  }
const XML_Char * name
Definition: expat.h:151
void maybe_implicitly_default()
Definition: Table.h:244
std::shared_ptr< T > value_
Definition: Table.h:88
std::string const & comment() const
Definition: ParameterBase.h:54
TableBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: TableBase.h:16
template<typename T , typename KeysToIgnore >
template<typename , typename >
Table::Table ( ParameterSet const &  pset)

Definition at line 169 of file Table.h.

170  : Table{pset, KeysToIgnore{}(), Impl{}}
171  {}
template<typename T , typename KeysToIgnore >
template<typename , typename >
Table::Table ( ParameterSet const &  pset,
std::set< std::string > const &  keysToIgnore = {} 
)

Definition at line 175 of file Table.h.

177  : Table{pset, keysToIgnore, Impl{}}
178  {}
template<typename T , typename KeysToIgnore >
Table::Table ( ParameterSet const &  pset,
std::set< std::string > const &  keysToIgnore,
Impl   
)
private

Definition at line 181 of file Table.h.

References fhicl::detail::AlwaysUse(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::Table< T, KeysToIgnore >::maybe_implicitly_default(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), fhicl::REQUIRED, and fhicl::Table< T, KeysToIgnore >::validate_ParameterSet().

184  : TableBase{Name("<top_level>"),
185  Comment(""),
188  , RegisterIfTableMember{this}
189  {
191  validate_ParameterSet(pset, keysToIgnore);
193  }
void maybe_implicitly_default()
Definition: Table.h:244
std::function< bool()> AlwaysUse()
void validate_ParameterSet(ParameterSet const &pset, std::set< std::string > const &keysToIgnore={})
Definition: Table.h:197
TableBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: TableBase.h:16

Member Function Documentation

std::string const& fhicl::detail::ParameterBase::comment ( ) const
inlineinherited
template<typename T , typename KeysToIgnore >
void Table::do_set_value ( fhicl::ParameterSet const &  pset,
bool const  trimParents 
)
overrideprivatevirtual

Implements fhicl::detail::ParameterBase.

Definition at line 227 of file Table.h.

References fhicl::ParameterSet::get(), fhicl::detail::ParameterBase::key(), fhicl::Table< T, KeysToIgnore >::pset_, string, and fhicl::detail::strip_first_containing_name().

Referenced by fhicl::Table< mf::service::ELdestination::MsgFormatSettings::mf::service::ELdestination::Config >::get_members().

229  {
230  // Kind of tricky: we do not have the name of the current
231  // parameter set. A placeholder is often used (e.g. "<top_level>").
232  // Fortunately, since the pset is passed in, we can just assign to
233  // it for a top-level ParameterSet. However, for nested parameter
234  // sets, we need to trim off the placeholder, and then the key we
235  // send pset.get<fhicl::ParameterSet>(key) is the key relative to
236  // the top-level pset.
237  std::string const& rkey = key();
239  pset_ = (nkey == rkey) ? pset : pset.get<fhicl::ParameterSet>(nkey);
240  }
ParameterSet pset_
Definition: Table.h:89
std::string strip_first_containing_name(std::string const &key)
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::string const & key() const
Definition: ParameterBase.h:44
enum BeamMode string
template<typename T, typename KeysToIgnore = void>
members_t const& fhicl::Table< T, KeysToIgnore >::get_members ( ) const
inlineoverrideprivatevirtual

Implements fhicl::detail::TableBase.

Definition at line 98 of file Table.h.

99  {
100  return members_;
101  }
members_t members_
Definition: Table.h:90
template<typename T, typename KeysToIgnore = void>
ParameterSet const& fhicl::Table< T, KeysToIgnore >::get_PSet ( ) const
inline

Definition at line 68 of file Table.h.

69  {
70  return pset_;
71  }
ParameterSet pset_
Definition: Table.h:89
bool fhicl::detail::ParameterBase::has_default ( ) const
inlineinherited
bool fhicl::detail::ParameterBase::is_conditional ( ) const
inlineinherited
bool fhicl::detail::ParameterBase::is_optional ( ) const
inlineinherited
std::string const& fhicl::detail::ParameterBase::key ( ) const
inlineinherited
template<typename T , typename KeysToIgnore >
void Table::maybe_implicitly_default ( )
private

Definition at line 244 of file Table.h.

References fhicl::DEFAULT, fhicl::Table< T, KeysToIgnore >::members_, and fhicl::detail::ParameterBase::set_par_style().

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

245  {
246  bool const implicitly_default =
247  std::all_of(members_.begin(), members_.end(), [](auto p) {
248  return p->has_default() || p->is_optional();
249  });
250  if (implicitly_default)
252  }
const char * p
Definition: xmltok.h:285
members_t members_
Definition: Table.h:90
void set_par_style(par_style const vt)
std::vector<cet::exempt_ptr<ParameterBase> > const& fhicl::detail::TableBase::members ( ) const
inlineinherited

Definition at line 24 of file TableBase.h.

References fhicl::detail::TableBase::get_members().

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

25  {
26  return get_members();
27  }
virtual std::vector< cet::exempt_ptr< ParameterBase > > const & get_members() const =0
std::string const& fhicl::detail::ParameterBase::name ( ) const
inlineinherited
template<typename T, typename KeysToIgnore = void>
auto const& fhicl::Table< T, KeysToIgnore >::operator() ( void  ) const
inline

Definition at line 62 of file Table.h.

63  {
64  return *value_;
65  }
std::shared_ptr< T > value_
Definition: Table.h:88
par_type fhicl::detail::ParameterBase::parameter_type ( ) const
inlineinherited
template<typename T , typename KeysToIgnore >
void Table::print_allowed_configuration ( std::ostream &  os,
std::string const &  tab = std::string(3, ' ') 
) const

Definition at line 216 of file Table.h.

References fhicl::detail::optional_parameter_message(), and python.hepunit::pc.

Referenced by fhicl::Table< mf::service::ELdestination::MsgFormatSettings::mf::service::ELdestination::Config >::get_PSet().

219  {
220  os << '\n' << tab << detail::optional_parameter_message() << '\n';
221  detail::PrintAllowedConfiguration pc{os, false, tab};
222  pc.walk_over(*this);
223  }
std::string optional_parameter_message(bool const with_comment=true)
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_
template<typename T , typename KeysToIgnore >
void Table::validate_ParameterSet ( ParameterSet const &  pset,
std::set< std::string > const &  keysToIgnore = {} 
)

Definition at line 197 of file Table.h.

References fhicl::NameStackRegistry::clear(), cet::for_all(), fhicl::NameStackRegistry::instance(), m, fhicl::detail::TableBase::members(), and fhicl::Table< T, KeysToIgnore >::pset_.

Referenced by fhicl::Table< mf::service::ELdestination::MsgFormatSettings::mf::service::ELdestination::Config >::get_PSet(), and fhicl::Table< T, KeysToIgnore >::Table().

200  {
201  pset_ = pset;
202  detail::ValidateThenSet vs{pset_, keysToIgnore};
203  cet::for_all(members(), [&vs](auto m) { vs.walk_over(*m); });
204 
205  try {
206  vs.check_keys();
207  }
208  catch (fhicl::detail::validationException const&) {
210  throw;
211  }
212  }
static NameStackRegistry & instance()
ParameterSet pset_
Definition: Table.h:89
std::vector< cet::exempt_ptr< ParameterBase > > const & members() const
Definition: TableBase.h:24
auto for_all(FwdCont &, Func)

Member Data Documentation

template<typename T, typename KeysToIgnore = void>
members_t fhicl::Table< T, KeysToIgnore >::members_
private
template<typename T, typename KeysToIgnore = void>
ParameterSet fhicl::Table< T, KeysToIgnore >::pset_ {}
private
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: