1 #include "fhiclcpp/detail/printing_helpers.h"
2 #include "fhiclcpp/types/detail/strip_containing_names.h"
7 Atom<T>::Atom(Name&& name,
9 : AtomBase{std::move(name), std::move(comment), par_style::REQUIRED, detail::AlwaysUse()}
10 , RegisterIfTableMember{this}
11 , value_{std::make_shared<T>()}
13 NameStackRegistry::end_of_ctor();
17 Atom<T>::Atom(Name&& name,
19 std::function<bool()> maybeUse)
20 : AtomBase{std::move(name), std::move(comment), par_style::REQUIRED_CONDITIONAL, maybeUse}
21 , RegisterIfTableMember{this}
22 , value_{std::make_shared<T>()}
24 NameStackRegistry::end_of_ctor();
28 Atom<T>::Atom(Name&& name,
31 : AtomBase{std::move(name), std::move(comment), par_style::DEFAULT, detail::AlwaysUse()}
32 , RegisterIfTableMember{this}
33 , value_{std::make_shared<T>(dflt_value)}
35 NameStackRegistry::end_of_ctor();
39 Atom<T>::Atom(Name&& name,
41 std::function<bool()> maybeUse,
43 : AtomBase{std::move(name), std::move(comment), par_style::DEFAULT_CONDITIONAL, maybeUse}
44 , RegisterIfTableMember{this}
45 , value_{std::make_shared<T>(dflt_value)}
47 NameStackRegistry::end_of_ctor();
51 Atom<T>::Atom(Name&& name)
52 : Atom{std::move(name), Comment("")}
56 Atom<T>::Atom(Name&& name, T const& dflt_value)
57 : Atom{std::move(name), Comment(""), dflt_value}
62 Atom<T>::get_stringified_value() const
64 std::stringstream oss;
66 using namespace detail::yes_defaults;
67 oss << maybe_quotes<T>(*value_) ;
70 using namespace detail::no_defaults;
71 oss << expected_types<T>();
78 Atom<T>::do_set_value(fhicl::ParameterSet const& pset, bool const trimParent)
80 std::string const& rkey = key();
81 std::string const& key = trimParent ? detail::strip_first_containing_name(rkey) : rkey;
84 pset.get_if_present<T>(key, *value_);
86 value_ = std::make_shared<T>(pset.get<T>(key));