LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ParameterBase.h
Go to the documentation of this file.
1 #ifndef fhiclcpp_types_detail_ParameterBase_h
2 #define fhiclcpp_types_detail_ParameterBase_h
3 
4 // clang-format off
5 /*
6  ParameterBase is the most fundamental base class for all fhiclcpp
7  types. The taxonomy is:
8 
9  ParameterBase
10  / | \ \____________________________________
11  / | \___________________ \
12  / | \ \
13  / | \ \
14  AtomBase TableBase SequenceBase DelegateBase
15  | | / | \ \
16  | | / | \ \
17  Atom<T> Table<T> Sequence<T,SZ> Sequence<T> Tuple<T...> DelegatedParameter
18 
19 
20  All concrete Optional* fhiclcpp types also inherit from the
21  corresponding base classes (e.g. OptionalAtom<T> inherits from
22  AtomBase, not OptionalAtomBase). The design is meant to closely
23  follow the classification of FHiCL values, as described in the FHiCL
24  language quick start guide.
25 */
26 // clang-format on
27 
28 #include "fhiclcpp/fwd.h"
32 
33 namespace fhicl::detail {
34 
35  //========================================================
36  class ParameterBase {
37  public:
38  ParameterBase(Name const& name,
39  Comment const& comment,
40  par_style const vt,
41  par_type const type,
42  std::function<bool()> maybeUse = AlwaysUse());
43  virtual ~ParameterBase();
44 
45  std::string const& key() const;
46  std::string const& name() const;
47  std::string const& comment() const;
48  bool has_default() const;
49  bool is_optional() const;
50  bool is_conditional() const;
51  par_type parameter_type() const;
52  bool should_use() const;
53 
54  // Modifiers
55  void set_value(fhicl::ParameterSet const& ps);
56  bool preset_value(fhicl::ParameterSet const& ps);
57  void set_par_style(par_style const vt);
58 
59  private:
60  virtual bool do_preset_value(fhicl::ParameterSet const&);
61  virtual void do_set_value(fhicl::ParameterSet const&) = 0;
62 
64  std::function<bool()> maybeUse_;
65  };
66 }
67 
68 #endif /* fhiclcpp_types_detail_ParameterBase_h */
69 
70 // Local variables:
71 // mode: c++
72 // End:
void set_value(fhicl::ParameterSet const &ps)
bool preset_value(fhicl::ParameterSet const &ps)
ParameterBase(Name const &name, Comment const &comment, par_style const vt, par_type const type, std::function< bool()> maybeUse=AlwaysUse())
std::function< bool()> AlwaysUse()
virtual void do_set_value(fhicl::ParameterSet const &)=0
ParameterMetadata mdata_
Definition: ParameterBase.h:63
par_type parameter_type() const
std::string const & name() const
std::string const & key() const
Definition: ParameterBase.cc:6
std::function< bool()> maybeUse_
Definition: ParameterBase.h:64
std::string const & comment() const
virtual bool do_preset_value(fhicl::ParameterSet const &)
void set_par_style(par_style const vt)