CMS 3D CMS Logo

WillGetIfMatch.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WillGetIfMatch_h
2 #define FWCore_Framework_WillGetIfMatch_h
3 
13 #include <functional>
18 
19 namespace edm {
20 
21  template <typename T>
22  class WillGetIfMatch {
23  public:
24  template <typename U>
25  WillGetIfMatch(U const& match, EDConsumerBase* module) : match_(match), module_(module) {}
26 
27  EDGetTokenT<T> operator()(BranchDescription const& branchDescription) {
28  if (match_(branchDescription)) {
29  auto transition = branchDescription.branchType();
31  branchDescription.moduleLabel(), branchDescription.productInstanceName(), branchDescription.processName()};
32  if (transition == edm::InEvent) {
33  return module_->template consumes<T>(tag);
34  } else if (transition == edm::InLumi) {
35  return module_->template consumes<T, edm::InLumi>(tag);
36  } else if (transition == edm::InRun) {
37  return module_->template consumes<T, edm::InRun>(tag);
38  }
39  }
40  return EDGetTokenT<T>{};
41  }
42 
43  private:
44  std::function<bool(BranchDescription const&)> match_;
46  };
47 } // namespace edm
48 #endif
BranchType const & branchType() const
std::string const & processName() const
WillGetIfMatch(U const &match, EDConsumerBase *module)
std::string const & moduleLabel() const
std::string const & productInstanceName() const
EDConsumerBase * module_
std::function< bool(BranchDescription const &)> match_
HLT enums.
EDGetTokenT< T > operator()(BranchDescription const &branchDescription)
Definition: vlib.h:208
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)