LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
fhicl::OptionalDelegatedParameter Class Referencefinal

#include "OptionalDelegatedParameter.h"

Inheritance diagram for fhicl::OptionalDelegatedParameter:
fhicl::detail::DelegateBase fhicl::detail::RegisterIfTableMember fhicl::detail::ParameterBase

Public Member Functions

 OptionalDelegatedParameter (Name &&name)
 
 OptionalDelegatedParameter (Name &&name, Comment &&comment)
 
 OptionalDelegatedParameter (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
bool hasValue () const
 
template<typename T >
std::optional< T > get_if_present () const
 
template<typename T >
bool get_if_present (T &t) 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

void do_set_value (fhicl::ParameterSet const &pset) override
 

Private Attributes

std::optional< ParameterSetpset_ {std::nullopt}
 

Detailed Description

Definition at line 18 of file OptionalDelegatedParameter.h.

Constructor & Destructor Documentation

fhicl::OptionalDelegatedParameter::OptionalDelegatedParameter ( Name &&  name)
explicit

Definition at line 7 of file OptionalDelegatedParameter.cc.

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

8  : OptionalDelegatedParameter{std::move(name), Comment("")}
9  {}
std::string const & name() const
fhicl::OptionalDelegatedParameter::OptionalDelegatedParameter ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 11 of file OptionalDelegatedParameter.cc.

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

13  : DelegateBase{std::move(name),
14  std::move(comment),
17  , RegisterIfTableMember{this}
18  {
20  }
DelegateBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: DelegateBase.h:10
std::function< bool()> AlwaysUse()
std::string const & name() const
std::string const & comment() const
fhicl::OptionalDelegatedParameter::OptionalDelegatedParameter ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 22 of file OptionalDelegatedParameter.cc.

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

26  : DelegateBase{std::move(name),
27  std::move(comment),
29  maybeUse}
30  , RegisterIfTableMember{this}
31  {
33  }
DelegateBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: DelegateBase.h:10
std::string const & name() const
std::string const & comment() const

Member Function Documentation

void fhicl::OptionalDelegatedParameter::do_set_value ( fhicl::ParameterSet const &  pset)
inlineoverrideprivatevirtual

Implements fhicl::detail::ParameterBase.

Definition at line 60 of file OptionalDelegatedParameter.h.

References pset_.

61  {
62  pset_ = std::make_optional(pset);
63  };
template<typename T >
std::optional<T> fhicl::OptionalDelegatedParameter::get_if_present ( ) const
inline

Definition at line 36 of file OptionalDelegatedParameter.h.

References fhicl::detail::ParameterBase::key(), pset_, and fhicl::detail::strip_first_containing_name().

Referenced by art::EmptyEvent::makePlugin_().

37  {
38  if (not pset_) {
39  return std::nullopt;
40  }
41 
42  auto const trimmed_key = detail::strip_first_containing_name(key());
43  return pset_->get_if_present<T>(trimmed_key);
44  }
std::string strip_first_containing_name(std::string const &key)
std::string const & key() const
Definition: ParameterBase.cc:6
template<typename T >
bool fhicl::OptionalDelegatedParameter::get_if_present ( T &  t) const
inline

Definition at line 49 of file OptionalDelegatedParameter.h.

50  {
51  if (auto result = get_if_present<T>()) {
52  t = *result;
53  return true;
54  }
55  return false;
56  }
bool fhicl::OptionalDelegatedParameter::hasValue ( ) const
inline

Definition at line 28 of file OptionalDelegatedParameter.h.

References fhicl::detail::ParameterBase::key(), pset_, and fhicl::detail::strip_first_containing_name().

Referenced by opdet::HitAlgoMakerToolBase< HitAlgoClass >::makeAlgo().

29  {
30  return pset_ &&
32  }
std::string strip_first_containing_name(std::string const &key)
std::string const & key() const
Definition: ParameterBase.cc:6
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(), get_if_present(), 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
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

Member Data Documentation

std::optional<ParameterSet> fhicl::OptionalDelegatedParameter::pset_ {std::nullopt}
private

Definition at line 65 of file OptionalDelegatedParameter.h.

Referenced by do_set_value(), get_if_present(), and hasValue().


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