VarExtractorBase.cxx
Go to the documentation of this file.
1 #include "VarExtractorBase.h"
2 #include "utils.h"
3 
4 namespace VLN {
5 
7  const std::string &prefix,
8  const std::vector<std::string> &scalarVars,
9  const std::vector<std::string> &vectorVars
10 ) : prefix(prefix), scalarVars(scalarVars), vectorVars(vectorVars)
11 { }
12 
14  VarDict &vars, const std::string &name, double value
15 ) const
16 {
17  vars.scalar[prefix + name] = value;
18 }
19 
21  VarDict &vars, const std::string &name, double value
22 ) const
23 {
24  vars.vector[prefix + name].push_back(value);
25 }
26 
28  VarDict &vars, const std::vector<std::string> &names
29 ) const
30 {
31  for (auto &name : names) {
32  vars.scalar[prefix + name] = -1;
33  }
34 }
35 
37  VarDict &vars, const std::vector<std::string> &names
38 ) const
39 {
40  for (auto &name : names) {
41  const std::string fullname = prefix + name;
42 
43  auto it = vars.vector.find(fullname);
44 
45  if (it != vars.vector.end()) {
46  it->second.clear();
47  }
48  else {
49  vars.vector[fullname] = {};
50  }
51  }
52 }
53 
55 {
58 
59  extractVars(evt, vars);
60 }
61 
62 }
63 
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
virtual void extractVars(const art::Event &evt, VarDict &vars)=0
Definition: VarDict.h:8
virtual void extract(const art::Event &evt, VarDict &vars)
std::vector< std::string > vectorVars
std::unordered_map< std::string, std::vector< double > > vector
Definition: VarDict.h:11
void appendToVectorVar(VarDict &vars, const std::string &name, double value) const
Definition: utils.cxx:6
std::vector< std::string > scalarVars
void setScalarVar(VarDict &vars, const std::string &name, double value) const
void initScalarVars(VarDict &vars, const std::vector< std::string > &names) const
void initVectorVars(VarDict &vars, const std::vector< std::string > &names) const
VarExtractorBase(const std::string &prefix, const std::vector< std::string > &scalarVars, const std::vector< std::string > &vectorVars)
TCEvent evt
Definition: DataStructs.cxx:7
static std::vector< std::string > const names
Definition: FragmentType.hh:8
std::unordered_map< std::string, double > scalar
Definition: VarDict.h:10