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<TypeWithDict> 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::isFullyResolved - Argument is out of range.\n";
145 return (productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInProcessNames() != 0
U);
149 if (
i >= numberOfMatches_) {
151 <<
"ProductResolverIndexHelper::Matches::processName - Argument is out of range.\n";
153 unsigned int startInProcessNames =
154 productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInProcessNames();
155 return &productResolverIndexHelper_->processNames_[startInProcessNames];
159 if (
i >= numberOfMatches_) {
161 <<
"ProductResolverIndexHelper::Matches::productInstanceName - Argument is out of range.\n";
164 productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInBigNamesContainer();
165 auto moduleLabelSize = strlen(&productResolverIndexHelper_->bigNamesContainer_[
start]);
166 return &productResolverIndexHelper_->bigNamesContainer_[
start + moduleLabelSize + 1];
170 if (
i >= numberOfMatches_) {
172 <<
"ProductResolverIndexHelper::Matches::moduleLabel - Argument is out of range.\n";
175 productResolverIndexHelper_->indexAndNames_[startInIndexAndNames_ +
i].startInBigNamesContainer();
176 return &productResolverIndexHelper_->bigNamesContainer_[
start];
184 unsigned int numberOfMatches = 1;
190 for (
unsigned int j = startInIndexAndNames + 1
U;
j < vSize && (
indexAndNames_[
j].startInProcessNames() != 0
U);
195 return Matches(
this, startInIndexAndNames, numberOfMatches);
199 TypeID const& typeID)
const {
201 unsigned int numberOfMatches = 0;
209 startInIndexAndNames =
range.begin();
210 numberOfMatches =
range.end() -
range.begin();
212 return Matches(
this, startInIndexAndNames, numberOfMatches);
219 TypeID const& containedTypeID,
220 std::vector<TypeWithDict>* baseTypesOfContainedType) {
223 <<
"ProductResolverIndexHelper::insert - Attempt to insert more elements after frozen.\n";
232 std::set<Item>::iterator iter =
items_->find(
item);
233 if (iter !=
items_->end()) {
235 <<
"ProductResolverIndexHelper::insert - Attempt to insert duplicate entry.\n";
248 if (iter ==
items_->end()) {
256 if (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID()) {
260 iter =
items_->find(containedItem);
261 if (iter !=
items_->end()) {
265 items_->insert(containedItem);
267 containedItem.clearProcess();
268 iter =
items_->find(containedItem);
269 if (iter ==
items_->end()) {
272 items_->insert(containedItem);
276 if (baseTypesOfContainedType) {
277 for (
TypeWithDict const& baseType : *baseTypesOfContainedType) {
278 TypeID baseTypeID(baseType.typeInfo());
280 iter =
items_->find(baseItem);
281 if (iter !=
items_->end()) {
287 baseItem.clearProcess();
288 iter =
items_->find(baseItem);
289 if (iter ==
items_->end()) {
297 return savedProductIndex;
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;
322 bool iFirstThisType =
true;
323 bool beginElementsWasSet =
false;
328 unsigned int iCountTypes = 0;
329 unsigned int iCountCharacters = 0;
331 if (iFirstThisType ||
item.typeID() != previousTypeID ||
item.kindOfType() != previousKindOfType) {
333 iFirstThisType =
true;
335 if (!beginElementsWasSet) {
337 beginElementsWasSet =
true;
346 if (iFirstThisType ||
item.moduleLabel() != previousModuleLabel ||
item.instance() != previousInstance) {
347 iCountCharacters +=
item.moduleLabel().size();
348 iCountCharacters +=
item.instance().size();
349 iCountCharacters += 2;
352 iFirstThisType =
false;
353 previousTypeID =
item.typeID();
354 previousKindOfType =
item.kindOfType();
355 previousModuleLabel =
item.moduleLabel();
356 previousInstance =
item.instance();
360 unsigned int processNamesSize = 0;
362 processNamesSize += processItem.size();
367 for (
auto const&
c : processItem) {
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;
390 if (iFirstThisType ||
item.typeID() != previousTypeID ||
item.kindOfType() != previousKindOfType) {
391 iFirstThisType =
true;
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) {
409 unsigned int instanceSize =
item.instance().size();
410 for (
unsigned int j = 0;
j < instanceSize; ++
j) {
415 previousCharacterCount = iCountCharacters;
417 iCountCharacters += labelSize;
418 iCountCharacters += instanceSize;
419 iCountCharacters += 2;
425 <<
"ProductResolverIndexHelper::setFrozen - Process not found in processNames_.\n";
429 iFirstThisType =
false;
430 previousTypeID =
item.typeID();
431 previousKindOfType =
item.kindOfType();
432 previousModuleLabel =
item.moduleLabel();
433 previousInstance =
item.instance();
452 <<
"ProductResolverIndexHelper::lookupProcessNames - Attempt to access names before frozen.\n";
465 unsigned startProcess = 0;
474 unsigned int begin =
range.begin();
477 while (begin <
end) {
478 unsigned int midpoint = begin + ((
end - begin) / 2);
483 while (*namePtr && (*namePtr == *
label)) {
487 if (*namePtr == *
label) {
498 if (startProcess ==
indexAndNames_[midpoint].startInProcessNames()) {
501 if (
indexAndNames_[midpoint].startInProcessNames() > startProcess) {
504 if (
indexAndNames_[midpoint].startInProcessNames() == startProcess) {
517 if (
indexAndNames_[midpoint].startInProcessNames() == startProcess) {
525 if (begin == midpoint)
531 }
else if (*namePtr < *
label) {
532 if (begin == midpoint)
544 unsigned int beginType = 0;
551 while (beginType < endType) {
552 unsigned int midpointType = beginType + ((endType - beginType) / 2);
556 if (beginType == midpointType)
558 beginType = midpointType;
560 endType = midpointType;
568 char const* begin = ptr;
571 char const* beginName = ptr;
572 while (*ptr && (*ptr == *
p)) {
577 return beginName - begin;
583 if (static_cast<unsigned>(ptr - begin) >=
processNames_.size()) {
600 auto l = strlen(pModLabel);
601 auto pInstance = pModLabel +
l + 1;
610 bool sanityChecksPass =
true;
612 sanityChecksPass =
false;
614 unsigned int previousEnd = 0;
616 if (
range.begin() != previousEnd)
617 sanityChecksPass =
false;
619 sanityChecksPass =
false;
620 previousEnd =
range.end();
623 sanityChecksPass =
false;
625 unsigned maxStart = 0;
626 unsigned maxStartProcess = 0;
629 sanityChecksPass =
false;
632 sanityChecksPass =
false;
633 if (indexAndName.startInProcessNames() >=
processNames_.size())
634 sanityChecksPass =
false;
636 if (indexAndName.startInBigNamesContainer() > maxStart)
637 maxStart = indexAndName.startInBigNamesContainer();
638 if (indexAndName.startInProcessNames() > maxStartProcess)
639 maxStartProcess = indexAndName.startInProcessNames();
644 sanityChecksPass =
false;
646 sanityChecksPass =
false;
648 sanityChecksPass =
false;
649 unsigned int countZeroes = 0;
655 if (countZeroes != 2)
656 sanityChecksPass =
false;
658 sanityChecksPass =
false;
665 if (countZeroes != 1)
666 sanityChecksPass =
false;
669 if (!sanityChecksPass) {
680 : kindOfType_(kindOfType),
708 os <<
"\n******* Dump ProductResolverIndexHelper *************************\n";
713 os <<
"\n******* sortedTypeIDs_ \n";
717 os <<
"******* ranges_ \n";
719 os <<
i.begin() <<
" " <<
i.end() <<
"\n";
721 os <<
"******* indexAndNames_ \n";
723 os <<
i.index() <<
" " <<
i.startInBigNamesContainer() <<
" ";
735 os <<
" " <<
i.startInProcessNames() <<
" ";
743 os <<
"******* bigNamesContainer_ \n";
752 os <<
"******* processNames_ \n";
762 os <<
"******* items_ \n";
765 <<
" " <<
item.index() <<
" " <<
item.typeID() <<
"\n";
769 os <<
"******* processItems_ \n";
774 os <<
"sortedTypeIDs_.size() = " <<
sortedTypeIDs_.size() <<
"\n";
775 os <<
"indexAndNames_.size() = " <<
indexAndNames_.size() <<
"\n";
777 os <<
"processNames_.size() = " <<
processNames_.size() <<
"\n";
unsigned int processIndex(char const *process) const
ProductResolverIndexHelper()
TypeID getContainedType(TypeID const &typeID)
bool operator<(Item const &right) const
std::vector< TypeID > sortedTypeIDs_
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
std::vector< char > processNames_
bool public_base_classes(std::vector< std::string > &missingDictionaries, TypeID const &typeID, std::vector< TypeWithDict > &baseTypes)
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
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_
bool isFullyResolved(unsigned int i) const
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)
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_