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::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<TypeID>* 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 (
TypeID const& baseTypeID : *baseTypesOfContainedType) {
279 iter =
items_->find(baseItem);
280 if (iter !=
items_->end()) {
287 iter =
items_->find(baseItem);
288 if (iter ==
items_->end()) {
296 return savedProductIndex;
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;
321 bool iFirstThisType =
true;
322 bool beginElementsWasSet =
false;
327 unsigned int iCountTypes = 0;
328 unsigned int iCountCharacters = 0;
330 if (iFirstThisType ||
item.typeID() != previousTypeID ||
item.kindOfType() != previousKindOfType) {
332 iFirstThisType =
true;
334 if (!beginElementsWasSet) {
336 beginElementsWasSet =
true;
345 if (iFirstThisType ||
item.moduleLabel() != previousModuleLabel ||
item.instance() != previousInstance) {
346 iCountCharacters +=
item.moduleLabel().size();
347 iCountCharacters +=
item.instance().size();
348 iCountCharacters += 2;
351 iFirstThisType =
false;
352 previousTypeID =
item.typeID();
353 previousKindOfType =
item.kindOfType();
354 previousModuleLabel =
item.moduleLabel();
355 previousInstance =
item.instance();
359 unsigned int processNamesSize = 0;
361 processNamesSize += processItem.size();
366 for (
auto const&
c : processItem) {
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;
389 if (iFirstThisType ||
item.typeID() != previousTypeID ||
item.kindOfType() != previousKindOfType) {
390 iFirstThisType =
true;
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) {
408 unsigned int instanceSize =
item.instance().size();
409 for (
unsigned int j = 0;
j < instanceSize; ++
j) {
414 previousCharacterCount = iCountCharacters;
416 iCountCharacters += labelSize;
417 iCountCharacters += instanceSize;
418 iCountCharacters += 2;
424 <<
"ProductResolverIndexHelper::setFrozen - Process not found in processNames_.\n";
428 iFirstThisType =
false;
429 previousTypeID =
item.typeID();
430 previousKindOfType =
item.kindOfType();
431 previousModuleLabel =
item.moduleLabel();
432 previousInstance =
item.instance();
451 <<
"ProductResolverIndexHelper::lookupProcessNames - Attempt to access names before frozen.\n";
464 unsigned startProcess = 0;
473 unsigned int begin =
range.begin();
474 unsigned int end =
range.end();
476 while (begin < end) {
477 unsigned int midpoint = begin + ((end - begin) / 2);
482 while (*namePtr && (*namePtr == *
label)) {
486 if (*namePtr == *
label) {
490 char const* instanceName =
instance;
491 while (*namePtr && (*namePtr == *instanceName)) {
495 if (*namePtr == *instanceName) {
497 if (startProcess ==
indexAndNames_[midpoint].startInProcessNames()) {
500 if (
indexAndNames_[midpoint].startInProcessNames() > startProcess) {
503 if (
indexAndNames_[midpoint].startInProcessNames() == startProcess) {
516 if (
indexAndNames_[midpoint].startInProcessNames() == startProcess) {
523 }
else if (*namePtr < *instanceName) {
524 if (begin == midpoint)
530 }
else if (*namePtr < *
label) {
531 if (begin == midpoint)
543 unsigned int beginType = 0;
550 while (beginType < endType) {
551 unsigned int midpointType = beginType + ((endType - beginType) / 2);
555 if (beginType == midpointType)
557 beginType = midpointType;
559 endType = midpointType;
567 char const* begin = ptr;
570 char const* beginName = ptr;
571 while (*ptr && (*ptr == *
p)) {
576 return beginName - begin;
582 if (static_cast<unsigned>(ptr - begin) >=
processNames_.size()) {
599 auto l = strlen(pModLabel);
600 auto pInstance = pModLabel +
l + 1;
609 bool sanityChecksPass =
true;
611 sanityChecksPass =
false;
613 unsigned int previousEnd = 0;
615 if (
range.begin() != previousEnd)
616 sanityChecksPass =
false;
618 sanityChecksPass =
false;
619 previousEnd =
range.end();
622 sanityChecksPass =
false;
624 unsigned maxStart = 0;
625 unsigned maxStartProcess = 0;
628 sanityChecksPass =
false;
631 sanityChecksPass =
false;
632 if (indexAndName.startInProcessNames() >=
processNames_.size())
633 sanityChecksPass =
false;
635 if (indexAndName.startInBigNamesContainer() > maxStart)
636 maxStart = indexAndName.startInBigNamesContainer();
637 if (indexAndName.startInProcessNames() > maxStartProcess)
638 maxStartProcess = indexAndName.startInProcessNames();
643 sanityChecksPass =
false;
645 sanityChecksPass =
false;
647 sanityChecksPass =
false;
648 unsigned int countZeroes = 0;
654 if (countZeroes != 2)
655 sanityChecksPass =
false;
657 sanityChecksPass =
false;
664 if (countZeroes != 1)
665 sanityChecksPass =
false;
668 if (!sanityChecksPass) {
679 : kindOfType_(kindOfType),
707 os <<
"\n******* Dump ProductResolverIndexHelper *************************\n";
712 os <<
"\n******* sortedTypeIDs_ \n";
716 os <<
"******* ranges_ \n";
718 os <<
i.begin() <<
" " <<
i.end() <<
"\n";
720 os <<
"******* indexAndNames_ \n";
722 os <<
i.index() <<
" " <<
i.startInBigNamesContainer() <<
" ";
734 os <<
" " <<
i.startInProcessNames() <<
" ";
742 os <<
"******* bigNamesContainer_ \n";
751 os <<
"******* processNames_ \n";
761 os <<
"******* items_ \n";
764 <<
" " <<
item.index() <<
" " <<
item.typeID() <<
"\n";
768 os <<
"******* processItems_ \n";
773 os <<
"sortedTypeIDs_.size() = " <<
sortedTypeIDs_.size() <<
"\n";
774 os <<
"indexAndNames_.size() = " <<
indexAndNames_.size() <<
"\n";
776 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)
static PFTauRenderPlugin instance
PixelRecoRange< float > Range
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_
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)
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_