CMS 3D CMS Logo

ProducerBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ProducerBase_h
2 #define FWCore_Framework_ProducerBase_h
3 
4 /*----------------------------------------------------------------------
5 
6 EDProducer: The base class of all "modules" that will insert new
7 EDProducts into an Event.
8 
9 ----------------------------------------------------------------------*/
10 
13 
14 #include <functional>
15 #include <unordered_map>
16 #include <string>
17 #include <vector>
18 #include <array>
19 
20 namespace edm {
21  class BranchDescription;
22  class ModuleDescription;
23  class ProductRegistry;
24  class Event;
25  class LuminosityBlock;
26  class Run;
27 
28  class EDProducer;
29  class EDFilter;
30  namespace one {
31  class EDProducerBase;
32  class EDFilterBase;
33  } // namespace one
34  namespace global {
35  class EDProducerBase;
36  class EDFilterBase;
37  } // namespace global
38  namespace limited {
39  class EDProducerBase;
40  class EDFilterBase;
41  } // namespace limited
42  namespace stream {
43  template <typename T>
44  class ProducingModuleAdaptorBase;
45  }
46 
47  namespace producerbasehelper {
48  template <typename P>
50  template <>
51  struct PrincipalTraits<Run> {
52  static constexpr int kBranchType = InRun;
53  };
54  template <>
56  static constexpr int kBranchType = InLumi;
57  };
58  template <>
60  static constexpr int kBranchType = InEvent;
61  };
62  } // namespace producerbasehelper
63 
65  public:
67  ProducerBase();
68  ~ProducerBase() noexcept(false) override;
69 
71  std::function<void(BranchDescription const&)> registrationCallback() const;
72 
73  void registerProducts(ProducerBase*, ProductRegistry*, ModuleDescription const&);
74 
75  using ProductRegistryHelper::produces;
76  using ProductRegistryHelper::recordProvenanceList;
77  using ProductRegistryHelper::typeLabelList;
78 
79  void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func) {
80  callWhenNewProductsRegistered_ = func;
81  }
82 
84  std::unordered_multimap<std::string, std::tuple<edm::TypeID const*, const char*, edm::ProductResolverIndex>>;
85  void resolvePutIndicies(BranchType iBranchType,
86  ModuleToResolverIndicies const& iIndicies,
87  std::string const& moduleLabel);
88 
89  std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const {
90  return putIndicies_[iBranchType];
91  }
92 
93  std::vector<edm::ProductResolverIndex> const& putTokenIndexToProductResolverIndex() const {
94  return putTokenToResolverIndex_;
95  }
96 
97  private:
98  friend class EDProducer;
99  friend class EDFilter;
100  friend class one::EDProducerBase;
101  friend class one::EDFilterBase;
103  friend class global::EDFilterBase;
105  friend class limited::EDFilterBase;
106  friend class PuttableSourceBase;
107  template <typename T>
109 
110  template <typename P>
111  void commit_(P& iPrincipal) {
112  iPrincipal.commit_(putIndicies_[producerbasehelper::PrincipalTraits<P>::kBranchType]);
113  }
114 
115  template <typename P, typename I>
116  void commit_(P& iPrincipal, I* iID) {
117  iPrincipal.commit_(putIndicies_[producerbasehelper::PrincipalTraits<P>::kBranchType], iID);
118  }
119 
120  std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
121  std::array<std::vector<edm::ProductResolverIndex>, edm::NumBranchTypes> putIndicies_;
122  std::vector<edm::ProductResolverIndex> putTokenToResolverIndex_;
123  };
124 } // namespace edm
125 #endif
void commit_(P &iPrincipal, I *iID)
Definition: ProducerBase.h:116
std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >> ModuleToResolverIndicies
Definition: ProducerBase.h:84
ProductRegistryHelper::TypeLabelList TypeLabelList
Definition: ProducerBase.h:66
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex() const
Definition: ProducerBase.h:93
std::function< void(BranchDescription const &)> callWhenNewProductsRegistered_
Definition: ProducerBase.h:120
std::array< std::vector< edm::ProductResolverIndex >, edm::NumBranchTypes > putIndicies_
Definition: ProducerBase.h:121
BranchType
Definition: BranchType.h:11
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducerBase.h:89
std::vector< TypeLabelItem > TypeLabelList
const std::complex< double > I
Definition: I.h:8
std::vector< edm::ProductResolverIndex > putTokenToResolverIndex_
Definition: ProducerBase.h:122
#define noexcept
std::pair< OmniClusterRef, TrackingParticleRef > P
HLT enums.
void commit_(P &iPrincipal)
Definition: ProducerBase.h:111
#define constexpr
Definition: Run.h:45