LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
make_ParameterSet.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // make_ParameterSet - intermediate_table -> ParameterSet
4 //
5 // ======================================================================
6 
8 
9 #include "boost/any.hpp"
10 #include "cetlib/includer.h"
11 #include "fhiclcpp/ParameterSet.h"
13 #include "fhiclcpp/exception.h"
16 #include "fhiclcpp/parse.h"
17 
18 using namespace fhicl;
19 
24 
25 using ps_atom_t = ParameterSet::ps_atom_t; // same as atom_t!
27 
28 // ----------------------------------------------------------------------
29 
30 void
32 {
33  for (auto const& pr : tbl) {
34  if (!pr.second.in_prolog)
35  ps.put(pr.first, pr.second);
36  }
37 }
38 
39 // ----------------------------------------------------------------------
40 
41 void
43 {
44  if (!xval.is_a(TABLE))
45  throw fhicl::exception(type_mismatch, "extended value not a table");
46 
47  table_t const& tbl = table_t(xval);
48  for (auto const& pr : tbl) {
49  if (!pr.second.in_prolog)
50  ps.put(pr.first, pr.second);
51  }
52 }
53 
54 // ----------------------------------------------------------------------
55 
56 void
57 fhicl::make_ParameterSet(std::string const& str, ParameterSet& ps)
58 {
60  parse_document(str, tbl);
61  make_ParameterSet(tbl, ps);
62 }
63 
64 // ----------------------------------------------------------------------
65 
66 void
67 fhicl::make_ParameterSet(std::string const& filename,
68  cet::filepath_maker& maker,
69  ParameterSet& ps)
70 {
72  parse_document(filename, maker, tbl);
73  make_ParameterSet(tbl, ps);
74 }
75 
76 // ======================================================================
intermediate_table::complex_t complex_t
intermediate_table::table_t table_t
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
extended_value::table_t table_t
extended_value::atom_t atom_t
extended_value::complex_t complex_t
extended_value::sequence_t sequence_t
parameter set interface
fhicl::detail::ps_atom_t ps_atom_t
Definition: ParameterSet.h:36
bool is_a(value_tag t) const
fhicl::detail::ps_sequence_t ps_sequence_t
Definition: ParameterSet.h:37
ParameterSet::ps_atom_t ps_atom_t
fhicl::extended_value::sequence_t sequence_t
intermediate_table::atom_t atom_t
ParameterSet::ps_sequence_t ps_sequence_t
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void parse_document(std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)
Definition: parse.cc:856