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

#include "type_traits.h"

Inheritance diagram for fhicl::Atom< T >:
fhicl::detail::AtomBase fhicl::detail::RegisterIfTableMember fhicl::detail::ParameterBase

Public Types

using default_type = T
 
using value_type = T
 

Public Member Functions

 Atom (Name &&name)
 
 Atom (Name &&name, Comment &&comment)
 
 Atom (Name &&name, Comment &&comment, std::function< bool()> useIf)
 
 Atom (Name &&name, T const &dflt_value)
 
 Atom (Name &&name, Comment &&comment, T const &dflt_value)
 
 Atom (Name &&name, Comment &&comment, std::function< bool()> useIf, T const &dflt_value)
 
auto const & operator() () const
 
std::string stringified_value () 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 preset_value (fhicl::ParameterSet const &ps)
 
void set_par_style (par_style const vt)
 

Private Member Functions

std::string get_stringified_value () const override
 
void do_set_value (fhicl::ParameterSet const &pset) override
 

Private Attributes

value_type value_ {}
 

Detailed Description

template<typename T>
class fhicl::Atom< T >

Definition at line 25 of file type_traits.h.

Member Typedef Documentation

template<typename T>
using fhicl::Atom< T >::default_type = T

Definition at line 55 of file Atom.h.

template<typename T>
using fhicl::Atom< T >::value_type = T

Definition at line 56 of file Atom.h.

Constructor & Destructor Documentation

template<typename T >
fhicl::Atom< T >::Atom ( Name &&  name)
explicit

Definition at line 122 of file Atom.h.

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

122  : Atom{std::move(name), Comment("")}
123  {}
Atom(Name &&name)
Definition: Atom.h:122
std::string const & name() const
template<typename T >
fhicl::Atom< T >::Atom ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 73 of file Atom.h.

References fhicl::detail::AlwaysUse(), fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::REQUIRED.

74  : AtomBase{std::move(name),
75  std::move(comment),
78  , RegisterIfTableMember{this}
79  {
81  }
AtomBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: AtomBase.h:10
std::function< bool()> AlwaysUse()
std::string const & name() const
std::string const & comment() const
template<typename T >
fhicl::Atom< T >::Atom ( Name &&  name,
Comment &&  comment,
std::function< bool()>  useIf 
)
explicit

Definition at line 84 of file Atom.h.

References fhicl::detail::ParameterBase::comment(), fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::REQUIRED_CONDITIONAL.

85  : AtomBase{std::move(name),
86  std::move(comment),
88  maybeUse}
89  , RegisterIfTableMember{this}
90  {
92  }
AtomBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: AtomBase.h:10
std::string const & name() const
std::string const & comment() const
template<typename T>
fhicl::Atom< T >::Atom ( Name &&  name,
T const &  dflt_value 
)
explicit

Definition at line 126 of file Atom.h.

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

127  : Atom{std::move(name), Comment(""), dflt_value}
128  {}
Atom(Name &&name)
Definition: Atom.h:122
std::string const & name() const
template<typename T>
fhicl::Atom< T >::Atom ( Name &&  name,
Comment &&  comment,
T const &  dflt_value 
)
explicit

Definition at line 95 of file Atom.h.

References fhicl::detail::AlwaysUse(), fhicl::detail::ParameterBase::comment(), fhicl::DEFAULT, fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::Atom< T >::value_.

96  : AtomBase{std::move(name),
97  std::move(comment),
100  , RegisterIfTableMember{this}
101  , value_{dflt_value}
102  {
104  }
AtomBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: AtomBase.h:10
std::function< bool()> AlwaysUse()
std::string const & name() const
value_type value_
Definition: Atom.h:59
std::string const & comment() const
template<typename T>
fhicl::Atom< T >::Atom ( Name &&  name,
Comment &&  comment,
std::function< bool()>  useIf,
T const &  dflt_value 
)
explicit

Definition at line 107 of file Atom.h.

References fhicl::detail::ParameterBase::comment(), fhicl::DEFAULT_CONDITIONAL, fhicl::NameStackRegistry::end_of_ctor(), fhicl::detail::ParameterBase::name(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::Atom< T >::value_.

111  : AtomBase{std::move(name),
112  std::move(comment),
114  maybeUse}
115  , RegisterIfTableMember{this}
116  , value_{dflt_value}
117  {
119  }
AtomBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: AtomBase.h:10
std::string const & name() const
value_type value_
Definition: Atom.h:59
std::string const & comment() const

Member Function Documentation

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

Implements fhicl::detail::ParameterBase.

Definition at line 147 of file Atom.h.

References fhicl::ParameterSet::get(), fhicl::ParameterSet::get_if_present(), fhicl::detail::ParameterBase::has_default(), fhicl::detail::ParameterBase::key(), fhicl::detail::strip_first_containing_name(), and fhicl::Atom< T >::value_.

148  {
149  auto const trimmed_key = detail::strip_first_containing_name(key());
150  if (has_default()) {
151  // Override default value if the key is present
152  pset.get_if_present<T>(trimmed_key, value_);
153  } else
154  value_ = pset.get<T>(trimmed_key);
155  }
std::string strip_first_containing_name(std::string const &key)
std::string const & key() const
Definition: ParameterBase.cc:6
value_type value_
Definition: Atom.h:59
template<typename T >
std::string fhicl::Atom< T >::get_stringified_value ( ) const
overrideprivatevirtual

Implements fhicl::detail::AtomBase.

Definition at line 132 of file Atom.h.

References fhicl::detail::ParameterBase::has_default(), and fhicl::Atom< T >::value_.

133  {
134  std::stringstream oss;
135  if (has_default()) {
136  using namespace detail::yes_defaults;
137  oss << maybe_quotes<T>(value_);
138  } else {
139  using namespace detail::no_defaults;
140  oss << expected_types<T>();
141  }
142  return oss.str();
143  }
value_type value_
Definition: Atom.h:59
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
template<typename T>
auto const& fhicl::Atom< T >::operator() ( ) const
inline

Definition at line 49 of file Atom.h.

50  {
51  return value_;
52  }
value_type value_
Definition: Atom.h:59
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::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
std::string fhicl::detail::AtomBase::stringified_value ( ) const
inlineinherited

Definition at line 18 of file AtomBase.h.

References fhicl::detail::AtomBase::get_stringified_value().

Referenced by fhicl::detail::PrintAllowedConfiguration::atom().

19  {
20  return get_stringified_value();
21  }
virtual std::string get_stringified_value() const =0

Member Data Documentation


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