CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
edm::productholderindexhelper Namespace Reference

Functions

TypeID getContainedType (TypeID const &typeID)
 
TypeID getContainedTypeFromWrapper (TypeID const &wrappedtypeID, std::string const &className)
 

Function Documentation

TypeID edm::productholderindexhelper::getContainedType ( TypeID const &  typeID)

Definition at line 67 of file ProductResolverIndexHelper.cc.

References edm::TypeWithDict::byName(), className(), edm::TypeID::className(), getContainedTypeFromWrapper(), AlCaHLTBitMon_QueryRunRegistry::string, edm::TypeWithDict::typeInfo(), and edm::wrappedClassName().

Referenced by edm::ProductResolverIndexHelper::insert().

67  {
68  std::string className = typeID.className();
69  TypeWithDict const wrappedType = TypeWithDict::byName(wrappedClassName(className));
70  TypeID const wrappedTypeID = TypeID(wrappedType.typeInfo());
71  return getContainedTypeFromWrapper(wrappedTypeID, className);
72  }
TypeID getContainedTypeFromWrapper(TypeID const &wrappedtypeID, std::string const &className)
std::string wrappedClassName(std::string const &iFullName)
std::string className(const T &t)
Definition: ClassName.h:30
TypeID edm::productholderindexhelper::getContainedTypeFromWrapper ( TypeID const &  wrappedtypeID,
std::string const &  className 
)

Definition at line 20 of file ProductResolverIndexHelper.cc.

References GetRecoTauVFromDQM_MC_cff::cl, edm::TypeID::className(), PFRecoTauDiscriminationByIsolation_cfi::offset, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edm::ProductRegistry::checkDictionariesOfConsumedTypes(), getContainedType(), and edm::ProductRegistry::initializeLookupTables().

20  {
21  static int const vtcOffset = 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 associationMap("edm::AssociationMap<");
28  static std::string const newDetSetVector("edmNew::DetSetVector<");
29  static size_t const rvsize = refVector.size();
30  static size_t const rtbvsize = refToBaseVector.size();
31  static size_t const pvsize = ptrVector.size();
32  static size_t const vpsize = vectorPtr.size();
33  static size_t const amsize = associationMap.size();
34  static size_t const ndsize = newDetSetVector.size();
35  bool mayBeRefVector = (className.substr(0, rvsize) == refVector)
36  || (className.substr(0, rtbvsize) == refToBaseVector)
37  || (className.substr(0, pvsize) == ptrVector)
38  || (className.substr(0, vpsize) == vectorPtr);
39  // AssociationMap and edmNew::DetSetVector do not support View and
40  // this function is used to get a contained type that can be accessed
41  // using a View. So return the void type in these cases.
42  // In practice, they were the only types causing a problem, but any
43  // type with a typedef named value_type that does not support
44  // View might also cause problems and might need to be added here in
45  // the future.
46  if (className.substr(0, amsize) == associationMap ||
47  className.substr(0, ndsize) == newDetSetVector) {
48  return TypeID(typeid(void));
49  }
50  TClass* cl = TClass::GetClass(wrappedTypeID.className().c_str());
51  if(cl == nullptr) {
52  return TypeID(typeid(void));
53  }
54  void* p = cl->New();
55  int offset = cl->GetBaseClassOffset(wbClass) + vtcOffset;
56  std::unique_ptr<ViewTypeChecker> checker = getAnyPtr<ViewTypeChecker>(p, offset);
57  if(mayBeRefVector) {
58  std::type_info const& ti = checker->memberTypeInfo();
59  if(ti != typeid(void)) {
60  return TypeID(ti);
61  }
62  }
63  return TypeID(checker->valueTypeInfo());
64  }
std::string className(const T &t)
Definition: ClassName.h:30