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);
48 if (
className.substr(0, amsize) == associationMap ||
className.substr(0, ndsize) == newDetSetVector) {
49 return TypeID(
typeid(
void));
51 TClass*
cl = TClass::GetClass(wrappedTypeID.
className().c_str());
53 return TypeID(
typeid(
void));
56 int offset =
cl->GetBaseClassOffset(wbClass) + vtcOffset;
57 std::unique_ptr<ViewTypeChecker> checker = getAnyPtr<ViewTypeChecker>(
p,
offset);
59 std::type_info
const& ti = checker->memberTypeInfo();
60 if (ti !=
typeid(
void)) {
64 return TypeID(checker->valueTypeInfo());
95 unsigned int startInIndexAndNames,
96 unsigned int numberOfMatches)
97 : productResolverIndexHelper_(productResolverIndexHelper),
98 startInIndexAndNames_(startInIndexAndNames),
99 numberOfMatches_(numberOfMatches) {
103 <<
"ProductResolverIndexHelper::Matches::Matches - Arguments exceed vector bounds.\n";
108 if (
i >= numberOfMatches_) {
111 return productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].index();
115 if (
i >= numberOfMatches_) {
117 <<
"ProductResolverIndexHelper::Matches::isFullyResolved - Argument is out of range.\n";
119 return (productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInProcessNames() != 0
U);
123 if (
i >= numberOfMatches_) {
125 <<
"ProductResolverIndexHelper::Matches::processName - Argument is out of range.\n";
127 unsigned int startInProcessNames =
128 productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInProcessNames();
129 return &productResolverIndexHelper_->processNames_[startInProcessNames];
133 if (
i >= numberOfMatches_) {
135 <<
"ProductResolverIndexHelper::Matches::moduleLabel - Argument is out of range.\n";
138 productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInBigNamesContainer();
139 return &productResolverIndexHelper_->bigNamesContainer_[
start];
147 unsigned int numberOfMatches = 1;
153 for (
unsigned int j = startInIndexAndNames + 1
U;
j < vSize && (
indexAndNames_[
j].startInProcessNames() != 0
U);
158 return Matches(
this, startInIndexAndNames, numberOfMatches);
162 TypeID const& typeID)
const {
164 unsigned int numberOfMatches = 0;
172 startInIndexAndNames =
range.begin();
173 numberOfMatches =
range.end() -
range.begin();
175 return Matches(
this, startInIndexAndNames, numberOfMatches);
182 TypeID const& containedTypeID,
183 std::vector<TypeWithDict>* baseTypesOfContainedType) {
186 <<
"ProductResolverIndexHelper::insert - Attempt to insert more elements after frozen.\n";
195 std::set<Item>::iterator iter =
items_->find(
item);
196 if (iter !=
items_->end()) {
198 <<
"ProductResolverIndexHelper::insert - Attempt to insert duplicate entry.\n";
211 if (iter ==
items_->end()) {
219 if (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID()) {
223 iter =
items_->find(containedItem);
224 if (iter !=
items_->end()) {
228 items_->insert(containedItem);
230 containedItem.clearProcess();
231 iter =
items_->find(containedItem);
232 if (iter ==
items_->end()) {
235 items_->insert(containedItem);
239 if (baseTypesOfContainedType) {
240 for (
TypeWithDict const& baseType : *baseTypesOfContainedType) {
241 TypeID baseTypeID(baseType.typeInfo());
243 iter =
items_->find(baseItem);
244 if (iter !=
items_->end()) {
250 baseItem.clearProcess();
251 iter =
items_->find(baseItem);
252 if (iter ==
items_->end()) {
260 return savedProductIndex;
268 bool hasContainedType = (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID());
269 std::vector<TypeWithDict> baseTypes;
270 std::vector<TypeWithDict>* baseTypesOfContainedType = &baseTypes;
271 if (hasContainedType) {
272 std::vector<std::string> missingDictionaries;
285 bool iFirstThisType =
true;
286 bool beginElementsWasSet =
false;
291 unsigned int iCountTypes = 0;
292 unsigned int iCountCharacters = 0;
294 if (iFirstThisType ||
item.typeID() != previousTypeID ||
item.kindOfType() != previousKindOfType) {
296 iFirstThisType =
true;
298 if (!beginElementsWasSet) {
300 beginElementsWasSet =
true;
309 if (iFirstThisType ||
item.moduleLabel() != previousModuleLabel ||
item.instance() != previousInstance) {
310 iCountCharacters +=
item.moduleLabel().size();
311 iCountCharacters +=
item.instance().size();
312 iCountCharacters += 2;
315 iFirstThisType =
false;
316 previousTypeID =
item.typeID();
317 previousKindOfType =
item.kindOfType();
318 previousModuleLabel =
item.moduleLabel();
319 previousInstance =
item.instance();
323 unsigned int processNamesSize = 0;
325 processNamesSize += processItem.size();
330 for (
auto const&
c : processItem) {
344 bool iFirstType =
true;
345 iFirstThisType =
true;
346 previousTypeID =
TypeID();
347 unsigned int iCount = 0;
348 unsigned int iBeginning = 0;
349 iCountCharacters = 0;
350 unsigned int previousCharacterCount = 0;
353 if (iFirstThisType ||
item.typeID() != previousTypeID ||
item.kindOfType() != previousKindOfType) {
354 iFirstThisType =
true;
365 if (iFirstThisType ||
item.moduleLabel() != previousModuleLabel ||
item.instance() != previousInstance) {
366 unsigned int labelSize =
item.moduleLabel().size();
367 for (
unsigned int j = 0;
j < labelSize; ++
j) {
372 unsigned int instanceSize =
item.instance().size();
373 for (
unsigned int j = 0;
j < instanceSize; ++
j) {
378 previousCharacterCount = iCountCharacters;
380 iCountCharacters += labelSize;
381 iCountCharacters += instanceSize;
382 iCountCharacters += 2;
388 <<
"ProductResolverIndexHelper::setFrozen - Process not found in processNames_.\n";
392 iFirstThisType =
false;
393 previousTypeID =
item.typeID();
394 previousKindOfType =
item.kindOfType();
395 previousModuleLabel =
item.moduleLabel();
396 previousInstance =
item.instance();
415 <<
"ProductResolverIndexHelper::lookupProcessNames - Attempt to access names before frozen.\n";
428 unsigned startProcess = 0;
446 while (*namePtr && (*namePtr == *
label)) {
450 if (*namePtr == *
label) {
461 if (startProcess ==
indexAndNames_[midpoint].startInProcessNames()) {
464 if (
indexAndNames_[midpoint].startInProcessNames() > startProcess) {
467 if (
indexAndNames_[midpoint].startInProcessNames() == startProcess) {
480 if (
indexAndNames_[midpoint].startInProcessNames() == startProcess) {
488 if (
begin == midpoint)
494 }
else if (*namePtr < *
label) {
495 if (
begin == midpoint)
507 unsigned int beginType = 0;
514 while (beginType < endType) {
515 unsigned int midpointType = beginType + ((endType - beginType) / 2);
519 if (beginType == midpointType)
521 beginType = midpointType;
523 endType = midpointType;
531 char const*
begin = ptr;
534 char const* beginName = ptr;
535 while (*ptr && (*ptr == *
p)) {
540 return beginName -
begin;
563 auto l = strlen(pModLabel);
564 auto pInstance = pModLabel +
l + 1;
573 bool sanityChecksPass =
true;
575 sanityChecksPass =
false;
577 unsigned int previousEnd = 0;
579 if (
range.begin() != previousEnd)
580 sanityChecksPass =
false;
582 sanityChecksPass =
false;
583 previousEnd =
range.end();
586 sanityChecksPass =
false;
588 unsigned maxStart = 0;
589 unsigned maxStartProcess = 0;
592 sanityChecksPass =
false;
595 sanityChecksPass =
false;
596 if (indexAndName.startInProcessNames() >=
processNames_.size())
597 sanityChecksPass =
false;
599 if (indexAndName.startInBigNamesContainer() > maxStart)
600 maxStart = indexAndName.startInBigNamesContainer();
601 if (indexAndName.startInProcessNames() > maxStartProcess)
602 maxStartProcess = indexAndName.startInProcessNames();
607 sanityChecksPass =
false;
609 sanityChecksPass =
false;
611 sanityChecksPass =
false;
612 unsigned int countZeroes = 0;
618 if (countZeroes != 2)
619 sanityChecksPass =
false;
621 sanityChecksPass =
false;
628 if (countZeroes != 1)
629 sanityChecksPass =
false;
632 if (!sanityChecksPass) {
643 : kindOfType_(kindOfType),
671 os <<
"\n******* Dump ProductResolverIndexHelper *************************\n";
676 os <<
"\n******* sortedTypeIDs_ \n";
680 os <<
"******* ranges_ \n";
682 os <<
i.begin() <<
" " <<
i.end() <<
"\n";
684 os <<
"******* indexAndNames_ \n";
686 os <<
i.index() <<
" " <<
i.startInBigNamesContainer() <<
" ";
698 os <<
" " <<
i.startInProcessNames() <<
" ";
706 os <<
"******* bigNamesContainer_ \n";
715 os <<
"******* processNames_ \n";
725 os <<
"******* items_ \n";
728 <<
" " <<
item.index() <<
" " <<
item.typeID() <<
"\n";
732 os <<
"******* processItems_ \n";
737 os <<
"sortedTypeIDs_.size() = " <<
sortedTypeIDs_.size() <<
"\n";
738 os <<
"indexAndNames_.size() = " <<
indexAndNames_.size() <<
"\n";
740 os <<
"processNames_.size() = " <<
processNames_.size() <<
"\n";