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());
75 TypeID const& wrappedtypeID,
78 if (elementType ==
TypeID(
typeid(
void))
or elementType ==
TypeID()) {
82 if (elementType == requestedViewType) {
86 std::vector<std::string> missingDictionaries;
87 std::vector<TypeID> baseTypes;
91 for (
auto const&
base : baseTypes) {
92 if (
TypeID(
base.typeInfo()) == requestedViewType) {
102 : nextIndexValue_(0),
121 unsigned int startInIndexAndNames,
122 unsigned int numberOfMatches)
123 : productResolverIndexHelper_(productResolverIndexHelper),
124 startInIndexAndNames_(startInIndexAndNames),
125 numberOfMatches_(numberOfMatches) {
129 <<
"ProductResolverIndexHelper::Matches::Matches - Arguments exceed vector bounds.\n";
134 if (
i >= numberOfMatches_) {
137 return productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].index();
141 if (
i >= numberOfMatches_) {
143 <<
"ProductResolverIndexHelper::Matches::processName - Argument is out of range.\n";
145 unsigned int startInProcessNames =
146 productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInProcessNames();
147 return &productResolverIndexHelper_->processNames_[startInProcessNames];
151 if (
i >= numberOfMatches_) {
153 <<
"ProductResolverIndexHelper::Matches::productInstanceName - Argument is out of range.\n";
156 productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInBigNamesContainer();
157 auto moduleLabelSize = strlen(&productResolverIndexHelper_->bigNamesContainer_[
start]);
158 return &productResolverIndexHelper_->bigNamesContainer_[
start + moduleLabelSize + 1];
162 if (
i >= numberOfMatches_) {
164 <<
"ProductResolverIndexHelper::Matches::moduleLabel - Argument is out of range.\n";
167 productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInBigNamesContainer();
168 return &productResolverIndexHelper_->bigNamesContainer_[
start];
176 unsigned int numberOfMatches = 1;
182 for (
unsigned int j = startInIndexAndNames + 1
U;
j < vSize && (
indexAndNames_[
j].startInProcessNames() != 0
U);
187 return Matches(
this, startInIndexAndNames, numberOfMatches);
191 TypeID const& typeID)
const {
193 unsigned int numberOfMatches = 0;
201 startInIndexAndNames =
range.begin();
202 numberOfMatches =
range.end() -
range.begin();
204 return Matches(
this, startInIndexAndNames, numberOfMatches);
211 TypeID const& containedTypeID,
212 std::vector<TypeID>* baseTypesOfContainedType) {
215 <<
"ProductResolverIndexHelper::insert - Attempt to insert more elements after frozen.\n";
224 std::set<Item>::iterator iter =
items_->find(
item);
225 if (iter !=
items_->end()) {
227 <<
"ProductResolverIndexHelper::insert - Attempt to insert duplicate entry.\n";
240 if (iter ==
items_->end()) {
248 if (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID()) {
252 iter =
items_->find(containedItem);
253 if (iter !=
items_->end()) {
257 items_->insert(containedItem);
259 containedItem.clearProcess();
260 iter =
items_->find(containedItem);
261 if (iter ==
items_->end()) {
264 items_->insert(containedItem);
268 if (baseTypesOfContainedType) {
269 for (
TypeID const& baseTypeID : *baseTypesOfContainedType) {
271 iter =
items_->find(baseItem);
272 if (iter !=
items_->end()) {
279 iter =
items_->find(baseItem);
280 if (iter ==
items_->end()) {
288 return savedProductIndex;
296 bool hasContainedType = (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID());
297 std::vector<TypeID> baseTypes;
298 std::vector<TypeID>* baseTypesOfContainedType = &baseTypes;
299 if (hasContainedType) {
300 std::vector<std::string> missingDictionaries;
313 bool iFirstThisType =
true;
314 bool beginElementsWasSet =
false;
319 unsigned int iCountTypes = 0;
320 unsigned int iCountCharacters = 0;
322 if (iFirstThisType ||
item.typeID() != previousTypeID ||
item.kindOfType() != previousKindOfType) {
324 iFirstThisType =
true;
326 if (!beginElementsWasSet) {
328 beginElementsWasSet =
true;
337 if (iFirstThisType ||
item.moduleLabel() != previousModuleLabel ||
item.instance() != previousInstance) {
338 iCountCharacters +=
item.moduleLabel().size();
339 iCountCharacters +=
item.instance().size();
340 iCountCharacters += 2;
343 iFirstThisType =
false;
344 previousTypeID =
item.typeID();
345 previousKindOfType =
item.kindOfType();
346 previousModuleLabel =
item.moduleLabel();
347 previousInstance =
item.instance();
351 unsigned int processNamesSize = 0;
353 processNamesSize += processItem.size();
358 for (
auto const&
c : processItem) {
372 bool iFirstType =
true;
373 iFirstThisType =
true;
374 previousTypeID =
TypeID();
375 unsigned int iCount = 0;
376 unsigned int iBeginning = 0;
377 iCountCharacters = 0;
378 unsigned int previousCharacterCount = 0;
381 if (iFirstThisType ||
item.typeID() != previousTypeID ||
item.kindOfType() != previousKindOfType) {
382 iFirstThisType =
true;
393 if (iFirstThisType ||
item.moduleLabel() != previousModuleLabel ||
item.instance() != previousInstance) {
394 unsigned int labelSize =
item.moduleLabel().size();
395 for (
unsigned int j = 0;
j < labelSize; ++
j) {
400 unsigned int instanceSize =
item.instance().size();
401 for (
unsigned int j = 0;
j < instanceSize; ++
j) {
406 previousCharacterCount = iCountCharacters;
408 iCountCharacters += labelSize;
409 iCountCharacters += instanceSize;
410 iCountCharacters += 2;
416 <<
"ProductResolverIndexHelper::setFrozen - Process not found in processNames_.\n";
420 iFirstThisType =
false;
421 previousTypeID =
item.typeID();
422 previousKindOfType =
item.kindOfType();
423 previousModuleLabel =
item.moduleLabel();
424 previousInstance =
item.instance();
443 <<
"ProductResolverIndexHelper::lookupProcessNames - Attempt to access names before frozen.\n";
456 unsigned startProcess = 0;
465 unsigned int begin =
range.begin();
466 unsigned int end =
range.end();
468 while (begin < end) {
469 unsigned int midpoint = begin + ((end - begin) / 2);
474 while (*namePtr && (*namePtr == *
label)) {
478 if (*namePtr == *
label) {
482 char const* instanceName =
instance;
483 while (*namePtr && (*namePtr == *instanceName)) {
487 if (*namePtr == *instanceName) {
489 if (startProcess ==
indexAndNames_[midpoint].startInProcessNames()) {
492 if (
indexAndNames_[midpoint].startInProcessNames() > startProcess) {
495 if (
indexAndNames_[midpoint].startInProcessNames() == startProcess) {
508 if (
indexAndNames_[midpoint].startInProcessNames() == startProcess) {
515 }
else if (*namePtr < *instanceName) {
516 if (begin == midpoint)
522 }
else if (*namePtr < *
label) {
523 if (begin == midpoint)
535 unsigned int beginType = 0;
542 while (beginType < endType) {
543 unsigned int midpointType = beginType + ((endType - beginType) / 2);
547 if (beginType == midpointType)
549 beginType = midpointType;
551 endType = midpointType;
559 char const* begin = ptr;
562 char const* beginName = ptr;
563 while (*ptr && (*ptr == *
p)) {
568 return beginName - begin;
574 if (static_cast<unsigned>(ptr - begin) >=
processNames_.size()) {
591 auto l = strlen(pModLabel);
592 auto pInstance = pModLabel +
l + 1;
601 bool sanityChecksPass =
true;
603 sanityChecksPass =
false;
605 unsigned int previousEnd = 0;
607 if (
range.begin() != previousEnd)
608 sanityChecksPass =
false;
610 sanityChecksPass =
false;
611 previousEnd =
range.end();
614 sanityChecksPass =
false;
616 unsigned maxStart = 0;
617 unsigned maxStartProcess = 0;
620 sanityChecksPass =
false;
623 sanityChecksPass =
false;
624 if (indexAndName.startInProcessNames() >=
processNames_.size())
625 sanityChecksPass =
false;
627 if (indexAndName.startInBigNamesContainer() > maxStart)
628 maxStart = indexAndName.startInBigNamesContainer();
629 if (indexAndName.startInProcessNames() > maxStartProcess)
630 maxStartProcess = indexAndName.startInProcessNames();
635 sanityChecksPass =
false;
637 sanityChecksPass =
false;
639 sanityChecksPass =
false;
640 unsigned int countZeroes = 0;
646 if (countZeroes != 2)
647 sanityChecksPass =
false;
649 sanityChecksPass =
false;
656 if (countZeroes != 1)
657 sanityChecksPass =
false;
660 if (!sanityChecksPass) {
671 : kindOfType_(kindOfType),
699 os <<
"\n******* Dump ProductResolverIndexHelper *************************\n";
704 os <<
"\n******* sortedTypeIDs_ \n";
708 os <<
"******* ranges_ \n";
710 os <<
i.begin() <<
" " <<
i.end() <<
"\n";
712 os <<
"******* indexAndNames_ \n";
714 os <<
i.index() <<
" " <<
i.startInBigNamesContainer() <<
" ";
726 os <<
" " <<
i.startInProcessNames() <<
" ";
734 os <<
"******* bigNamesContainer_ \n";
743 os <<
"******* processNames_ \n";
753 os <<
"******* items_ \n";
756 <<
" " <<
item.index() <<
" " <<
item.typeID() <<
"\n";
760 os <<
"******* processItems_ \n";
765 os <<
"sortedTypeIDs_.size() = " <<
sortedTypeIDs_.size() <<
"\n";
766 os <<
"indexAndNames_.size() = " <<
indexAndNames_.size() <<
"\n";
768 os <<
"processNames_.size() = " <<
processNames_.size() <<
"\n";
unsigned int processIndex(char const *process) const
ProductResolverIndexHelper()
TypeID getContainedType(TypeID const &typeID)
void setIndex(ProductResolverIndex v)
bool operator<(Item const &right) const
std::vector< TypeID > sortedTypeIDs_
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)
PixelRecoRange< float > Range
static PFTauRenderPlugin instance
std::vector< char > processNames_
ModulesToIndiciesMap indiciesForModulesInProcess(const std::string &iProcessName) const
void print(std::ostream &os) const
unsigned int startInIndexAndNames_
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
static TypeWithDict byName(std::string const &name)
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
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)
std::vector< Range > ranges_
char const * moduleLabel(unsigned int i) const
ProductResolverIndex index(unsigned int i) const
ProductResolverIndex nextIndexValue_
std::string const & className() const
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 numberOfMatches_
unsigned int indexToType(KindOfType kindOfType, TypeID const &typeID) const
std::vector< IndexAndNames > const & indexAndNames() const
ProductResolverIndexHelper const * productResolverIndexHelper_
std::vector< std::string > const & lookupProcessNames() const
unsigned int beginElements_
constexpr const std::type_info & typeInfo() const
unsigned int numberOfMatches() const
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)
char const * productInstanceName(unsigned int i) const
std::vector< char > bigNamesContainer_