DatabaseSupport.cc
Go to the documentation of this file.
2 
6 
7 void
9  std::vector<std::string>& records,
10  std::vector<std::string>& hashes)
11 {
12  // Parse file into a ParameterSet.
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
51 {
53  auto const top = ParameterSet::make(filename, fpm);
56 }
std::string to_string() const
static ParameterSetID const & put(ParameterSet const &ps)
std::string string
Definition: nybbler.cc:12
string filename
Definition: train.py:213
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:171
bool is_key_to_table(std::string const &key) const
Definition: ParameterSet.h:165
def key(type, name=None)
Definition: graph.py:13
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::string to_compact_string() const
Definition: ParameterSet.h:159
static constexpr double ps
Definition: Units.h:99
ParameterSetID id() const
struct sqlite3 sqlite3
unique_ptr< InputSource > make(ParameterSet const &conf, InputSourceDescription &desc)
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)