LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DatabaseSupport.cc
Go to the documentation of this file.
2 
3 #include "cetlib/filepath_maker.h"
6 
7 void
8 fhicl::decompose_fhicl(std::string const& filename,
9  std::vector<std::string>& records,
10  std::vector<std::string>& hashes)
11 {
12  // Parse file into a ParameterSet.
13  cet::filepath_maker fpm;
14  auto const top = ParameterSet::make(filename, fpm);
15  decompose_parameterset(top, records, hashes);
16 }
17 
18 void
20  std::vector<std::string>& records,
21  std::vector<std::string>& hashes)
22 {
23  assert(records.size() == hashes.size());
24 
25  // First handle the top-level ParameterSet
26  records.push_back(top.to_compact_string());
27  hashes.push_back(top.id().to_string());
28 
29  // Recurse through all parameters, dealing with ParameterSets and
30  // vectors thereof.
31  std::vector<std::string> keys = top.get_names();
32  for (auto const& key : keys) {
33  if (top.is_key_to_table(key))
34  decompose_parameterset(top.get<ParameterSet>(key), records, hashes);
35  else if (top.is_key_to_sequence(key)) {
36  try {
37  auto nestlings = top.get<std::vector<ParameterSet>>(key);
38  for (auto const& ps : nestlings)
39  decompose_parameterset(ps, records, hashes);
40  }
41  catch (fhicl::exception const&) {
42  // The vector didn't contain ParameterSets, keep going; no
43  // corrective action is needed.
44  }
45  }
46  }
47 }
48 
49 void
50 fhicl::parse_file_and_fill_db(std::string const& filename, sqlite3* out)
51 {
52  cet::filepath_maker fpm;
53  auto const top = ParameterSet::make(filename, fpm);
56 }
std::string to_string() const
static ParameterSetID const & put(ParameterSet const &ps)
std::unique_ptr< InputSource > make(fhicl::ParameterSet const &conf, InputSourceDescription &desc)
void parse_file_and_fill_db(std::string const &filename, sqlite3 *db)
void decompose_parameterset(fhicl::ParameterSet const &top, std::vector< std::string > &records, std::vector< std::string > &hashes)
bool is_key_to_sequence(std::string const &key) const
Definition: ParameterSet.h:214
bool is_key_to_table(std::string const &key) const
Definition: ParameterSet.h:208
T get(std::string const &key) const
Definition: ParameterSet.h:314
std::string to_compact_string() const
Definition: ParameterSet.h:202
ParameterSetID id() const
std::vector< std::string > get_names() const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
static void exportTo(sqlite3 *db)
void decompose_fhicl(std::string const &filename, std::vector< std::string > &records, std::vector< std::string > &hashes)