CMS 3D CMS Logo

ProductRegistryHelper.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 
3 ----------------------------------------------------------------------*/
4 
11 
12 #include <vector>
13 #include <typeindex>
14 
15 namespace edm {
17 
19  return typeLabelList_;
20  }
21 
22  void
23  ProductRegistryHelper::addToRegistry(TypeLabelList::const_iterator const& iBegin,
24  TypeLabelList::const_iterator const& iEnd,
25  ModuleDescription const& iDesc,
26  ProductRegistry& iReg,
27  bool iIsListener) {
28 
29  std::vector<std::string> missingDictionaries;
30  std::vector<std::string> producedTypes;
31  std::set<std::tuple<BranchType,std::type_index,std::string>> registeredProducts;
32 
33  for(TypeLabelList::const_iterator p = iBegin; p != iEnd; ++p) {
34 
35  if (!checkDictionary(missingDictionaries, p->typeID_)) {
36  checkDictionaryOfWrappedType(missingDictionaries, p->typeID_);
37  producedTypes.emplace_back(p->typeID_.className());
38  continue;
39  }
40  auto branchType = convertToBranchType(p->transition_);
41  if(branchType != InEvent) {
42  std::tuple<BranchType, std::type_index, std::string> entry{ branchType,p->typeID_.typeInfo(),p->productInstanceName_};
43  if(registeredProducts.end() != registeredProducts.find(entry) ) {
44  //ignore registration of items if in both begin and end transitions for now
45  // This is to work around ExternalLHEProducer
46  continue;
47  } else {
48  registeredProducts.insert(entry);
49  }
50  }
51 
52  TypeWithDict type(p->typeID_.typeInfo());
54  iDesc.moduleLabel(),
55  iDesc.processName(),
56  p->typeID_.userClassName(),
57  p->typeID_.friendlyClassName(),
58  p->productInstanceName_,
59  iDesc.moduleName(),
60  iDesc.parameterSetID(),
61  type,
62  true,
63  isEndTransition(p->transition_));
64 
65  if (pdesc.transient()) {
66  if (!checkDictionary(missingDictionaries, pdesc.wrappedName(), pdesc.wrappedType())) {
67  // It is should be impossible to get here, because the only way to
68  // make it transient is in the line that causes the wrapped dictionary
69  // to be created. Just to be safe I leave this check here ...
70  producedTypes.emplace_back(pdesc.className());
71  continue;
72  }
73  } else {
74  // also check constituents of wrapped types if it is not transient
75  if (!checkClassDictionaries(missingDictionaries, pdesc.wrappedName(), pdesc.wrappedType())) {
76  producedTypes.emplace_back(pdesc.className());
77  continue;
78  }
79  }
80  if (!p->branchAlias_.empty()) pdesc.insertBranchAlias(p->branchAlias_);
81  iReg.addProduct(pdesc, iIsListener);
82  }
83 
84  if (!missingDictionaries.empty()) {
85  std::string context("Calling ProductRegistryHelper::addToRegistry, checking dictionaries for produced types");
86  throwMissingDictionariesException(missingDictionaries, context, producedTypes);
87  }
88  }
89 }
type
Definition: HCALResponse.h:21
void throwMissingDictionariesException(std::vector< std::string > &missingDictionaries, std::string const &context)
std::string const & processName() const
TypeLabelList const & typeLabelList() const
used by the fwk to register the list of products of this module
std::string const & moduleName() const
std::string const & moduleLabel() const
constexpr bool isEndTransition(Transition iValue)
Definition: Transition.h:31
std::vector< TypeLabelItem > TypeLabelList
bool checkDictionary(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
bool checkClassDictionaries(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
HLT enums.
ParameterSetID const & parameterSetID() const
bool checkDictionaryOfWrappedType(std::vector< std::string > &missingDictionaries, TypeID const &unwrappedTypeID)
static void addToRegistry(TypeLabelList::const_iterator const &iBegin, TypeLabelList::const_iterator const &iEnd, ModuleDescription const &iDesc, ProductRegistry &iReg, bool iIsListener=false)
void addProduct(BranchDescription const &productdesc, bool iFromListener=false)
constexpr BranchType convertToBranchType(Transition iValue)
Definition: Transition.h:21
void insertBranchAlias(std::string const &alias)
def branchType(schema, name)
Definition: revisionDML.py:112