-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
ProducerBase.h
111 lines (93 loc) · 3.36 KB
/
ProducerBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef FWCore_Framework_ProducerBase_h
#define FWCore_Framework_ProducerBase_h
/*----------------------------------------------------------------------
EDProducer: The base class of all "modules" that will insert new
EDProducts into an Event.
----------------------------------------------------------------------*/
#include "FWCore/Framework/interface/ProductRegistryHelper.h"
#include "FWCore/Utilities/interface/ProductResolverIndex.h"
#include <functional>
#include <unordered_map>
#include <string>
#include <vector>
#include <array>
namespace edm {
class BranchDescription;
class ModuleDescription;
class ProductRegistry;
class Event;
class LuminosityBlock;
class Run;
class EDProducer;
class EDFilter;
namespace one {
class EDProducerBase;
class EDFilterBase;
}
namespace global {
class EDProducerBase;
class EDFilterBase;
}
namespace limited {
class EDProducerBase;
class EDFilterBase;
}
namespace stream {
template<typename T> class ProducingModuleAdaptorBase;
}
namespace producerbasehelper{
template<typename P> struct PrincipalTraits;
template<> struct PrincipalTraits<Run> {
static constexpr int kBranchType = InRun;
};
template<> struct PrincipalTraits<LuminosityBlock> {
static constexpr int kBranchType = InLumi;
};
template<> struct PrincipalTraits<Event> {
static constexpr int kBranchType = InEvent;
};
}
class ProducerBase : private ProductRegistryHelper {
public:
typedef ProductRegistryHelper::TypeLabelList TypeLabelList;
ProducerBase ();
virtual ~ProducerBase() noexcept(false);
/// used by the fwk to register list of products
std::function<void(BranchDescription const&)> registrationCallback() const;
void registerProducts(ProducerBase*,
ProductRegistry*,
ModuleDescription const&);
using ProductRegistryHelper::produces;
using ProductRegistryHelper::typeLabelList;
void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func) {
callWhenNewProductsRegistered_ = func;
}
void resolvePutIndicies(BranchType iBranchType,
std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
std::string const& moduleLabel);
std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const {
return putIndicies_[iBranchType];
}
private:
friend class EDProducer;
friend class EDFilter;
friend class one::EDProducerBase;
friend class one::EDFilterBase;
friend class global::EDProducerBase;
friend class global::EDFilterBase;
friend class limited::EDProducerBase;
friend class limited::EDFilterBase;
template<typename T> friend class stream::ProducingModuleAdaptorBase;
template< typename P>
void commit_(P& iPrincipal) {
iPrincipal.commit_(putIndicies_[producerbasehelper::PrincipalTraits<P>::kBranchType]);
}
template< typename P, typename L, typename I>
void commit_(P& iPrincipal, L* iList, I* iID) {
iPrincipal.commit_(putIndicies_[producerbasehelper::PrincipalTraits<P>::kBranchType], iList,iID);
}
std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
std::array<std::vector<edm::ProductResolverIndex>, edm::NumBranchTypes> putIndicies_;
};
}
#endif