Public Member Functions | Private Attributes | List of all members
WireCell::tagrules::Context Class Reference

#include <TagRules.h>

Public Member Functions

void configure (const Configuration &cfg)
 
tagset_t transform (size_t ind, const std::string &name, const tag_t &tag)
 
template<typename Tags >
Tags transform (size_t ind, const std::string &name, const Tags &tags)
 

Private Attributes

std::unordered_map< std::string, std::vector< ruleset_t > > m_rulesets
 

Detailed Description

Definition at line 69 of file TagRules.h.

Member Function Documentation

void tagrules::Context::configure ( const Configuration cfg)

Definition at line 61 of file TagRules.cxx.

62 {
63  if (jcfg.empty() or !jcfg.isArray()) {
64  return;
65  }
66 
67  const int nrss = jcfg.size();
68 
69  // Note: JSON is in name-major order, C++ index-major.
70  for (int ind=0; ind<nrss; ++ind) {
71  auto jone = jcfg[ind];
72  for (auto name : jone.getMemberNames()) {
73  auto& rsv = m_rulesets[name]; // eg, "frame" or "trace"
74  rsv.resize(nrss);
75  rsv[ind] = convert<tagrules::ruleset_t>(jone[name]);
76  }
77  }
78 }
static QCString name
Definition: declinfo.cpp:673
std::unordered_map< std::string, std::vector< ruleset_t > > m_rulesets
Definition: TagRules.h:71
tagrules::tagset_t tagrules::Context::transform ( size_t  ind,
const std::string name,
const tag_t tag 
)

Definition at line 80 of file TagRules.cxx.

82 {
83  const auto& rsv = m_rulesets[name];
84  if (rsv.empty() or ind >= rsv.size()) {
85  return tagrules::tagset_t{};
86  }
87  const auto& rs = rsv[ind];
89  ts.insert(tag);
90  return tagrules::transform(ts, rs);
91 }
static QCString name
Definition: declinfo.cpp:673
std::unordered_set< tag_t > tagset_t
Definition: TagRules.h:48
tagset_t transform(const tagset_t &ts, const ruleset_t &rs, bool all_rules=true)
Definition: TagRules.cxx:43
std::unordered_map< std::string, std::vector< ruleset_t > > m_rulesets
Definition: TagRules.h:71
template<typename Tags >
Tags WireCell::tagrules::Context::transform ( size_t  ind,
const std::string name,
const Tags &  tags 
)
inline

Definition at line 83 of file TagRules.h.

83  {
84  const auto& rsv = m_rulesets[name];
85  if (rsv.empty() or ind >= rsv.size()) {
86  return Tags();
87  }
88  tagrules::tagset_t ts(tags.begin(), tags.end());
89  const auto& rs = rsv[ind];
90  auto out = tagrules::transform(ts, rs);
91  return Tags(out.begin(), out.end());
92  }
static QCString name
Definition: declinfo.cpp:673
std::unordered_set< tag_t > tagset_t
Definition: TagRules.h:48
tagset_t transform(const tagset_t &ts, const ruleset_t &rs, bool all_rules=true)
Definition: TagRules.cxx:43
std::unordered_map< std::string, std::vector< ruleset_t > > m_rulesets
Definition: TagRules.h:71

Member Data Documentation

std::unordered_map< std::string, std::vector<ruleset_t> > WireCell::tagrules::Context::m_rulesets
private

Definition at line 71 of file TagRules.h.


The documentation for this class was generated from the following files: