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

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

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.

122  : Atom{std::move(name), Comment("")}
123  {}
std::string const & name() const
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
Atom(Name &&name)
Definition: Atom.h:122
#define Comment
template<typename T >
fhicl::Atom< T >::Atom ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 73 of file Atom.h.

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

Definition at line 84 of file Atom.h.

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

Definition at line 126 of file Atom.h.

127  : Atom{std::move(name), Comment(""), dflt_value}
128  {}
std::string const & name() const
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
Atom(Name &&name)
Definition: Atom.h:122
#define Comment
template<typename T>
fhicl::Atom< T >::Atom ( Name &&  name,
Comment &&  comment,
T const &  dflt_value 
)
explicit

Definition at line 95 of file Atom.h.

100  , RegisterIfTableMember{this}
101  , value_{dflt_value}
102  {
104  }
std::string const & name() const
Definition: ParameterBase.h:43
AtomBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: AtomBase.h:10
std::function< bool()> AlwaysUse()
def move(depos, offset)
Definition: depos.py:107
value_type value_
Definition: Atom.h:59
std::string const & comment() const
Definition: ParameterBase.h:48
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.

114  maybeUse}
115  , RegisterIfTableMember{this}
116  , value_{dflt_value}
117  {
119  }
std::string const & name() const
Definition: ParameterBase.h:43
AtomBase(Name const &name, Comment const &comment, par_style const vt, std::function< bool()> maybeUse)
Definition: AtomBase.h:10
def move(depos, offset)
Definition: depos.py:107
value_type value_
Definition: Atom.h:59
std::string const & comment() const
Definition: ParameterBase.h:48

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.

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  }
154  else
155  value_ = pset.get<T>(trimmed_key);
156  }
std::string strip_first_containing_name(std::string const &key)
value_type value_
Definition: Atom.h:59
std::string const & key() const
Definition: ParameterBase.h:38
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.

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
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

Member Data Documentation

template<typename T>
value_type fhicl::Atom< T >::value_ {}
private

Definition at line 59 of file Atom.h.


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