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  }
34  namespace global {
35  class EDProducerBase;
36  class EDFilterBase;
37  }
38  namespace stream {
39  template<typename T> class ProducingModuleAdaptorBase;
40  }
41 
42  namespace producerbasehelper{
43  template<typename P> struct PrincipalTraits;
44  template<> struct PrincipalTraits<Run> {
45  static constexpr int kBranchType = InRun;
46  };
47  template<> struct PrincipalTraits<LuminosityBlock> {
48  static constexpr int kBranchType = InLumi;
49  };
50  template<> struct PrincipalTraits<Event> {
51  static constexpr int kBranchType = InEvent;
52  };
53  }
54 
56  public:
58  ProducerBase ();
59  virtual ~ProducerBase() noexcept(false);
60 
62  std::function<void(BranchDescription const&)> registrationCallback() const;
63 
64  void registerProducts(ProducerBase*,
66  ModuleDescription const&);
67 
68  using ProductRegistryHelper::produces;
69  using ProductRegistryHelper::typeLabelList;
70 
71  void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func) {
72  callWhenNewProductsRegistered_ = func;
73  }
74 
75  void resolvePutIndicies(BranchType iBranchType,
76  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
77  std::string const& moduleLabel);
78 
79  std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const {
80  return putIndicies_[iBranchType];
81  }
82  private:
83  friend class EDProducer;
84  friend class EDFilter;
85  friend class one::EDProducerBase;
86  friend class one::EDFilterBase;
87  friend class global::EDProducerBase;
88  friend class global::EDFilterBase;
89  template<typename T> friend class stream::ProducingModuleAdaptorBase;
90 
91  template< typename P>
92  void commit_(P& iPrincipal) {
93  iPrincipal.commit_(putIndicies_[producerbasehelper::PrincipalTraits<P>::kBranchType]);
94  }
95 
96  template< typename P, typename L, typename I>
97  void commit_(P& iPrincipal, L* iList, I* iID) {
98  iPrincipal.commit_(putIndicies_[producerbasehelper::PrincipalTraits<P>::kBranchType], iList,iID);
99  }
100 
101  std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
102  std::array<std::vector<edm::ProductResolverIndex>, edm::NumBranchTypes> putIndicies_;
103  };
104 }
105 #endif
std::list< TypeLabelItem > TypeLabelList
ProductRegistryHelper::TypeLabelList TypeLabelList
Definition: ProducerBase.h:57
#define noexcept
std::function< void(BranchDescription const &)> callWhenNewProductsRegistered_
Definition: ProducerBase.h:101
std::array< std::vector< edm::ProductResolverIndex >, edm::NumBranchTypes > putIndicies_
Definition: ProducerBase.h:102
#define constexpr
BranchType
Definition: BranchType.h:11
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducerBase.h:79
const std::complex< double > I
Definition: I.h:8
std::pair< OmniClusterRef, TrackingParticleRef > P
HLT enums.
void commit_(P &iPrincipal, L *iList, I *iID)
Definition: ProducerBase.h:97
void commit_(P &iPrincipal)
Definition: ProducerBase.h:92
Definition: Run.h:42