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<TypeID> 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<TypeID>* 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 (TypeID const& baseTypeID : *baseTypesOfContainedType) {
278  Item baseItem(ELEMENT_TYPE, baseTypeID, moduleLabel, instance, process, savedProductIndex);
279  iter = items_->find(baseItem);
280  if (iter != items_->end()) {
282  items_->erase(iter);
283  }
284  items_->insert(baseItem);
285 
286  baseItem.clearProcess();
287  iter = items_->find(baseItem);
288  if (iter == items_->end()) {
289  baseItem.setIndex(nextIndexValue_);
290  ++nextIndexValue_;
291  items_->insert(baseItem);
292  }
293  }
294  }
295  }
296  return savedProductIndex;
297  }
298 
300  char const* moduleLabel,
301  char const* instance,
302  char const* process) {
303  TypeID containedTypeID = productholderindexhelper::getContainedType(typeID);
304  bool hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
305  std::vector<TypeID> baseTypes;
306  std::vector<TypeID>* baseTypesOfContainedType = &baseTypes;
307  if (hasContainedType) {
308  std::vector<std::string> missingDictionaries;
309  public_base_classes(missingDictionaries, containedTypeID, baseTypes);
310  }
311  return insert(typeID, moduleLabel, instance, process, containedTypeID, baseTypesOfContainedType);
312  }
313 
315  if (!items_)
316  return;
317 
318  // Make a first pass and count things so we
319  // can reserve memory in the vectors. Also
320  // fill processItems_ on the first pass.
321  bool iFirstThisType = true;
322  bool beginElementsWasSet = false;
323  TypeID previousTypeID;
324  KindOfType previousKindOfType = PRODUCT_TYPE;
325  std::string previousModuleLabel;
326  std::string previousInstance;
327  unsigned int iCountTypes = 0;
328  unsigned int iCountCharacters = 0;
329  for (auto const& item : *items_) {
330  if (iFirstThisType || item.typeID() != previousTypeID || item.kindOfType() != previousKindOfType) {
331  ++iCountTypes;
332  iFirstThisType = true;
333 
334  if (!beginElementsWasSet) {
335  if (item.kindOfType() == ELEMENT_TYPE) {
336  beginElementsWasSet = true;
337  } else {
338  beginElements_ = iCountTypes;
339  }
340  }
341  }
342 
343  processItems_->insert(item.process());
344 
345  if (iFirstThisType || item.moduleLabel() != previousModuleLabel || item.instance() != previousInstance) {
346  iCountCharacters += item.moduleLabel().size();
347  iCountCharacters += item.instance().size();
348  iCountCharacters += 2;
349  }
350 
351  iFirstThisType = false;
352  previousTypeID = item.typeID();
353  previousKindOfType = item.kindOfType();
354  previousModuleLabel = item.moduleLabel();
355  previousInstance = item.instance();
356  }
357 
358  // Size and fill the process name vector
359  unsigned int processNamesSize = 0;
360  for (auto const& processItem : *processItems_) {
361  processNamesSize += processItem.size();
362  ++processNamesSize;
363  }
364  processNames_.reserve(processNamesSize);
365  for (auto const& processItem : *processItems_) {
366  for (auto const& c : processItem) {
367  processNames_.push_back(c);
368  }
369  processNames_.push_back('\0');
370  lookupProcessNames_.push_back(processItem);
371  }
372 
373  // Reserve memory in the vectors
374  sortedTypeIDs_.reserve(iCountTypes);
375  ranges_.reserve(iCountTypes);
376  indexAndNames_.reserve(items_->size());
377  bigNamesContainer_.reserve(iCountCharacters);
378 
379  // Second pass. Really fill the vectors this time.
380  bool iFirstType = true;
381  iFirstThisType = true;
382  previousTypeID = TypeID();
383  unsigned int iCount = 0;
384  unsigned int iBeginning = 0;
385  iCountCharacters = 0;
386  unsigned int previousCharacterCount = 0;
387  if (!items_->empty()) {
388  for (auto const& item : *items_) {
389  if (iFirstThisType || item.typeID() != previousTypeID || item.kindOfType() != previousKindOfType) {
390  iFirstThisType = true;
391  sortedTypeIDs_.push_back(item.typeID());
392  if (iFirstType) {
393  iFirstType = false;
394  } else {
395  ranges_.push_back(Range(iBeginning, iCount));
396  }
397  iBeginning = iCount;
398  }
399  ++iCount;
400 
401  if (iFirstThisType || item.moduleLabel() != previousModuleLabel || item.instance() != previousInstance) {
402  unsigned int labelSize = item.moduleLabel().size();
403  for (unsigned int j = 0; j < labelSize; ++j) {
404  bigNamesContainer_.push_back(item.moduleLabel()[j]);
405  }
406  bigNamesContainer_.push_back('\0');
407 
408  unsigned int instanceSize = item.instance().size();
409  for (unsigned int j = 0; j < instanceSize; ++j) {
410  bigNamesContainer_.push_back(item.instance()[j]);
411  }
412  bigNamesContainer_.push_back('\0');
413 
414  previousCharacterCount = iCountCharacters;
415 
416  iCountCharacters += labelSize;
417  iCountCharacters += instanceSize;
418  iCountCharacters += 2;
419  }
420 
421  unsigned int processStart = processIndex(item.process().c_str());
422  if (processStart == std::numeric_limits<unsigned int>::max()) {
424  << "ProductResolverIndexHelper::setFrozen - Process not found in processNames_.\n";
425  }
426  indexAndNames_.emplace_back(item.index(), previousCharacterCount, processStart);
427 
428  iFirstThisType = false;
429  previousTypeID = item.typeID();
430  previousKindOfType = item.kindOfType();
431  previousModuleLabel = item.moduleLabel();
432  previousInstance = item.instance();
433  }
434  ranges_.push_back(Range(iBeginning, iCount));
435  }
436 
437  // Some sanity checks to protect against out of bounds vector accesses
438  // These should only fail if there is a bug. If profiling ever shows
439  // them to be expensive one might delete them.
440  sanityCheck();
441 
442  // Cleanup, do not need the temporary containers anymore
443  // propagate_const<T> has no reset() function
444  items_ = nullptr;
445  processItems_ = nullptr;
446  }
447 
448  std::vector<std::string> const& ProductResolverIndexHelper::lookupProcessNames() const {
449  if (items_) {
451  << "ProductResolverIndexHelper::lookupProcessNames - Attempt to access names before frozen.\n";
452  }
453  return lookupProcessNames_;
454  }
455 
457  TypeID const& typeID,
458  char const* moduleLabel,
459  char const* instance,
460  char const* process) const {
461  // Look for the type and check to see if it found it
462  unsigned iType = indexToType(kindOfType, typeID);
464  unsigned startProcess = 0;
465  if (process) {
466  startProcess = processIndex(process);
467  if (startProcess == std::numeric_limits<unsigned int>::max()) {
469  }
470  }
471 
473  unsigned int begin = range.begin();
474  unsigned int end = range.end();
475 
476  while (begin < end) {
477  unsigned int midpoint = begin + ((end - begin) / 2);
478  char const* namePtr = &bigNamesContainer_[indexAndNames_[midpoint].startInBigNamesContainer()];
479 
480  // Compare the module label
481  char const* label = moduleLabel;
482  while (*namePtr && (*namePtr == *label)) {
483  ++namePtr;
484  ++label;
485  }
486  if (*namePtr == *label) { // true only if both are at the '\0' at the end of the C string
487  ++namePtr; // move to the next C string
488 
489  // Compare the instance name
490  char const* instanceName = instance;
491  while (*namePtr && (*namePtr == *instanceName)) {
492  ++namePtr;
493  ++instanceName;
494  }
495  if (*namePtr == *instanceName) {
496  // Compare the process name
497  if (startProcess == indexAndNames_[midpoint].startInProcessNames()) {
498  return midpoint;
499  } else {
500  if (indexAndNames_[midpoint].startInProcessNames() > startProcess) {
501  while (true) {
502  --midpoint;
503  if (indexAndNames_[midpoint].startInProcessNames() == startProcess) {
504  return midpoint;
505  }
506  if (indexAndNames_[midpoint].startInProcessNames() == 0)
507  break;
508  }
509  } else {
510  while (true) {
511  ++midpoint;
512  if (midpoint == indexAndNames_.size())
513  break;
514  if (indexAndNames_[midpoint].startInProcessNames() == 0)
515  break;
516  if (indexAndNames_[midpoint].startInProcessNames() == startProcess) {
517  return midpoint;
518  }
519  }
520  }
521  break;
522  }
523  } else if (*namePtr < *instanceName) {
524  if (begin == midpoint)
525  break;
526  begin = midpoint;
527  } else {
528  end = midpoint;
529  }
530  } else if (*namePtr < *label) {
531  if (begin == midpoint)
532  break;
533  begin = midpoint;
534  } else {
535  end = midpoint;
536  }
537  } // end while (begin < end)
538  }
540  }
541 
542  unsigned int ProductResolverIndexHelper::indexToType(KindOfType kindOfType, TypeID const& typeID) const {
543  unsigned int beginType = 0;
544  unsigned int endType = beginElements_;
545  if (kindOfType == ELEMENT_TYPE) {
546  beginType = beginElements_;
547  endType = sortedTypeIDs_.size();
548  }
549 
550  while (beginType < endType) {
551  unsigned int midpointType = beginType + ((endType - beginType) / 2);
552  if (sortedTypeIDs_[midpointType] == typeID) {
553  return midpointType; // Found it
554  } else if (sortedTypeIDs_[midpointType] < typeID) {
555  if (beginType == midpointType)
556  break;
557  beginType = midpointType;
558  } else {
559  endType = midpointType;
560  }
561  }
562  return std::numeric_limits<unsigned int>::max(); // Failed to find it
563  }
564 
565  unsigned int ProductResolverIndexHelper::processIndex(char const* process) const {
566  char const* ptr = &processNames_[0];
567  char const* begin = ptr;
568  while (true) {
569  char const* p = process;
570  char const* beginName = ptr;
571  while (*ptr && (*ptr == *p)) {
572  ++ptr;
573  ++p;
574  }
575  if (*ptr == *p) {
576  return beginName - begin;
577  }
578  while (*ptr) {
579  ++ptr;
580  }
581  ++ptr;
582  if (static_cast<unsigned>(ptr - begin) >= processNames_.size()) {
584  }
585  }
586  return 0;
587  }
588 
590  const std::string& iProcessName) const {
592  for (unsigned int i = 0; i < beginElements_; ++i) {
593  auto const& range = ranges_[i];
594  for (unsigned int j = range.begin(); j < range.end(); ++j) {
595  auto const& indexAndNames = indexAndNames_[j];
596  if (0 == strcmp(&processNames_[indexAndNames.startInProcessNames()], iProcessName.c_str())) {
597  //The first null terminated string is the module label
598  auto pModLabel = &bigNamesContainer_[indexAndNames.startInBigNamesContainer()];
599  auto l = strlen(pModLabel);
600  auto pInstance = pModLabel + l + 1;
601  result.emplace(pModLabel, std::make_tuple(&sortedTypeIDs_[i], pInstance, indexAndNames.index()));
602  }
603  }
604  }
605  return result;
606  }
607 
609  bool sanityChecksPass = true;
610  if (sortedTypeIDs_.size() != ranges_.size())
611  sanityChecksPass = false;
612 
613  unsigned int previousEnd = 0;
614  for (auto const& range : ranges_) {
615  if (range.begin() != previousEnd)
616  sanityChecksPass = false;
617  if (range.begin() >= range.end())
618  sanityChecksPass = false;
619  previousEnd = range.end();
620  }
621  if (previousEnd != indexAndNames_.size())
622  sanityChecksPass = false;
623 
624  unsigned maxStart = 0;
625  unsigned maxStartProcess = 0;
626  for (auto const& indexAndName : indexAndNames_) {
627  if (indexAndName.index() >= nextIndexValue_ && indexAndName.index() != ProductResolverIndexAmbiguous)
628  sanityChecksPass = false;
629 
630  if (indexAndName.startInBigNamesContainer() >= bigNamesContainer_.size())
631  sanityChecksPass = false;
632  if (indexAndName.startInProcessNames() >= processNames_.size())
633  sanityChecksPass = false;
634 
635  if (indexAndName.startInBigNamesContainer() > maxStart)
636  maxStart = indexAndName.startInBigNamesContainer();
637  if (indexAndName.startInProcessNames() > maxStartProcess)
638  maxStartProcess = indexAndName.startInProcessNames();
639  }
640 
641  if (!indexAndNames_.empty()) {
642  if (bigNamesContainer_.back() != '\0')
643  sanityChecksPass = false;
644  if (processNames_.back() != '\0')
645  sanityChecksPass = false;
646  if (maxStart >= bigNamesContainer_.size())
647  sanityChecksPass = false;
648  unsigned int countZeroes = 0;
649  for (unsigned j = maxStart; j < bigNamesContainer_.size(); ++j) {
650  if (bigNamesContainer_[j] == '\0') {
651  ++countZeroes;
652  }
653  }
654  if (countZeroes != 2)
655  sanityChecksPass = false;
656  if (maxStartProcess >= processNames_.size())
657  sanityChecksPass = false;
658  countZeroes = 0;
659  for (unsigned j = maxStartProcess; j < processNames_.size(); ++j) {
660  if (processNames_[j] == '\0') {
661  ++countZeroes;
662  }
663  }
664  if (countZeroes != 1)
665  sanityChecksPass = false;
666  }
667 
668  if (!sanityChecksPass) {
669  throw Exception(errors::LogicError) << "ProductResolverIndexHelper::setFrozen - Detected illegal state.\n";
670  }
671  }
672 
674  TypeID const& typeID,
675  std::string const& moduleLabel,
676  std::string const& instance,
677  std::string const& process,
679  : kindOfType_(kindOfType),
680  typeID_(typeID),
681  moduleLabel_(moduleLabel),
682  instance_(instance),
683  process_(process),
684  index_(index) {}
685 
687  if (kindOfType_ < right.kindOfType_)
688  return true;
689  if (kindOfType_ > right.kindOfType_)
690  return false;
691  if (typeID_ < right.typeID_)
692  return true;
693  if (typeID_ > right.typeID_)
694  return false;
695  if (moduleLabel_ < right.moduleLabel_)
696  return true;
697  if (moduleLabel_ > right.moduleLabel_)
698  return false;
699  if (instance_ < right.instance_)
700  return true;
701  if (instance_ > right.instance_)
702  return false;
703  return process_ < right.process_;
704  }
705 
706  void ProductResolverIndexHelper::print(std::ostream& os) const {
707  os << "\n******* Dump ProductResolverIndexHelper *************************\n";
708 
709  os << "\nnextIndexValue_ = " << nextIndexValue_ << "\n";
710  os << "beginElements_ = " << beginElements_ << "\n";
711 
712  os << "\n******* sortedTypeIDs_ \n";
713  for (auto const& i : sortedTypeIDs_) {
714  os << i << "\n";
715  }
716  os << "******* ranges_ \n";
717  for (auto const& i : ranges_) {
718  os << i.begin() << " " << i.end() << "\n";
719  }
720  os << "******* indexAndNames_ \n";
721  for (auto const& i : indexAndNames_) {
722  os << i.index() << " " << i.startInBigNamesContainer() << " ";
723  char const* ptr = &bigNamesContainer_[i.startInBigNamesContainer()];
724  while (*ptr) {
725  os << *ptr;
726  ++ptr;
727  }
728  ++ptr;
729  os << " ";
730  while (*ptr) {
731  os << *ptr;
732  ++ptr;
733  }
734  os << " " << i.startInProcessNames() << " ";
735  ptr = &processNames_[i.startInProcessNames()];
736  while (*ptr) {
737  os << *ptr;
738  ++ptr;
739  }
740  os << "\n";
741  }
742  os << "******* bigNamesContainer_ \n";
743  for (auto i : bigNamesContainer_) {
744  if (i == '\0')
745  os << '\\' << '0';
746  else
747  os << i;
748  }
749  if (!bigNamesContainer_.empty())
750  os << "\n";
751  os << "******* processNames_ \n";
752  for (auto i : processNames_) {
753  if (i == '\0')
754  os << '\\' << '0';
755  else
756  os << i;
757  }
758  if (!processNames_.empty())
759  os << "\n";
760  if (items_) {
761  os << "******* items_ \n";
762  for (auto const& item : *items_) {
763  std::cout << item.kindOfType() << " " << item.moduleLabel() << " " << item.instance() << " " << item.process()
764  << " " << item.index() << " " << item.typeID() << "\n";
765  }
766  }
767  if (processItems_) {
768  os << "******* processItems_ \n";
769  for (auto const& item : *processItems_) {
770  os << item << "\n";
771  }
772  }
773  os << "sortedTypeIDs_.size() = " << sortedTypeIDs_.size() << "\n";
774  os << "indexAndNames_.size() = " << indexAndNames_.size() << "\n";
775  os << "bigNamesContainer_.size() = " << bigNamesContainer_.size() << "\n";
776  os << "processNames_.size() = " << processNames_.size() << "\n";
777  os << "\n";
778  }
779 } // namespace edm
unsigned int processIndex(char const *process) const
Definition: start.py:1
TypeID getContainedType(TypeID const &typeID)
unsigned int ProductResolverIndex
bool public_base_classes(std::vector< std::string > &missingDictionaries, TypeID const &typeID, std::vector< TypeID > &baseTypes)
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
base
Main Program
Definition: newFWLiteAna.py:92
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)
ProductResolverIndex insert(TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process, TypeID const &containedTypeID, std::vector< TypeID > *baseTypesOfContainedType)
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