Public Member Functions | Private Member Functions | Private Attributes | List of all members
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
 
- Public Member Functions inherited from fhicl::detail::DelegateBase
 DelegateBase (Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
 
- 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 Member Functions

void do_set_value (fhicl::ParameterSet const &pset) override
 
- Private Member Functions inherited from fhicl::detail::RegisterIfTableMember
 RegisterIfTableMember (ParameterBase *pb)
 

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.

9  {}
std::string const & name() const
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
#define Comment
fhicl::OptionalDelegatedParameter::OptionalDelegatedParameter ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 11 of file OptionalDelegatedParameter.cc.

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::string const & name() const
Definition: ParameterBase.h:43
std::function< bool()> AlwaysUse()
def move(depos, offset)
Definition: depos.py:107
std::string const & comment() const
Definition: ParameterBase.h:48
fhicl::OptionalDelegatedParameter::OptionalDelegatedParameter ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 22 of file OptionalDelegatedParameter.cc.

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
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
std::string const & comment() const
Definition: ParameterBase.h:48

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.

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.

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.h:38
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  }
static QCString result
bool fhicl::OptionalDelegatedParameter::hasValue ( ) const
inline

Definition at line 28 of file OptionalDelegatedParameter.h.

29  {
30  return pset_ &&
32  }
std::string strip_first_containing_name(std::string const &key)
std::string const & key() const
Definition: ParameterBase.h:38

Member Data Documentation

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

Definition at line 65 of file OptionalDelegatedParameter.h.


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