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 <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 const &pset, std::set< std::string > const &keysToIgnore={})
 
void print_allowed_configuration (std::ostream &os, std::string const &tab=std::string(3, ' ')) const
 
- Public Member Functions inherited from fhicl::detail::TableBase
 TableBase (Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
 
std::vector< cet::exempt_ptr< ParameterBase > > const & members () 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 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) override
 
- Private Member Functions inherited from fhicl::detail::RegisterIfTableMember
 RegisterIfTableMember (ParameterBase *pb)
 

Private Attributes

std::shared_ptr< T > value_ {std::make_shared<T>()}
 
ParameterSet pset_ {}
 
members_t members_ {detail::TableMemberRegistry::release_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>
fhicl::Table< T, KeysToIgnore >::Table ( Name &&  name,
TCARGS &&...  tcargs 
)
explicit

Definition at line 128 of file Table.h.

129  : Table{std::move(name), Comment(""), std::forward<TCARGS>(tcargs)...}
130  {}
std::string const & name() const
Definition: ParameterBase.h:43
Table(Name &&name, TCARGS &&...tcargs)
Definition: Table.h:128
def move(depos, offset)
Definition: depos.py:107
#define Comment
template<typename T , typename KeysToIgnore >
template<typename... TCARGS>
fhicl::Table< T, KeysToIgnore >::Table ( Name &&  name,
Comment &&  comment,
TCARGS &&...  tcargs 
)
explicit

Definition at line 134 of file Table.h.

141  , RegisterIfTableMember{this}
142  , value_{std::make_shared<T>(std::forward<TCARGS>(tcargs)...)}
143  {
146  }
std::string const & name() const
Definition: ParameterBase.h:43
std::function< bool()> AlwaysUse()
def move(depos, offset)
Definition: depos.py:107
std::shared_ptr< T > value_
Definition: Table.h:88
void maybe_implicitly_default()
Definition: Table.h:240
std::string const & comment() const
Definition: ParameterBase.h:48
TableBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: TableBase.h:11
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 150 of file Table.h.

157  maybeUse}
158  , RegisterIfTableMember{this}
159  , value_{std::make_shared<T>(std::forward<TCARGS>(tcargs)...)}
160  {
163  }
std::string const & name() const
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
std::shared_ptr< T > value_
Definition: Table.h:88
void maybe_implicitly_default()
Definition: Table.h:240
std::string const & comment() const
Definition: ParameterBase.h:48
TableBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: TableBase.h:11
template<typename T , typename KeysToIgnore >
template<typename , typename >
fhicl::Table< T, KeysToIgnore >::Table ( ParameterSet const &  pset)

Definition at line 167 of file Table.h.

168  : Table{pset, KeysToIgnore{}(), Impl{}}
169  {}
Table(Name &&name, TCARGS &&...tcargs)
Definition: Table.h:128
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 173 of file Table.h.

175  : Table{pset, keysToIgnore, Impl{}}
176  {}
Table(Name &&name, TCARGS &&...tcargs)
Definition: Table.h:128
template<typename T , typename KeysToIgnore >
fhicl::Table< T, KeysToIgnore >::Table ( ParameterSet const &  pset,
std::set< std::string > const &  keysToIgnore,
Impl   
)
private

Definition at line 179 of file Table.h.

182  : TableBase{Name("<top_level>"),
183  Comment(""),
186  , RegisterIfTableMember{this}
187  {
190  validate(pset, keysToIgnore);
191  }
ChannelGroupService::Name Name
std::function< bool()> AlwaysUse()
void validate(ParameterSet const &pset, std::set< std::string > const &keysToIgnore={})
Definition: Table.h:195
#define Comment
void maybe_implicitly_default()
Definition: Table.h:240
TableBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: TableBase.h:11

Member Function Documentation

template<typename T , typename KeysToIgnore >
void fhicl::Table< T, KeysToIgnore >::do_set_value ( fhicl::ParameterSet const &  pset)
overrideprivatevirtual

Implements fhicl::detail::ParameterBase.

Definition at line 224 of file Table.h.

225  {
226  // Kind of tricky: we do not have the name of the current
227  // parameter set. A placeholder is often used (e.g. "<top_level>").
228  // Fortunately, since the pset is passed in, we can just assign to
229  // it for a top-level ParameterSet. However, for nested parameter
230  // sets, we need to trim off the placeholder, and then the key we
231  // send pset.get<fhicl::ParameterSet>(key) is the key relative to
232  // the top-level pset.
233  std::string const& rkey = key();
235  pset_ = (nkey == rkey) ? pset : pset.get<fhicl::ParameterSet>(nkey);
236  }
std::string string
Definition: nybbler.cc:12
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:271
std::string const & key() const
Definition: ParameterBase.h:38
template<typename T, typename KeysToIgnore = void>
members_t const& fhicl::Table< T, KeysToIgnore >::get_members ( ) const
inlineoverrideprivatevirtual

Implements fhicl::detail::TableBase.

Definition at line 97 of file Table.h.

98  {
99  return members_;
100  }
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
template<typename T , typename KeysToIgnore >
void fhicl::Table< T, KeysToIgnore >::maybe_implicitly_default ( )
private

Definition at line 240 of file Table.h.

241  {
242  bool const implicitly_default =
243  std::all_of(members_.begin(), members_.end(), [](auto p) {
244  return p->has_default() || p->is_optional();
245  });
246  if (implicitly_default)
248  }
members_t members_
Definition: Table.h:90
p
Definition: test.py:223
void set_par_style(par_style const vt)
template<typename T, typename KeysToIgnore = void>
auto const& fhicl::Table< T, KeysToIgnore >::operator() ( ) const
inline

Definition at line 62 of file Table.h.

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

Definition at line 213 of file Table.h.

216  {
217  os << '\n' << tab << detail::optional_parameter_message() << '\n';
218  detail::PrintAllowedConfiguration pc{os, false, tab};
219  pc.walk_over(*this);
220  }
std::string optional_parameter_message(bool const with_comment=true)
template<typename T , typename KeysToIgnore >
void fhicl::Table< T, KeysToIgnore >::validate ( ParameterSet const &  pset,
std::set< std::string > const &  keysToIgnore = {} 
)

Definition at line 195 of file Table.h.

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

Member Data Documentation

template<typename T, typename KeysToIgnore = void>
members_t fhicl::Table< T, KeysToIgnore >::members_ {detail::TableMemberRegistry::release_members()}
private

Definition at line 90 of file Table.h.

template<typename T, typename KeysToIgnore = void>
ParameterSet fhicl::Table< T, KeysToIgnore >::pset_ {}
private

Definition at line 89 of file Table.h.

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

Definition at line 88 of file Table.h.


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