CMS 3D CMS Logo

ProductRegistryHelper.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ProductRegistryHelper_h
2 #define FWCore_Framework_ProductRegistryHelper_h
3 
4 /*----------------------------------------------------------------------
5 
6 ProductRegistryHelper:
7 
8 ----------------------------------------------------------------------*/
9 
14 #include <string>
15 #include <vector>
16 #include <type_traits>
17 
18 namespace edm {
19  class ModuleDescription;
20  class ProductRegistry;
21  struct DoNotRecordParents;
22 
24  public:
25  virtual ~ProductRegistryHelper() noexcept(false);
27 
28  // has_donotrecordparents<T>::value is true if we should not
29  // record parentage for type T, and false otherwise.
30  template <typename T>
33  };
34 
35  struct TypeLabelItem {
37 
38  TypeLabelItem(Transition const& transition, TypeID const& tid, std::string pin)
39  : transition_(transition),
40  typeID_(tid),
42  branchAlias_(),
43  aliasType_(AliasType::kBranchAlias) {}
49  };
50 
52  BranchAliasSetter(TypeLabelItem& iItem, EDPutToken iToken) : value_(iItem), token_(iToken) {}
53 
56  return *this;
57  }
61  return *this;
62  }
65 
66  operator EDPutToken() { return token_; }
67  };
68 
69  template <typename T>
71  BranchAliasSetterT(TypeLabelItem& iItem, EDPutTokenT<T> iToken) : value_(iItem), token_(std::move(iToken)) {}
72 
74 
77  return *this;
78  }
81 
82  operator EDPutTokenT<T>() { return token_; }
83  operator EDPutToken() { return EDPutToken(token_.index()); }
84  };
85 
86  typedef std::vector<TypeLabelItem> TypeLabelList;
87 
89  TypeLabelList const& typeLabelList() const;
90 
91  std::vector<bool> const& recordProvenanceList() const { return recordProvenanceList_; }
92 
93  static void addToRegistry(TypeLabelList::const_iterator const& iBegin,
94  TypeLabelList::const_iterator const& iEnd,
95  ModuleDescription const& iDesc,
96  ProductRegistry& iReg,
97  ProductRegistryHelper* iProd,
98  bool iIsListener = false);
99 
101 
107  template <class ProductType>
109  return produces<ProductType, InEvent>(std::string());
110  }
111 
112  template <class ProductType>
114  return produces<ProductType, InEvent>(std::move(instanceName));
115  }
116 
117  template <typename ProductType, BranchType B>
119  return produces<ProductType, B>(std::string());
120  }
121 
122  template <typename ProductType, BranchType B>
124  TypeID tid(typeid(ProductType));
127  }
128 
129  template <typename ProductType, Transition B>
131  return produces<ProductType, B>(std::string());
132  }
133 
134  template <typename ProductType, Transition B>
136  TypeID tid(typeid(ProductType));
137  return BranchAliasSetterT<ProductType>{produces<B>(
139  }
140 
143  bool recordProvenance = true) {
144  return produces<Transition::Event>(id, std::move(instanceName), recordProvenance);
145  }
146 
147  template <BranchType B>
150  bool recordProvenance = true) {
151  unsigned int index = typeLabelList_.size();
153  recordProvenanceList_.push_back(recordProvenance and B == InEvent);
154  return BranchAliasSetter{typeLabelList_.back(), EDPutToken{static_cast<unsigned int>(index)}};
155  }
156  template <Transition B>
159  bool recordProvenance = true) {
160  unsigned int index = typeLabelList_.size();
161  typeLabelList_.emplace_back(B, id, std::move(instanceName));
162  recordProvenanceList_.push_back(recordProvenance and B == Transition::Event);
164  }
165 
166  virtual bool hasAbilityToProduceInBeginProcessBlocks() const { return false; }
167  virtual bool hasAbilityToProduceInEndProcessBlocks() const { return false; }
168 
169  virtual bool hasAbilityToProduceInBeginRuns() const { return false; }
170  virtual bool hasAbilityToProduceInEndRuns() const { return false; }
171 
172  virtual bool hasAbilityToProduceInBeginLumis() const { return false; }
173  virtual bool hasAbilityToProduceInEndLumis() const { return false; }
174 
175  private:
177  std::vector<bool> recordProvenanceList_;
178  };
179 
180 } // namespace edm
181 
182 #endif
edm::ProductRegistryHelper::BranchAliasSetterT::BranchAliasSetterT
BranchAliasSetterT(BranchAliasSetter &&iS)
Definition: ProductRegistryHelper.h:73
edm::ProductRegistryHelper::BranchAliasSetterT
Definition: ProductRegistryHelper.h:70
edm::ProductRegistryHelper::produces
BranchAliasSetter produces(const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
Definition: ProductRegistryHelper.h:148
edm::ProductRegistryHelper::hasAbilityToProduceInEndRuns
virtual bool hasAbilityToProduceInEndRuns() const
Definition: ProductRegistryHelper.h:170
edm::ProductRegistryHelper::hasAbilityToProduceInBeginRuns
virtual bool hasAbilityToProduceInBeginRuns() const
Definition: ProductRegistryHelper.h:169
edm::ProductRegistryHelper::BranchAliasSetter::setBranchAlias
BranchAliasSetter & setBranchAlias(std::string alias)
Definition: ProductRegistryHelper.h:54
edm::ProductRegistryHelper::TypeLabelItem::productInstanceName_
std::string productInstanceName_
Definition: ProductRegistryHelper.h:46
edm::ProductRegistryHelper::produces
BranchAliasSetterT< ProductType > produces(std::string instanceName)
Definition: ProductRegistryHelper.h:113
edm::ProductRegistryHelper::hasAbilityToProduceInBeginLumis
virtual bool hasAbilityToProduceInBeginLumis() const
Definition: ProductRegistryHelper.h:172
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Transition::Event
edm::EDPutTokenT
Definition: EDPutToken.h:33
edm::ProductRegistryHelper::BranchAliasSetter
Definition: ProductRegistryHelper.h:51
edm::ProductRegistryHelper::BranchAliasSetter::token_
EDPutToken token_
Definition: ProductRegistryHelper.h:64
TypeID.h
edm::ProductRegistryHelper::recordProvenanceList_
std::vector< bool > recordProvenanceList_
Definition: ProductRegistryHelper.h:177
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::ProductRegistryHelper::TypeLabelItem::aliasType_
AliasType aliasType_
Definition: ProductRegistryHelper.h:48
edm::ProductRegistryHelper::BranchAliasSetterT::value_
TypeLabelItem & value_
Definition: ProductRegistryHelper.h:79
edm::ProductRegistry
Definition: ProductRegistry.h:37
edm::ProductRegistryHelper::TypeLabelItem::typeID_
TypeID typeID_
Definition: ProductRegistryHelper.h:45
edm::ProductRegistryHelper::TypeLabelItem
Definition: ProductRegistryHelper.h:35
edm::ProductRegistryHelper::hasAbilityToProduceInEndProcessBlocks
virtual bool hasAbilityToProduceInEndProcessBlocks() const
Definition: ProductRegistryHelper.h:167
edm::ProductRegistryHelper::hasAbilityToProduceInBeginProcessBlocks
virtual bool hasAbilityToProduceInBeginProcessBlocks() const
Definition: ProductRegistryHelper.h:166
edm::EDPutToken
Definition: EDPutToken.h:38
edm::ProductRegistryHelper::~ProductRegistryHelper
virtual ~ProductRegistryHelper() noexcept(false)
Definition: ProductRegistryHelper.cc:18
edm::ProductRegistryHelper::BranchAliasSetter::BranchAliasSetter
BranchAliasSetter(TypeLabelItem &iItem, EDPutToken iToken)
Definition: ProductRegistryHelper.h:52
edm::ProductRegistryHelper::produces
BranchAliasSetter produces(const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
Definition: ProductRegistryHelper.h:141
edm::ProductRegistryHelper::hasAbilityToProduceInEndLumis
virtual bool hasAbilityToProduceInEndLumis() const
Definition: ProductRegistryHelper.h:173
edm::InEvent
Definition: BranchType.h:11
Transition.h
edm::ProductRegistryHelper::recordProvenanceList
std::vector< bool > const & recordProvenanceList() const
Definition: ProductRegistryHelper.h:91
edm::ProductRegistryHelper::TypeLabelItem::transition_
Transition transition_
Definition: ProductRegistryHelper.h:44
edm::ProductRegistryHelper::typeLabelList
TypeLabelList const & typeLabelList() const
used by the fwk to register the list of products of this module
Definition: ProductRegistryHelper.cc:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Transition
Transition
Definition: Transition.h:12
EDPutToken.h
edm::ProductRegistryHelper::TypeLabelItem::TypeLabelItem
TypeLabelItem(Transition const &transition, TypeID const &tid, std::string pin)
Definition: ProductRegistryHelper.h:38
edm::ProductRegistryHelper::typeLabelList_
TypeLabelList typeLabelList_
Definition: ProductRegistryHelper.h:176
edm::ProductRegistryHelper::TypeLabelList
std::vector< TypeLabelItem > TypeLabelList
Definition: ProductRegistryHelper.h:86
value
Definition: value.py:1
BranchType.h
edm::ProductRegistryHelper::produces
BranchAliasSetterT< ProductType > produces()
Definition: ProductRegistryHelper.h:118
edm::ProductRegistryHelper::TypeLabelItem::AliasType
AliasType
Definition: ProductRegistryHelper.h:36
edm::ProductRegistryHelper::ProductRegistryHelper
ProductRegistryHelper()
Definition: ProductRegistryHelper.h:26
edm::ProductRegistryHelper::BranchAliasSetter::value_
TypeLabelItem & value_
Definition: ProductRegistryHelper.h:63
edm::ProductRegistryHelper::addToRegistry
static void addToRegistry(TypeLabelList::const_iterator const &iBegin, TypeLabelList::const_iterator const &iEnd, ModuleDescription const &iDesc, ProductRegistry &iReg, ProductRegistryHelper *iProd, bool iIsListener=false)
Definition: ProductRegistryHelper.cc:34
edm::convertToTransition
constexpr Transition convertToTransition(BranchType iValue)
Definition: Transition.h:31
edm::ProductRegistryHelper::BranchAliasSetterT::setBranchAlias
BranchAliasSetterT< T > & setBranchAlias(std::string alias)
Definition: ProductRegistryHelper.h:75
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
edm::TypeID
Definition: TypeID.h:22
edm::ProductRegistryHelper::produces
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
Definition: ProductRegistryHelper.h:108
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::ProductRegistryHelper::TypeLabelItem::branchAlias_
std::string branchAlias_
Definition: ProductRegistryHelper.h:47
relativeConstraints.value
value
Definition: relativeConstraints.py:53
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:128
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::ProductRegistryHelper::TypeLabelItem::AliasType::kSwitchAlias
edm::ProductRegistryHelper::has_donotrecordparents
Definition: ProductRegistryHelper.h:31
edm::ProductRegistryHelper::BranchAliasSetter::setSwitchAlias
BranchAliasSetter & setSwitchAlias(std::string moduleLabel)
Definition: ProductRegistryHelper.h:58
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::ProductRegistryHelper::BranchAliasSetterT::token_
EDPutTokenT< T > token_
Definition: ProductRegistryHelper.h:80
edm::ProductRegistryHelper::produces
BranchAliasSetterT< ProductType > produces(std::string instanceName)
Definition: ProductRegistryHelper.h:123
edm::ProductRegistryHelper::BranchAliasSetterT::BranchAliasSetterT
BranchAliasSetterT(TypeLabelItem &iItem, EDPutTokenT< T > iToken)
Definition: ProductRegistryHelper.h:71
MuonErrorMatrixAdjuster_cfi.instanceName
instanceName
Definition: MuonErrorMatrixAdjuster_cfi.py:16
edm::ProductRegistryHelper::TypeLabelItem::AliasType::kBranchAlias
edm::ProductRegistryHelper
Definition: ProductRegistryHelper.h:23