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