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 ProducesCollector;
24  class ProductRegistry;
25  class Event;
26  class LuminosityBlock;
27  class Run;
28 
29  class EDProducer;
30  class EDFilter;
31  namespace one {
32  class EDProducerBase;
33  class EDFilterBase;
34  } // namespace one
35  namespace global {
36  class EDProducerBase;
37  class EDFilterBase;
38  } // namespace global
39  namespace limited {
40  class EDProducerBase;
41  class EDFilterBase;
42  } // namespace limited
43  namespace stream {
44  template <typename T>
45  class ProducingModuleAdaptorBase;
46  }
47 
48  namespace producerbasehelper {
49  template <typename P>
51  template <>
52  struct PrincipalTraits<Run> {
53  static constexpr int kBranchType = InRun;
54  };
55  template <>
57  static constexpr int kBranchType = InLumi;
58  };
59  template <>
61  static constexpr int kBranchType = InEvent;
62  };
63  } // namespace producerbasehelper
64 
66  public:
68  ProducerBase();
69  ~ProducerBase() noexcept(false) override;
70 
72  std::function<void(BranchDescription const&)> registrationCallback() const;
73 
74  void registerProducts(ProducerBase*, ProductRegistry*, ModuleDescription const&);
75 
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  protected:
98  ProducesCollector producesCollector();
100 
101  private:
102  friend class EDProducer;
103  friend class EDFilter;
104  friend class one::EDProducerBase;
105  friend class one::EDFilterBase;
107  friend class global::EDFilterBase;
109  friend class limited::EDFilterBase;
110  friend class PuttableSourceBase;
111  template <typename T>
113 
114  template <typename P>
115  void commit_(P& iPrincipal) {
116  iPrincipal.commit_(putIndicies_[producerbasehelper::PrincipalTraits<P>::kBranchType]);
117  }
118 
119  template <typename P, typename I>
120  void commit_(P& iPrincipal, I* iID) {
121  iPrincipal.commit_(putIndicies_[producerbasehelper::PrincipalTraits<P>::kBranchType], iID);
122  }
123 
124  std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
125  std::array<std::vector<edm::ProductResolverIndex>, edm::NumBranchTypes> putIndicies_;
126  std::vector<edm::ProductResolverIndex> putTokenToResolverIndex_;
127  };
128 } // namespace edm
129 #endif
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
void commit_(P &iPrincipal, I *iID)
Definition: ProducerBase.h:120
Definition: vlib.h:246
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:67
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex() const
Definition: ProducerBase.h:93
std::function< void(BranchDescription const &)> callWhenNewProductsRegistered_
Definition: ProducerBase.h:124
std::array< std::vector< edm::ProductResolverIndex >, edm::NumBranchTypes > putIndicies_
Definition: ProducerBase.h:125
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:126
#define noexcept
std::pair< OmniClusterRef, TrackingParticleRef > P
HLT enums.
void commit_(P &iPrincipal)
Definition: ProducerBase.h:115
#define constexpr
Definition: Run.h:45