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>
16 
17 namespace edm {
18 
19  class BranchDescription;
20  class EDConsumerBase;
21 
22  template<typename T>
23  class WillGetIfMatch {
24  public:
25 
26  template <typename U>
28  match_(match),
29  module_(module) {
30  }
31 
32  EDGetTokenT<T> operator()(BranchDescription const& branchDescription) {
33  if (match_(branchDescription)){
34  auto transition = branchDescription.branchType();
35  edm::InputTag tag{branchDescription.moduleLabel(),
36  branchDescription.productInstanceName(),
37  branchDescription.processName()};
38  if(transition == edm::InEvent) {
39  return module_->template consumes<T>(tag);
40  } else if(transition == edm::InLumi) {
41  return module_->template consumes<T,edm::InLumi>(tag);
42  } else if(transition == edm::InRun) {
43  return module_->template consumes<T,edm::InRun>(tag);
44  }
45  }
46  return EDGetTokenT<T>{};
47  }
48 
49  private:
50  std::function<bool(BranchDescription const&)> match_;
52  };
53 }
54 #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)