CMS 3D CMS Logo

ProductResolverIndexHelper.cc
Go to the documentation of this file.
1 
9 
10 #include <TClass.h>
11 
12 #include <cassert>
13 #include <iostream>
14 #include <limits>
15 
16 namespace edm {
17 
18  namespace productholderindexhelper {
20  static int const vtcOffset =
21  TClass::GetClass("edm::WrapperBase")->GetBaseClassOffset(TClass::GetClass("edm::ViewTypeChecker"));
22  static TClass const* const wbClass = TClass::GetClass("edm::WrapperBase");
23  static std::string const refVector("edm::RefVector<");
24  static std::string const refToBaseVector("edm::RefToBaseVector<");
25  static std::string const ptrVector("edm::PtrVector<");
26  static std::string const vectorPtr("std::vector<edm::Ptr<");
27  static std::string const vectorUniquePtr("std::vector<std::unique_ptr<");
28  static std::string const associationMap("edm::AssociationMap<");
29  static std::string const newDetSetVector("edmNew::DetSetVector<");
30  static size_t const rvsize = refVector.size();
31  static size_t const rtbvsize = refToBaseVector.size();
32  static size_t const pvsize = ptrVector.size();
33  static size_t const vpsize = vectorPtr.size();
34  static size_t const vupsize = vectorUniquePtr.size();
35  static size_t const amsize = associationMap.size();
36  static size_t const ndsize = newDetSetVector.size();
37  bool mayBeRefVector = (className.substr(0, rvsize) == refVector) ||
38  (className.substr(0, rtbvsize) == refToBaseVector) ||
39  (className.substr(0, pvsize) == ptrVector) || (className.substr(0, vpsize) == vectorPtr) ||
40  (className.substr(0, vupsize) == vectorUniquePtr);
41  // AssociationMap and edmNew::DetSetVector do not support View and
42  // this function is used to get a contained type that can be accessed
43  // using a View. So return the void type in these cases.
44  // In practice, they were the only types causing a problem, but any
45  // type with a typedef named value_type that does not support
46  // View might also cause problems and might need to be added here in
47  // the future.
48  if (className.substr(0, amsize) == associationMap || className.substr(0, ndsize) == newDetSetVector) {
49  return TypeID(typeid(void));
50  }
51  TClass* cl = TClass::GetClass(wrappedTypeID.className().c_str());
52  if (cl == nullptr) {
53  return TypeID(typeid(void));
54  }
55  void* p = cl->New();
56  int offset = cl->GetBaseClassOffset(wbClass) + vtcOffset;
57  std::unique_ptr<ViewTypeChecker> checker = getAnyPtr<ViewTypeChecker>(p, offset);
58  if (mayBeRefVector) {
59  std::type_info const& ti = checker->memberTypeInfo();
60  if (ti != typeid(void)) {
61  return TypeID(ti);
62  }
63  }
64  return TypeID(checker->valueTypeInfo());
65  }
66 
67  TypeID getContainedType(TypeID const& typeID) {
68  const std::string& className = typeID.className();
70  TypeID const wrappedTypeID = TypeID(wrappedType.typeInfo());
71  return getContainedTypeFromWrapper(wrappedTypeID, className);
72  }
73 
74  bool typeIsViewCompatible(TypeID const& requestedViewType,
75  TypeID const& wrappedtypeID,
76  std::string const& className) {
77  auto elementType = getContainedTypeFromWrapper(wrappedtypeID, className);
78  if (elementType == TypeID(typeid(void)) or elementType == TypeID()) {
79  //the wrapped type is not a container
80  return false;
81  }
82  if (elementType == requestedViewType) {
83  return true;
84  }
85  //need to check for inheritance match
86  std::vector<std::string> missingDictionaries;
87  std::vector<TypeWithDict> baseTypes;
88  if (!public_base_classes(missingDictionaries, elementType, baseTypes)) {
89  return false;
90  }
91  for (auto const& base : baseTypes) {
92  if (TypeID(base.typeInfo()) == requestedViewType) {
93  return true;
94  }
95  }
96  return false;
97  }
98 
99  } // namespace productholderindexhelper
100 
102  : nextIndexValue_(0),
103  beginElements_(0),
104  items_(new std::set<ProductResolverIndexHelper::Item>),
105  processItems_(new std::set<std::string>) {}
106 
108  TypeID const& typeID,
109  char const* moduleLabel,
110  char const* instance,
111  char const* process) const {
112  unsigned int iToIndexAndNames = indexToIndexAndNames(kindOfType, typeID, moduleLabel, instance, process);
113 
114  if (iToIndexAndNames == std::numeric_limits<unsigned int>::max()) {
116  }
117  return indexAndNames_[iToIndexAndNames].index();
118  }
119 
121  unsigned int startInIndexAndNames,
122  unsigned int numberOfMatches)
123  : productResolverIndexHelper_(productResolverIndexHelper),
124  startInIndexAndNames_(startInIndexAndNames),
125  numberOfMatches_(numberOfMatches) {
126  if (numberOfMatches != 0 &&
129  << "ProductResolverIndexHelper::Matches::Matches - Arguments exceed vector bounds.\n";
130  }
131  }
132 
134  if (i >= numberOfMatches_) {
135  throw Exception(errors::LogicError) << "ProductResolverIndexHelper::Matches::index - Argument is out of range.\n";
136  }
137  return productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ + i].index();
138  }
139 
141  if (i >= numberOfMatches_) {
143  << "ProductResolverIndexHelper::Matches::isFullyResolved - Argument is out of range.\n";
144  }
145  return (productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ + i].startInProcessNames() != 0U);
146  }
147 
148  char const* ProductResolverIndexHelper::Matches::processName(unsigned int i) const {
149  if (i >= numberOfMatches_) {
151  << "ProductResolverIndexHelper::Matches::processName - Argument is out of range.\n";
152  }
153  unsigned int startInProcessNames =
154  productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ + i].startInProcessNames();
155  return &productResolverIndexHelper_->processNames_[startInProcessNames];
156  }
157 
159  if (i >= numberOfMatches_) {
161  << "ProductResolverIndexHelper::Matches::productInstanceName - Argument is out of range.\n";
162  }
163  unsigned int start =
164  productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ + i].startInBigNamesContainer();
165  auto moduleLabelSize = strlen(&productResolverIndexHelper_->bigNamesContainer_[start]);
166  return &productResolverIndexHelper_->bigNamesContainer_[start + moduleLabelSize + 1];
167  }
168 
169  char const* ProductResolverIndexHelper::Matches::moduleLabel(unsigned int i) const {
170  if (i >= numberOfMatches_) {
172  << "ProductResolverIndexHelper::Matches::moduleLabel - Argument is out of range.\n";
173  }
174  unsigned int start =
175  productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ + i].startInBigNamesContainer();
176  return &productResolverIndexHelper_->bigNamesContainer_[start];
177  }
178 
180  TypeID const& typeID,
181  char const* moduleLabel,
182  char const* instance) const {
183  unsigned int startInIndexAndNames = indexToIndexAndNames(kindOfType, typeID, moduleLabel, instance, nullptr);
184  unsigned int numberOfMatches = 1;
185 
186  if (startInIndexAndNames == std::numeric_limits<unsigned int>::max()) {
187  numberOfMatches = 0;
188  } else {
189  auto vSize = indexAndNames_.size();
190  for (unsigned int j = startInIndexAndNames + 1U; j < vSize && (indexAndNames_[j].startInProcessNames() != 0U);
191  ++j) {
192  ++numberOfMatches;
193  }
194  }
195  return Matches(this, startInIndexAndNames, numberOfMatches);
196  }
197 
199  TypeID const& typeID) const {
200  unsigned int startInIndexAndNames = std::numeric_limits<unsigned int>::max();
201  unsigned int numberOfMatches = 0;
202 
203  // Look for the type and check to see if it found it
204  unsigned iType = indexToType(kindOfType, typeID);
206  // Get the range of entries with a matching TypeID
207  Range const& range = ranges_[iType];
208 
209  startInIndexAndNames = range.begin();
210  numberOfMatches = range.end() - range.begin();
211  }
212  return Matches(this, startInIndexAndNames, numberOfMatches);
213  }
214 
216  char const* moduleLabel,
217  char const* instance,
218  char const* process,
219  TypeID const& containedTypeID,
220  std::vector<TypeWithDict>* baseTypesOfContainedType) {
221  if (!items_) {
223  << "ProductResolverIndexHelper::insert - Attempt to insert more elements after frozen.\n";
224  }
225 
226  if (process == nullptr || *process == '\0') {
227  throw Exception(errors::LogicError) << "ProductResolverIndexHelper::insert - Empty process.\n";
228  }
229 
230  // Throw if this has already been inserted
232  std::set<Item>::iterator iter = items_->find(item);
233  if (iter != items_->end()) {
235  << "ProductResolverIndexHelper::insert - Attempt to insert duplicate entry.\n";
236  }
237 
238  // Put in an entry for the product
239  item.setIndex(nextIndexValue_);
240  unsigned int savedProductIndex = nextIndexValue_;
241  ++nextIndexValue_;
242  items_->insert(item);
243 
244  // Put in an entry for the product with an empty process name
245  // if it is not already there
246  item.clearProcess();
247  iter = items_->find(item);
248  if (iter == items_->end()) {
249  item.setIndex(nextIndexValue_);
250  ++nextIndexValue_;
251  items_->insert(item);
252  }
253 
254  // Now put in entries for a contained class if this is a
255  // recognized container.
256  if (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID()) {
257  TypeWithDict containedType(containedTypeID.typeInfo());
258 
259  Item containedItem(ELEMENT_TYPE, containedTypeID, moduleLabel, instance, process, savedProductIndex);
260  iter = items_->find(containedItem);
261  if (iter != items_->end()) {
262  containedItem.setIndex(ProductResolverIndexAmbiguous);
263  items_->erase(iter);
264  }
265  items_->insert(containedItem);
266 
267  containedItem.clearProcess();
268  iter = items_->find(containedItem);
269  if (iter == items_->end()) {
270  containedItem.setIndex(nextIndexValue_);
271  ++nextIndexValue_;
272  items_->insert(containedItem);
273  }
274 
275  // Repeat this for all public base classes of the contained type
276  if (baseTypesOfContainedType) {
277  for (TypeWithDict const& baseType : *baseTypesOfContainedType) {
278  TypeID baseTypeID(baseType.typeInfo());
279  Item baseItem(ELEMENT_TYPE, baseTypeID, moduleLabel, instance, process, savedProductIndex);
280  iter = items_->find(baseItem);
281  if (iter != items_->end()) {
282  baseItem.setIndex(ProductResolverIndexAmbiguous);
283  items_->erase(iter);
284  }
285  items_->insert(baseItem);
286 
287  baseItem.clearProcess();
288  iter = items_->find(baseItem);
289  if (iter == items_->end()) {
290  baseItem.setIndex(nextIndexValue_);
291  ++nextIndexValue_;
292  items_->insert(baseItem);
293  }
294  }
295  }
296  }
297  return savedProductIndex;
298  }
299 
301  char const* moduleLabel,
302  char const* instance,
303  char const* process) {
304  TypeID containedTypeID = productholderindexhelper::getContainedType(typeID);
305  bool hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
306  std::vector<TypeWithDict> baseTypes;
307  std::vector<TypeWithDict>* baseTypesOfContainedType = &baseTypes;
308  if (hasContainedType) {
309  std::vector<std::string> missingDictionaries;
310  public_base_classes(missingDictionaries, containedTypeID, baseTypes);
311  }
312  return insert(typeID, moduleLabel, instance, process, containedTypeID, baseTypesOfContainedType);
313  }
314 
316  if (!items_)
317  return;
318 
319  // Make a first pass and count things so we
320  // can reserve memory in the vectors. Also
321  // fill processItems_ on the first pass.
322  bool iFirstThisType = true;
323  bool beginElementsWasSet = false;
324  TypeID previousTypeID;
325  KindOfType previousKindOfType = PRODUCT_TYPE;
326  std::string previousModuleLabel;
327  std::string previousInstance;
328  unsigned int iCountTypes = 0;
329  unsigned int iCountCharacters = 0;
330  for (auto const& item : *items_) {
331  if (iFirstThisType || item.typeID() != previousTypeID || item.kindOfType() != previousKindOfType) {
332  ++iCountTypes;
333  iFirstThisType = true;
334 
335  if (!beginElementsWasSet) {
336  if (item.kindOfType() == ELEMENT_TYPE) {
337  beginElementsWasSet = true;
338  } else {
339  beginElements_ = iCountTypes;
340  }
341  }
342  }
343 
344  processItems_->insert(item.process());
345 
346  if (iFirstThisType || item.moduleLabel() != previousModuleLabel || item.instance() != previousInstance) {
347  iCountCharacters += item.moduleLabel().size();
348  iCountCharacters += item.instance().size();
349  iCountCharacters += 2;
350  }
351 
352  iFirstThisType = false;
353  previousTypeID = item.typeID();
354  previousKindOfType = item.kindOfType();
355  previousModuleLabel = item.moduleLabel();
356  previousInstance = item.instance();
357  }
358 
359  // Size and fill the process name vector
360  unsigned int processNamesSize = 0;
361  for (auto const& processItem : *processItems_) {
362  processNamesSize += processItem.size();
363  ++processNamesSize;
364  }
365  processNames_.reserve(processNamesSize);
366  for (auto const& processItem : *processItems_) {
367  for (auto const& c : processItem) {
368  processNames_.push_back(c);
369  }
370  processNames_.push_back('\0');
371  lookupProcessNames_.push_back(processItem);
372  }
373 
374  // Reserve memory in the vectors
375  sortedTypeIDs_.reserve(iCountTypes);
376  ranges_.reserve(iCountTypes);
377  indexAndNames_.reserve(items_->size());
378  bigNamesContainer_.reserve(iCountCharacters);
379 
380  // Second pass. Really fill the vectors this time.
381  bool iFirstType = true;
382  iFirstThisType = true;
383  previousTypeID = TypeID();
384  unsigned int iCount = 0;
385  unsigned int iBeginning = 0;
386  iCountCharacters = 0;
387  unsigned int previousCharacterCount = 0;
388  if (!items_->empty()) {
389  for (auto const& item : *items_) {
390  if (iFirstThisType || item.typeID() != previousTypeID || item.kindOfType() != previousKindOfType) {
391  iFirstThisType = true;
392  sortedTypeIDs_.push_back(item.typeID());
393  if (iFirstType) {
394  iFirstType = false;
395  } else {
396  ranges_.push_back(Range(iBeginning, iCount));
397  }
398  iBeginning = iCount;
399  }
400  ++iCount;
401 
402  if (iFirstThisType || item.moduleLabel() != previousModuleLabel || item.instance() != previousInstance) {
403  unsigned int labelSize = item.moduleLabel().size();
404  for (unsigned int j = 0; j < labelSize; ++j) {
405  bigNamesContainer_.push_back(item.moduleLabel()[j]);
406  }
407  bigNamesContainer_.push_back('\0');
408 
409  unsigned int instanceSize = item.instance().size();
410  for (unsigned int j = 0; j < instanceSize; ++j) {
411  bigNamesContainer_.push_back(item.instance()[j]);
412  }
413  bigNamesContainer_.push_back('\0');
414 
415  previousCharacterCount = iCountCharacters;
416 
417  iCountCharacters += labelSize;
418  iCountCharacters += instanceSize;
419  iCountCharacters += 2;
420  }
421 
422  unsigned int processStart = processIndex(item.process().c_str());
423  if (processStart == std::numeric_limits<unsigned int>::max()) {
425  << "ProductResolverIndexHelper::setFrozen - Process not found in processNames_.\n";
426  }
427  indexAndNames_.emplace_back(item.index(), previousCharacterCount, processStart);
428 
429  iFirstThisType = false;
430  previousTypeID = item.typeID();
431  previousKindOfType = item.kindOfType();
432  previousModuleLabel = item.moduleLabel();
433  previousInstance = item.instance();
434  }
435  ranges_.push_back(Range(iBeginning, iCount));
436  }
437 
438  // Some sanity checks to protect against out of bounds vector accesses
439  // These should only fail if there is a bug. If profiling ever shows
440  // them to be expensive one might delete them.
441  sanityCheck();
442 
443  // Cleanup, do not need the temporary containers anymore
444  // propagate_const<T> has no reset() function
445  items_ = nullptr;
446  processItems_ = nullptr;
447  }
448 
449  std::vector<std::string> const& ProductResolverIndexHelper::lookupProcessNames() const {
450  if (items_) {
452  << "ProductResolverIndexHelper::lookupProcessNames - Attempt to access names before frozen.\n";
453  }
454  return lookupProcessNames_;
455  }
456 
458  TypeID const& typeID,
459  char const* moduleLabel,
460  char const* instance,
461  char const* process) const {
462  // Look for the type and check to see if it found it
463  unsigned iType = indexToType(kindOfType, typeID);
465  unsigned startProcess = 0;
466  if (process) {
467  startProcess = processIndex(process);
468  if (startProcess == std::numeric_limits<unsigned int>::max()) {
470  }
471  }
472 
474  unsigned int begin = range.begin();
475  unsigned int end = range.end();
476 
477  while (begin < end) {
478  unsigned int midpoint = begin + ((end - begin) / 2);
479  char const* namePtr = &bigNamesContainer_[indexAndNames_[midpoint].startInBigNamesContainer()];
480 
481  // Compare the module label
482  char const* label = moduleLabel;
483  while (*namePtr && (*namePtr == *label)) {
484  ++namePtr;
485  ++label;
486  }
487  if (*namePtr == *label) { // true only if both are at the '\0' at the end of the C string
488  ++namePtr; // move to the next C string
489 
490  // Compare the instance name
491  char const* instanceName = instance;
492  while (*namePtr && (*namePtr == *instanceName)) {
493  ++namePtr;
494  ++instanceName;
495  }
496  if (*namePtr == *instanceName) {
497  // Compare the process name
498  if (startProcess == indexAndNames_[midpoint].startInProcessNames()) {
499  return midpoint;
500  } else {
501  if (indexAndNames_[midpoint].startInProcessNames() > startProcess) {
502  while (true) {
503  --midpoint;
504  if (indexAndNames_[midpoint].startInProcessNames() == startProcess) {
505  return midpoint;
506  }
507  if (indexAndNames_[midpoint].startInProcessNames() == 0)
508  break;
509  }
510  } else {
511  while (true) {
512  ++midpoint;
513  if (midpoint == indexAndNames_.size())
514  break;
515  if (indexAndNames_[midpoint].startInProcessNames() == 0)
516  break;
517  if (indexAndNames_[midpoint].startInProcessNames() == startProcess) {
518  return midpoint;
519  }
520  }
521  }
522  break;
523  }
524  } else if (*namePtr < *instanceName) {
525  if (begin == midpoint)
526  break;
527  begin = midpoint;
528  } else {
529  end = midpoint;
530  }
531  } else if (*namePtr < *label) {
532  if (begin == midpoint)
533  break;
534  begin = midpoint;
535  } else {
536  end = midpoint;
537  }
538  } // end while (begin < end)
539  }
541  }
542 
543  unsigned int ProductResolverIndexHelper::indexToType(KindOfType kindOfType, TypeID const& typeID) const {
544  unsigned int beginType = 0;
545  unsigned int endType = beginElements_;
546  if (kindOfType == ELEMENT_TYPE) {
547  beginType = beginElements_;
548  endType = sortedTypeIDs_.size();
549  }
550 
551  while (beginType < endType) {
552  unsigned int midpointType = beginType + ((endType - beginType) / 2);
553  if (sortedTypeIDs_[midpointType] == typeID) {
554  return midpointType; // Found it
555  } else if (sortedTypeIDs_[midpointType] < typeID) {
556  if (beginType == midpointType)
557  break;
558  beginType = midpointType;
559  } else {
560  endType = midpointType;
561  }
562  }
563  return std::numeric_limits<unsigned int>::max(); // Failed to find it
564  }
565 
566  unsigned int ProductResolverIndexHelper::processIndex(char const* process) const {
567  char const* ptr = &processNames_[0];
568  char const* begin = ptr;
569  while (true) {
570  char const* p = process;
571  char const* beginName = ptr;
572  while (*ptr && (*ptr == *p)) {
573  ++ptr;
574  ++p;
575  }
576  if (*ptr == *p) {
577  return beginName - begin;
578  }
579  while (*ptr) {
580  ++ptr;
581  }
582  ++ptr;
583  if (static_cast<unsigned>(ptr - begin) >= processNames_.size()) {
585  }
586  }
587  return 0;
588  }
589 
591  const std::string& iProcessName) const {
593  for (unsigned int i = 0; i < beginElements_; ++i) {
594  auto const& range = ranges_[i];
595  for (unsigned int j = range.begin(); j < range.end(); ++j) {
596  auto const& indexAndNames = indexAndNames_[j];
597  if (0 == strcmp(&processNames_[indexAndNames.startInProcessNames()], iProcessName.c_str())) {
598  //The first null terminated string is the module label
599  auto pModLabel = &bigNamesContainer_[indexAndNames.startInBigNamesContainer()];
600  auto l = strlen(pModLabel);
601  auto pInstance = pModLabel + l + 1;
602  result.emplace(pModLabel, std::make_tuple(&sortedTypeIDs_[i], pInstance, indexAndNames.index()));
603  }
604  }
605  }
606  return result;
607  }
608 
610  bool sanityChecksPass = true;
611  if (sortedTypeIDs_.size() != ranges_.size())
612  sanityChecksPass = false;
613 
614  unsigned int previousEnd = 0;
615  for (auto const& range : ranges_) {
616  if (range.begin() != previousEnd)
617  sanityChecksPass = false;
618  if (range.begin() >= range.end())
619  sanityChecksPass = false;
620  previousEnd = range.end();
621  }
622  if (previousEnd != indexAndNames_.size())
623  sanityChecksPass = false;
624 
625  unsigned maxStart = 0;
626  unsigned maxStartProcess = 0;
627  for (auto const& indexAndName : indexAndNames_) {
628  if (indexAndName.index() >= nextIndexValue_ && indexAndName.index() != ProductResolverIndexAmbiguous)
629  sanityChecksPass = false;
630 
631  if (indexAndName.startInBigNamesContainer() >= bigNamesContainer_.size())
632  sanityChecksPass = false;
633  if (indexAndName.startInProcessNames() >= processNames_.size())
634  sanityChecksPass = false;
635 
636  if (indexAndName.startInBigNamesContainer() > maxStart)
637  maxStart = indexAndName.startInBigNamesContainer();
638  if (indexAndName.startInProcessNames() > maxStartProcess)
639  maxStartProcess = indexAndName.startInProcessNames();
640  }
641 
642  if (!indexAndNames_.empty()) {
643  if (bigNamesContainer_.back() != '\0')
644  sanityChecksPass = false;
645  if (processNames_.back() != '\0')
646  sanityChecksPass = false;
647  if (maxStart >= bigNamesContainer_.size())
648  sanityChecksPass = false;
649  unsigned int countZeroes = 0;
650  for (unsigned j = maxStart; j < bigNamesContainer_.size(); ++j) {
651  if (bigNamesContainer_[j] == '\0') {
652  ++countZeroes;
653  }
654  }
655  if (countZeroes != 2)
656  sanityChecksPass = false;
657  if (maxStartProcess >= processNames_.size())
658  sanityChecksPass = false;
659  countZeroes = 0;
660  for (unsigned j = maxStartProcess; j < processNames_.size(); ++j) {
661  if (processNames_[j] == '\0') {
662  ++countZeroes;
663  }
664  }
665  if (countZeroes != 1)
666  sanityChecksPass = false;
667  }
668 
669  if (!sanityChecksPass) {
670  throw Exception(errors::LogicError) << "ProductResolverIndexHelper::setFrozen - Detected illegal state.\n";
671  }
672  }
673 
675  TypeID const& typeID,
676  std::string const& moduleLabel,
677  std::string const& instance,
678  std::string const& process,
680  : kindOfType_(kindOfType),
681  typeID_(typeID),
682  moduleLabel_(moduleLabel),
683  instance_(instance),
684  process_(process),
685  index_(index) {}
686 
688  if (kindOfType_ < right.kindOfType_)
689  return true;
690  if (kindOfType_ > right.kindOfType_)
691  return false;
692  if (typeID_ < right.typeID_)
693  return true;
694  if (typeID_ > right.typeID_)
695  return false;
696  if (moduleLabel_ < right.moduleLabel_)
697  return true;
698  if (moduleLabel_ > right.moduleLabel_)
699  return false;
700  if (instance_ < right.instance_)
701  return true;
702  if (instance_ > right.instance_)
703  return false;
704  return process_ < right.process_;
705  }
706 
707  void ProductResolverIndexHelper::print(std::ostream& os) const {
708  os << "\n******* Dump ProductResolverIndexHelper *************************\n";
709 
710  os << "\nnextIndexValue_ = " << nextIndexValue_ << "\n";
711  os << "beginElements_ = " << beginElements_ << "\n";
712 
713  os << "\n******* sortedTypeIDs_ \n";
714  for (auto const& i : sortedTypeIDs_) {
715  os << i << "\n";
716  }
717  os << "******* ranges_ \n";
718  for (auto const& i : ranges_) {
719  os << i.begin() << " " << i.end() << "\n";
720  }
721  os << "******* indexAndNames_ \n";
722  for (auto const& i : indexAndNames_) {
723  os << i.index() << " " << i.startInBigNamesContainer() << " ";
724  char const* ptr = &bigNamesContainer_[i.startInBigNamesContainer()];
725  while (*ptr) {
726  os << *ptr;
727  ++ptr;
728  }
729  ++ptr;
730  os << " ";
731  while (*ptr) {
732  os << *ptr;
733  ++ptr;
734  }
735  os << " " << i.startInProcessNames() << " ";
736  ptr = &processNames_[i.startInProcessNames()];
737  while (*ptr) {
738  os << *ptr;
739  ++ptr;
740  }
741  os << "\n";
742  }
743  os << "******* bigNamesContainer_ \n";
744  for (auto i : bigNamesContainer_) {
745  if (i == '\0')
746  os << '\\' << '0';
747  else
748  os << i;
749  }
750  if (!bigNamesContainer_.empty())
751  os << "\n";
752  os << "******* processNames_ \n";
753  for (auto i : processNames_) {
754  if (i == '\0')
755  os << '\\' << '0';
756  else
757  os << i;
758  }
759  if (!processNames_.empty())
760  os << "\n";
761  if (items_) {
762  os << "******* items_ \n";
763  for (auto const& item : *items_) {
764  std::cout << item.kindOfType() << " " << item.moduleLabel() << " " << item.instance() << " " << item.process()
765  << " " << item.index() << " " << item.typeID() << "\n";
766  }
767  }
768  if (processItems_) {
769  os << "******* processItems_ \n";
770  for (auto const& item : *processItems_) {
771  os << item << "\n";
772  }
773  }
774  os << "sortedTypeIDs_.size() = " << sortedTypeIDs_.size() << "\n";
775  os << "indexAndNames_.size() = " << indexAndNames_.size() << "\n";
776  os << "bigNamesContainer_.size() = " << bigNamesContainer_.size() << "\n";
777  os << "processNames_.size() = " << processNames_.size() << "\n";
778  os << "\n";
779  }
780 } // namespace edm
unsigned int processIndex(char const *process) const
Definition: start.py:1
TypeID getContainedType(TypeID const &typeID)
unsigned int ProductResolverIndex
Item(KindOfType kindOfType, TypeID const &typeID, std::string const &moduleLabel, std::string const &instance, std::string const &process, ProductResolverIndex index)
TypeID getContainedTypeFromWrapper(TypeID const &wrappedtypeID, std::string const &className)
static PFTauRenderPlugin instance
PixelRecoRange< float > Range
bool public_base_classes(std::vector< std::string > &missingDictionaries, TypeID const &typeID, std::vector< TypeWithDict > &baseTypes)
base
Main Program
Definition: newFWLiteAna.py:92
ProductResolverIndex insert(TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process, TypeID const &containedTypeID, std::vector< TypeWithDict > *baseTypesOfContainedType)
ModulesToIndiciesMap indiciesForModulesInProcess(const std::string &iProcessName) const
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
char const * label
Matches(ProductResolverIndexHelper const *productResolverIndexHelper, unsigned int startInIndexAndNames, unsigned int numberOfMatches)
edm::propagate_const< std::unique_ptr< std::set< std::string > > > processItems_
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
unsigned int indexToIndexAndNames(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process) const
bool typeIsViewCompatible(TypeID const &requestedViewType, TypeID const &wrappedtypeID, std::string const &className)
char const * moduleLabel(unsigned int i) const
ProductResolverIndex index(unsigned int i) const
std::string const & className() const
Definition: TypeID.cc:40
std::vector< IndexAndNames > indexAndNames_
char const * processName(unsigned int i) const
std::vector< std::string > lookupProcessNames_
std::type_info const & typeInfo() const
std::string wrappedClassName(std::string const &iFullName)
unsigned int indexToType(KindOfType kindOfType, TypeID const &typeID) const
HLT enums.
std::vector< IndexAndNames > const & indexAndNames() const
ProductResolverIndexHelper const * productResolverIndexHelper_
std::vector< std::string > const & lookupProcessNames() const
constexpr const std::type_info & typeInfo() const
Definition: TypeIDBase.h:50
std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, ProductResolverIndex > > ModulesToIndiciesMap
edm::propagate_const< std::unique_ptr< std::set< Item > > > items_
std::string className(const T &t)
Definition: ClassName.h:31
char const * productInstanceName(unsigned int i) const