From 3ae597231267ad0a4e587b7c74801cb729f5788a Mon Sep 17 00:00:00 2001 From: wmtan Date: Sun, 5 Oct 2014 06:45:21 +0200 Subject: [PATCH] Use compiler, not introspection, to find nested typedefs --- DataFormats/Common/interface/PtrVector.h | 1 + DataFormats/Common/interface/Wrapper.h | 49 ++++++ DataFormats/Common/interface/WrapperBase.h | 3 +- DataFormats/Common/src/WrapperBase.cc | 2 +- DataFormats/Common/src/classes_def.xml | 3 +- DataFormats/Common/test/DictionaryTools_t.cpp | 70 -------- .../interface/ProductHolderIndexHelper.h | 32 +++- .../Provenance/interface/ViewTypeChecker.h | 26 +++ .../src/ProductHolderIndexHelper.cc | 63 +++++-- DataFormats/Provenance/src/ProductRegistry.cc | 21 ++- DataFormats/Provenance/src/ViewTypeChecker.cc | 12 ++ DataFormats/Provenance/src/classes.h | 1 + DataFormats/Provenance/src/classes_def.xml | 3 + .../test/productHolderIndexHelperTest.cc | 8 +- .../productHolderIndexHelper_t.cppunit.cc | 57 +++---- .../TestObjects/interface/DeleteEarly.h | 1 + DataFormats/TestObjects/src/classes.h | 1 + DataFormats/TestObjects/src/classes_def.xml | 1 + .../test/edconsumerbase_t.cppunit.cc | 160 +++++++++--------- .../test/stubs/DeleteEarlyModules.cc | 5 + FWCore/Utilities/interface/DictionaryTools.h | 36 ---- FWCore/Utilities/interface/getAnyPtr.h | 26 +++ FWCore/Utilities/src/DictionaryTools.cc | 53 ------ IOPool/Common/interface/getWrapperBasePtr.h | 17 +- 24 files changed, 337 insertions(+), 314 deletions(-) create mode 100644 DataFormats/Provenance/interface/ViewTypeChecker.h create mode 100644 DataFormats/Provenance/src/ViewTypeChecker.cc create mode 100644 FWCore/Utilities/interface/getAnyPtr.h diff --git a/DataFormats/Common/interface/PtrVector.h b/DataFormats/Common/interface/PtrVector.h index f1b9b6d8d1dc5..0fafadcfda501 100644 --- a/DataFormats/Common/interface/PtrVector.h +++ b/DataFormats/Common/interface/PtrVector.h @@ -106,6 +106,7 @@ namespace edm { typedef PtrVectorItr const_iterator; typedef PtrVectorItr iterator; // make boost::sub_range happy (std allows this) typedef Ptr value_type; + typedef T member_type; typedef void collection_type; friend class PtrVectorItr; diff --git a/DataFormats/Common/interface/Wrapper.h b/DataFormats/Common/interface/Wrapper.h index f2a30857e0d5d..f00d47ece7fd9 100644 --- a/DataFormats/Common/interface/Wrapper.h +++ b/DataFormats/Common/interface/Wrapper.h @@ -53,6 +53,8 @@ namespace edm { virtual std::type_info const& dynamicTypeInfo_() const GCC11_OVERRIDE {return typeid(T);} virtual std::type_info const& wrappedTypeInfo_() const GCC11_OVERRIDE {return typeid(Wrapper);} + virtual std::type_info const& valueTypeInfo_() const GCC11_OVERRIDE; + virtual std::type_info const& memberTypeInfo_() const GCC11_OVERRIDE; #ifndef __GCCXML__ virtual bool isMergeable_() const GCC11_OVERRIDE; virtual bool mergeProduct_(WrapperBase const* newProduct) GCC11_OVERRIDE; @@ -254,6 +256,41 @@ namespace edm { }; #ifndef __GCCXML__ + + template static yes_tag& has_value_type(typename T::value_type*); + template static no_tag& has_value_type(...); + template struct has_typedef_value_type { + static const bool value = sizeof(has_value_type(nullptr)) == sizeof(yes_tag); + }; + template ::value> struct getValueType; + template struct getValueType { + std::type_info const& operator()() { + return typeid(typename T::value_type); + } + }; + template struct getValueType { + std::type_info const& operator()() { + return typeid(void); + } + }; + + template static yes_tag& has_member_type(typename T::member_type*); + template static no_tag& has_member_type(...); + template struct has_typedef_member_type { + static const bool value = sizeof(has_member_type(nullptr)) == sizeof(yes_tag); + }; + template ::value> struct getMemberType; + template struct getMemberType { + std::type_info const& operator()() { + return typeid(typename T::member_type); + } + }; + template struct getMemberType { + std::type_info const& operator()() { + return typeid(void); + } + }; + template struct mergeProduct_function; template no_tag has_mergeProduct_helper(...); template yes_tag has_mergeProduct_helper(mergeProduct_function * dummy); @@ -310,6 +347,18 @@ namespace edm { } #endif +#ifndef __GCCXML__ + template + std::type_info const& Wrapper::valueTypeInfo_() const { + return detail::getValueType()(); + } + + template + std::type_info const& Wrapper::memberTypeInfo_() const { + return detail::getMemberType()(); + } +#endif + #ifndef __GCCXML__ template bool Wrapper::isMergeable_() const { diff --git a/DataFormats/Common/interface/WrapperBase.h b/DataFormats/Common/interface/WrapperBase.h index 02eb2ebd7662d..693db38fc1906 100644 --- a/DataFormats/Common/interface/WrapperBase.h +++ b/DataFormats/Common/interface/WrapperBase.h @@ -8,12 +8,13 @@ WrapperBase: The base class of all things that will be inserted into the Event. ----------------------------------------------------------------------*/ #include "DataFormats/Common/interface/EDProductfwd.h" +#include "DataFormats/Provenance/interface/ViewTypeChecker.h" #include #include namespace edm { - class WrapperBase { + class WrapperBase : public ViewTypeChecker { public: WrapperBase(); virtual ~WrapperBase(); diff --git a/DataFormats/Common/src/WrapperBase.cc b/DataFormats/Common/src/WrapperBase.cc index 60a12a0e9ab3b..d4596e44d6ae0 100644 --- a/DataFormats/Common/src/WrapperBase.cc +++ b/DataFormats/Common/src/WrapperBase.cc @@ -7,7 +7,7 @@ #include namespace edm { - WrapperBase::WrapperBase() {} + WrapperBase::WrapperBase() : ViewTypeChecker() {} WrapperBase::~WrapperBase() {} diff --git a/DataFormats/Common/src/classes_def.xml b/DataFormats/Common/src/classes_def.xml index cc9da8ee2971b..60621f3af8dc9 100644 --- a/DataFormats/Common/src/classes_def.xml +++ b/DataFormats/Common/src/classes_def.xml @@ -1,6 +1,7 @@ - + + diff --git a/DataFormats/Common/test/DictionaryTools_t.cpp b/DataFormats/Common/test/DictionaryTools_t.cpp index c7cd0d5ce9845..ab64b04a3378e 100644 --- a/DataFormats/Common/test/DictionaryTools_t.cpp +++ b/DataFormats/Common/test/DictionaryTools_t.cpp @@ -20,11 +20,6 @@ class TestDictionaries: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TestDictionaries); CPPUNIT_TEST(default_is_invalid); CPPUNIT_TEST(no_dictionary_is_invalid); - CPPUNIT_TEST(find_nested); - CPPUNIT_TEST(burrowing); - CPPUNIT_TEST(burrowing_failure); - CPPUNIT_TEST(wrapper_type); - CPPUNIT_TEST(wrapper_type_failure); CPPUNIT_TEST(not_a_template_instance); CPPUNIT_TEST(demangling); CPPUNIT_TEST_SUITE_END(); @@ -37,11 +32,6 @@ class TestDictionaries: public CppUnit::TestFixture { void default_is_invalid(); void no_dictionary_is_invalid(); - void find_nested(); - void burrowing(); - void burrowing_failure(); - void wrapper_type(); - void wrapper_type_failure(); void not_a_template_instance(); void demangling(); @@ -61,66 +51,6 @@ void TestDictionaries::no_dictionary_is_invalid() { CPPUNIT_ASSERT(!t); } -void TestDictionaries::find_nested() { - edm::TypeWithDict intvec(edm::TypeWithDict::byName("std::vector")); - CPPUNIT_ASSERT(intvec); - - edm::TypeWithDict found_type; - - CPPUNIT_ASSERT(edm::find_nested_type_named("const_iterator", - intvec, - found_type)); - - CPPUNIT_ASSERT(!edm::find_nested_type_named("WankelRotaryEngine", - intvec, - found_type)); -} - -void TestDictionaries::burrowing() { - edm::TypeWithDict wrapper_type(typeid(edm::Wrapper)); - CPPUNIT_ASSERT(wrapper_type); - edm::TypeWithDict wrapped_type; - CPPUNIT_ASSERT(edm::find_nested_type_named("wrapped_type", - wrapper_type, - wrapped_type)); - CPPUNIT_ASSERT(wrapped_type); - edm::TypeWithDict wrapped_Dict_type(wrapped_type.typeInfo()); - CPPUNIT_ASSERT(!wrapped_Dict_type.isTypedef()); - CPPUNIT_ASSERT(wrapped_Dict_type.isFundamental()); - CPPUNIT_ASSERT(wrapped_type == edm::TypeWithDict::byName("int")); - CPPUNIT_ASSERT(wrapped_type.typeInfo() == typeid(int)); -} - -void TestDictionaries::burrowing_failure() { - edm::TypeWithDict not_a_wrapper(edm::TypeWithDict::byName("double")); - CPPUNIT_ASSERT(not_a_wrapper); - edm::TypeWithDict no_such_wrapped_type; - CPPUNIT_ASSERT(!no_such_wrapped_type); - CPPUNIT_ASSERT(!edm::find_nested_type_named("wrapped_type", - not_a_wrapper, - no_such_wrapped_type)); - CPPUNIT_ASSERT(!no_such_wrapped_type); -} - -void TestDictionaries::wrapper_type() { - edm::TypeWithDict wrapper_type(typeid(edm::Wrapper)); - edm::TypeWithDict wrapped_type; - CPPUNIT_ASSERT(edm::wrapper_type_of(wrapper_type, wrapped_type)); - edm::TypeWithDict wrapped_Dict_type(wrapped_type.typeInfo()); - CPPUNIT_ASSERT(!wrapped_Dict_type.isTypedef()); - CPPUNIT_ASSERT(wrapped_type == edm::TypeWithDict::byName("int")); -} - -void TestDictionaries::wrapper_type_failure() { - edm::TypeWithDict not_a_wrapper(edm::TypeWithDict::byName("double")); - CPPUNIT_ASSERT(not_a_wrapper); - edm::TypeWithDict no_such_wrapped_type; - CPPUNIT_ASSERT(!no_such_wrapped_type); - CPPUNIT_ASSERT(!edm::wrapper_type_of(not_a_wrapper, - no_such_wrapped_type)); - CPPUNIT_ASSERT(!no_such_wrapped_type); -} - void TestDictionaries::not_a_template_instance() { edm::TypeWithDict not_a_template(edm::TypeWithDict::byName("double")); CPPUNIT_ASSERT(not_a_template); diff --git a/DataFormats/Provenance/interface/ProductHolderIndexHelper.h b/DataFormats/Provenance/interface/ProductHolderIndexHelper.h index 8c244cf4a845f..1aebea0a42167 100644 --- a/DataFormats/Provenance/interface/ProductHolderIndexHelper.h +++ b/DataFormats/Provenance/interface/ProductHolderIndexHelper.h @@ -62,7 +62,24 @@ ProductRegistry is frozen. #include namespace edm { - class TypeWithDict; + + namespace productholderindexhelper { + // The next function supports views. For the given wrapped type, + // which must be Wrapper, + // this function returns the type of the contained type of T. + // If the type is not a recongnized container, it returns + // a TypeID(typeid(void)). + TypeID getContainedTypeFromWrapper(TypeID const& wrappedtypeID, std::string const& className); + + // The next function supports views. For the given type T, + // this function returns the type of the contained type of T. + // If the type is not a recongnized container, it returns + // a TypeID(typeid(void)). + // This calls getContainedTypefromWrapped internally + // If the TypeID for the wrapped type is already available, + // it is faster to call getContainedTypeFromWrapper directly. + TypeID getContainedType(TypeID const& typeID); + } class ProductHolderIndexHelper { public: @@ -152,10 +169,19 @@ namespace edm { // entry with a new ProductHolderIndex for the case // which searches for the most recent process. ProductHolderIndex - insert(TypeWithDict const& typeWithDict, + insert(TypeID const& typeID, + char const* moduleLabel, + char const* instance, + char const* process, + TypeID const& containedTypeID); + + ProductHolderIndex + insert(TypeID const& typeID, char const* moduleLabel, char const* instance, - char const* process); + char const* process) { + return insert(typeID, moduleLabel, instance, process, productholderindexhelper::getContainedType(typeID)); + } // Before the object is frozen the accessors above will // fail to find a match. Once frozen, no more new entries diff --git a/DataFormats/Provenance/interface/ViewTypeChecker.h b/DataFormats/Provenance/interface/ViewTypeChecker.h new file mode 100644 index 0000000000000..a21d53019cd82 --- /dev/null +++ b/DataFormats/Provenance/interface/ViewTypeChecker.h @@ -0,0 +1,26 @@ +#ifndef DataFormats_Provenance_ViewTypeChecker_h +#define DataFormats_Provenance_ViewTypeChecker_h + +/*---------------------------------------------------------------------- + +Checks for "value_type" and "member_type" typedefs inside T (of Wrapper). + +----------------------------------------------------------------------*/ + +#include + +namespace edm { + class ViewTypeChecker { + public: + ViewTypeChecker(); + virtual ~ViewTypeChecker(); + + std::type_info const& valueTypeInfo() const {return valueTypeInfo_();} + std::type_info const& memberTypeInfo() const {return memberTypeInfo_();} + + private: + virtual std::type_info const& valueTypeInfo_() const = 0; + virtual std::type_info const& memberTypeInfo_() const = 0; + }; +} +#endif diff --git a/DataFormats/Provenance/src/ProductHolderIndexHelper.cc b/DataFormats/Provenance/src/ProductHolderIndexHelper.cc index 35264a6fd237f..774415918e88b 100644 --- a/DataFormats/Provenance/src/ProductHolderIndexHelper.cc +++ b/DataFormats/Provenance/src/ProductHolderIndexHelper.cc @@ -1,14 +1,59 @@ #include "DataFormats/Provenance/interface/ProductHolderIndexHelper.h" +#include "DataFormats/Provenance/interface/ViewTypeChecker.h" #include "FWCore/Utilities/interface/DictionaryTools.h" #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/TypeWithDict.h" +#include "FWCore/Utilities/interface/WrappedClassName.h" +#include "FWCore/Utilities/interface/getAnyPtr.h" +#include + +#include #include #include namespace edm { + namespace productholderindexhelper { + TypeID + getContainedTypeFromWrapper(TypeID const& wrappedTypeID, std::string const& className) { + static int const vtcOffset = TClass::GetClass("edm::WrapperBase")->GetBaseClassOffset(TClass::GetClass("edm::ViewTypeChecker")); + static TClass const* const wbClass = TClass::GetClass("edm::WrapperBase"); + static std::string const refVector("edm::RefVector<"); + static std::string const refToBaseVector("edm::RefToBaseVector<"); + static std::string const ptrVector("edm::PtrVector<"); + static size_t rvsize = refVector.size(); + static size_t rtbvsize = refToBaseVector.size(); + static size_t pvsize = ptrVector.size(); + bool mayBeRefVector = (className.substr(0, rvsize) == refVector) + || (className.substr(0, rtbvsize) == refToBaseVector) + || (className.substr(0, pvsize) == ptrVector); + TClass* cl = TClass::GetClass(wrappedTypeID.className().c_str()); + if(cl == nullptr) { + return TypeID(typeid(void)); + } + void* p = cl->New(); + int offset = cl->GetBaseClassOffset(wbClass) + vtcOffset;; + std::unique_ptr checker = getAnyPtr(p, offset); + if(mayBeRefVector) { + std::type_info const& ti = checker->memberTypeInfo(); + if(ti != typeid(void)) { + return TypeID(ti); + } + } + return TypeID(checker->valueTypeInfo()); + } + + TypeID + getContainedType(TypeID const& typeID) { + std::string className = typeID.className(); + TypeWithDict const wrappedType = TypeWithDict::byName(wrappedClassName(className)); + TypeID const wrappedTypeID = TypeID(wrappedType.typeInfo()); + return getContainedTypeFromWrapper(wrappedTypeID, className); + } + } + ProductHolderIndexHelper::ProductHolderIndexHelper() : nextIndexValue_(0), beginElements_(0), @@ -112,10 +157,11 @@ namespace edm { } ProductHolderIndex - ProductHolderIndexHelper::insert(TypeWithDict const& typeWithDict, + ProductHolderIndexHelper::insert(TypeID const& typeID, char const* moduleLabel, char const* instance, - char const* process) { + char const* process, + TypeID const& containedTypeID) { if (!items_) { throw Exception(errors::LogicError) << "ProductHolderIndexHelper::insert - Attempt to insert more elements after frozen.\n"; @@ -126,8 +172,6 @@ namespace edm { << "ProductHolderIndexHelper::insert - Empty process.\n"; } - TypeID typeID(typeWithDict.typeInfo()); - // Throw if this has already been inserted Item item(PRODUCT_TYPE, typeID, moduleLabel, instance, process, 0); std::set::iterator iter = items_->find(item); @@ -154,14 +198,9 @@ namespace edm { // Now put in entries for a contained class if this is a // recognized container. - TypeWithDict containedType; - if((is_RefVector(typeWithDict, containedType) || - is_PtrVector(typeWithDict, containedType) || - is_RefToBaseVector(typeWithDict, containedType) || - value_type_of(typeWithDict, containedType)) - && bool(containedType)) { - - TypeID containedTypeID(containedType.typeInfo()); + if(containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID()) { + TypeWithDict containedType(containedTypeID.typeInfo()); + Item containedItem(ELEMENT_TYPE, containedTypeID, moduleLabel, instance, process, savedProductIndex); iter = items_->find(containedItem); if (iter != items_->end()) { diff --git a/DataFormats/Provenance/src/ProductRegistry.cc b/DataFormats/Provenance/src/ProductRegistry.cc index a2775d13d34db..9b082ad45c82c 100644 --- a/DataFormats/Provenance/src/ProductRegistry.cc +++ b/DataFormats/Provenance/src/ProductRegistry.cc @@ -266,7 +266,7 @@ namespace edm { } void ProductRegistry::initializeLookupTables() { - + std::map containedTypeMap; StringSet missingDicts; transient_.branchIDToIndex_.clear(); constProductList().clear(); @@ -283,16 +283,25 @@ namespace edm { //only do the following if the data is supposed to be available in the event if(desc.present()) { - TypeWithDict type(TypeWithDict::byName(desc.className())); - TypeWithDict wrappedType(TypeWithDict::byName(wrappedClassName(desc.className()))); - if(!bool(type) || !bool(wrappedType)) { + if(!bool(desc.unwrappedType()) || !bool(desc.wrappedType())) { missingDicts.insert(desc.className()); } else { + TypeID wrappedTypeID(desc.wrappedType().typeInfo()); + TypeID typeID(desc.unwrappedType().typeInfo()); + TypeID containedTypeID; + auto const& iter = containedTypeMap.find(typeID); + if(iter != containedTypeMap.end()) { + containedTypeID = iter->second; + } else { + containedTypeID = productholderindexhelper::getContainedTypeFromWrapper(wrappedTypeID, typeID.className()); + containedTypeMap.emplace(typeID, containedTypeID); + } ProductHolderIndex index = - productLookup(desc.branchType())->insert(type, + productLookup(desc.branchType())->insert(typeID, desc.moduleLabel().c_str(), desc.productInstanceName().c_str(), - desc.processName().c_str()); + desc.processName().c_str(), + containedTypeID); transient_.branchIDToIndex_[desc.branchID()] = index; } diff --git a/DataFormats/Provenance/src/ViewTypeChecker.cc b/DataFormats/Provenance/src/ViewTypeChecker.cc new file mode 100644 index 0000000000000..3d1157781e3b9 --- /dev/null +++ b/DataFormats/Provenance/src/ViewTypeChecker.cc @@ -0,0 +1,12 @@ +/*---------------------------------------------------------------------- + +----------------------------------------------------------------------*/ + +#include "DataFormats/Provenance/interface/ViewTypeChecker.h" +#include + +namespace edm { + ViewTypeChecker::ViewTypeChecker() {} + + ViewTypeChecker::~ViewTypeChecker() {} +} diff --git a/DataFormats/Provenance/src/classes.h b/DataFormats/Provenance/src/classes.h index db79694c9ee88..10308a62e8258 100644 --- a/DataFormats/Provenance/src/classes.h +++ b/DataFormats/Provenance/src/classes.h @@ -32,6 +32,7 @@ #include "DataFormats/Provenance/interface/ThinnedAssociationsHelper.h" #include "DataFormats/Provenance/interface/Timestamp.h" #include "DataFormats/Provenance/interface/ESRecordAuxiliary.h" +#include "DataFormats/Provenance/interface/ViewTypeChecker.h" #include "FWCore/Utilities/interface/typedefs.h" #include #include diff --git a/DataFormats/Provenance/src/classes_def.xml b/DataFormats/Provenance/src/classes_def.xml index c9c5073b4e824..8c65e1512e259 100644 --- a/DataFormats/Provenance/src/classes_def.xml +++ b/DataFormats/Provenance/src/classes_def.xml @@ -1,4 +1,7 @@ + + + diff --git a/DataFormats/Provenance/test/productHolderIndexHelperTest.cc b/DataFormats/Provenance/test/productHolderIndexHelperTest.cc index a353987945397..e2398f65025f8 100644 --- a/DataFormats/Provenance/test/productHolderIndexHelperTest.cc +++ b/DataFormats/Provenance/test/productHolderIndexHelperTest.cc @@ -6,7 +6,6 @@ #include "FWCore/RootAutoLibraryLoader/interface/RootAutoLibraryLoader.h" #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/ProductKindOfType.h" -#include "FWCore/Utilities/interface/TypeWithDict.h" #include "TClass.h" @@ -139,21 +138,16 @@ int main() { // most of the total time as well. TClass* clss = TClass::GetClass(n.className.c_str()); - TypeWithDict typeWithDict; - if (n.className == "bool") { n.typeID = TypeID(typeid(bool)); - typeWithDict = TypeWithDict(typeid(bool)); } else if (n.className == "double") { n.typeID = TypeID(typeid(double)); - typeWithDict = TypeWithDict(typeid(double)); } else { n.typeID = TypeID(*clss->GetTypeInfo()); - typeWithDict = TypeWithDict(*clss->GetTypeInfo()); } timer.start(); - phih.insert(typeWithDict, + phih.insert(n.typeID, n.label.c_str(), n.instance.c_str(), n.process.c_str()); diff --git a/DataFormats/Provenance/test/productHolderIndexHelper_t.cppunit.cc b/DataFormats/Provenance/test/productHolderIndexHelper_t.cppunit.cc index 93ba78090251b..1771e295ecd18 100644 --- a/DataFormats/Provenance/test/productHolderIndexHelper_t.cppunit.cc +++ b/DataFormats/Provenance/test/productHolderIndexHelper_t.cppunit.cc @@ -13,7 +13,6 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/Utilities/interface/ProductKindOfType.h" #include "FWCore/Utilities/interface/TypeID.h" -#include "FWCore/Utilities/interface/TypeWithDict.h" #include #include @@ -72,16 +71,16 @@ void TestProductHolderIndexHelper::testCreateEmpty() { matches = helper.relatedIndexes(PRODUCT_TYPE, typeID_ProductID); CPPUNIT_ASSERT(matches.numberOfMatches() == 0); - TypeWithDict typeWithDict(typeid(ProductID)); - CPPUNIT_ASSERT_THROW( helper.insert(typeWithDict, "labelA", "instanceA", "processA") , cms::Exception); + TypeID typeID(typeid(ProductID)); + CPPUNIT_ASSERT_THROW( helper.insert(typeID, "labelA", "instanceA", "processA") , cms::Exception); } void TestProductHolderIndexHelper::testOneEntry() { edm::ProductHolderIndexHelper helper; - TypeWithDict typeWithDictProductID(typeid(ProductID)); - helper.insert(typeWithDictProductID, "labelA", "instanceA", "processA"); + TypeID typeIDProductID(typeid(ProductID)); + helper.insert(typeIDProductID, "labelA", "instanceA", "processA"); CPPUNIT_ASSERT(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "processA") == ProductHolderIndexInvalid); CPPUNIT_ASSERT(helper.index(ELEMENT_TYPE, typeID_ProductID, "labelA", "instanceA", "processA") == ProductHolderIndexInvalid); @@ -141,30 +140,30 @@ void TestProductHolderIndexHelper::testManyEntries() { edm::ProductHolderIndexHelper helper; - TypeWithDict typeWithDictProductID(typeid(ProductID)); - TypeWithDict typeWithDictEventID(typeid(EventID)); - TypeWithDict typeWithDictVectorInt(typeid(std::vector)); - TypeWithDict typeWithDictSetInt(typeid(std::set)); - TypeWithDict typeWithDictVSimpleDerived(typeid(std::vector)); - - helper.insert(typeWithDictVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 - helper.insert(typeWithDictVectorInt, "label", "instance", "process"); // 3, 4, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB"); // 6, 7 - helper.insert(typeWithDictEventID, "label", "instanceB", "processB"); // 8, 9 - helper.insert(typeWithDictEventID, "labelX", "instanceB", "processB"); // 10, 11 - helper.insert(typeWithDictEventID, "labelB", "instance", "processB"); // 12, 13 - helper.insert(typeWithDictEventID, "labelB", "instanceX", "processB"); // 14, 15 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB1"); // 16, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB3"); // 17, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB2"); // 18, 5 - helper.insert(typeWithDictProductID, "label", "instance", "process"); // 19, 20 - helper.insert(typeWithDictEventID, "label", "instance", "process"); // 21, 22 - helper.insert(typeWithDictProductID, "labelA", "instanceA", "processA"); // 23, 24 - CPPUNIT_ASSERT_THROW(helper.insert(typeWithDictProductID, "labelA", "instanceA", "processA"), cms::Exception); // duplicate - - helper.insert(typeWithDictSetInt, "labelC", "instanceC", "processC"); // 25, 26 - - helper.insert(typeWithDictVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 + TypeID typeIDProductID(typeid(ProductID)); + TypeID typeIDEventID(typeid(EventID)); + TypeID typeIDVectorInt(typeid(std::vector)); + TypeID typeIDSetInt(typeid(std::set)); + TypeID typeIDVSimpleDerived(typeid(std::vector)); + + helper.insert(typeIDVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 + helper.insert(typeIDVectorInt, "label", "instance", "process"); // 3, 4, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB"); // 6, 7 + helper.insert(typeIDEventID, "label", "instanceB", "processB"); // 8, 9 + helper.insert(typeIDEventID, "labelX", "instanceB", "processB"); // 10, 11 + helper.insert(typeIDEventID, "labelB", "instance", "processB"); // 12, 13 + helper.insert(typeIDEventID, "labelB", "instanceX", "processB"); // 14, 15 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB1"); // 16, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB3"); // 17, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB2"); // 18, 5 + helper.insert(typeIDProductID, "label", "instance", "process"); // 19, 20 + helper.insert(typeIDEventID, "label", "instance", "process"); // 21, 22 + helper.insert(typeIDProductID, "labelA", "instanceA", "processA"); // 23, 24 + CPPUNIT_ASSERT_THROW(helper.insert(typeIDProductID, "labelA", "instanceA", "processA"), cms::Exception); // duplicate + + helper.insert(typeIDSetInt, "labelC", "instanceC", "processC"); // 25, 26 + + helper.insert(typeIDVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 // helper.print(std::cout); helper.setFrozen(); diff --git a/DataFormats/TestObjects/interface/DeleteEarly.h b/DataFormats/TestObjects/interface/DeleteEarly.h index c699ca2f9e3cd..072d3afbed8fb 100644 --- a/DataFormats/TestObjects/interface/DeleteEarly.h +++ b/DataFormats/TestObjects/interface/DeleteEarly.h @@ -34,6 +34,7 @@ namespace edmtest { // ---------- static member functions -------------------- static unsigned int nDeletes() {return s_nDeletes;} + static void resetDeleteCount() {s_nDeletes = 0;} // ---------- member functions --------------------------- diff --git a/DataFormats/TestObjects/src/classes.h b/DataFormats/TestObjects/src/classes.h index 411cb03bf5788..e6e9c915d94fc 100644 --- a/DataFormats/TestObjects/src/classes.h +++ b/DataFormats/TestObjects/src/classes.h @@ -68,6 +68,7 @@ struct dictionary { edm::DetSet x2; std::vector x3; std::vector x4; + edm::Wrapper > dummy99; edm::Ref > dummyRefThings; edm::reftobase::Holder > > bhThing; diff --git a/DataFormats/TestObjects/src/classes_def.xml b/DataFormats/TestObjects/src/classes_def.xml index e152bc66cbae2..0b7bc316fb79a 100644 --- a/DataFormats/TestObjects/src/classes_def.xml +++ b/DataFormats/TestObjects/src/classes_def.xml @@ -42,6 +42,7 @@ + diff --git a/FWCore/Framework/test/edconsumerbase_t.cppunit.cc b/FWCore/Framework/test/edconsumerbase_t.cppunit.cc index d8e3294878a2c..7fab71de16819 100644 --- a/FWCore/Framework/test/edconsumerbase_t.cppunit.cc +++ b/FWCore/Framework/test/edconsumerbase_t.cppunit.cc @@ -133,27 +133,27 @@ TestEDConsumerBase::testRegularType() edm::ProductHolderIndexHelper helper; - edm::TypeWithDict typeWithDictProductID(typeid(edm::ProductID)); - edm::TypeWithDict typeWithDictEventID(typeid(edm::EventID)); - edm::TypeWithDict typeWithDictVectorInt(typeid(std::vector)); - edm::TypeWithDict typeWithDictSetInt(typeid(std::set)); - edm::TypeWithDict typeWithDictVSimpleDerived(typeid(std::vector)); + edm::TypeID typeIDProductID(typeid(edm::ProductID)); + edm::TypeID typeIDEventID(typeid(edm::EventID)); + edm::TypeID typeIDVectorInt(typeid(std::vector)); + edm::TypeID typeIDSetInt(typeid(std::set)); + edm::TypeID typeIDVSimpleDerived(typeid(std::vector)); - helper.insert(typeWithDictVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 - helper.insert(typeWithDictVectorInt, "label", "instance", "process"); // 3, 4, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB"); // 6, 7 - helper.insert(typeWithDictEventID, "label", "instanceB", "processB"); // 8, 9 - helper.insert(typeWithDictEventID, "labelX", "instanceB", "processB"); // 10, 11 - helper.insert(typeWithDictEventID, "labelB", "instance", "processB"); // 12, 13 - helper.insert(typeWithDictEventID, "labelB", "instanceX", "processB"); // 14, 15 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB1"); // 16, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB3"); // 17, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB2"); // 18, 5 - helper.insert(typeWithDictProductID, "label", "instance", "process"); // 19, 20 - helper.insert(typeWithDictEventID, "label", "instance", "process"); // 21, 22 - helper.insert(typeWithDictProductID, "labelA", "instanceA", "processA"); // 23, 24 - helper.insert(typeWithDictSetInt, "labelC", "instanceC", "processC"); // 25, 26 - helper.insert(typeWithDictVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 + helper.insert(typeIDVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 + helper.insert(typeIDVectorInt, "label", "instance", "process"); // 3, 4, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB"); // 6, 7 + helper.insert(typeIDEventID, "label", "instanceB", "processB"); // 8, 9 + helper.insert(typeIDEventID, "labelX", "instanceB", "processB"); // 10, 11 + helper.insert(typeIDEventID, "labelB", "instance", "processB"); // 12, 13 + helper.insert(typeIDEventID, "labelB", "instanceX", "processB"); // 14, 15 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB1"); // 16, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB3"); // 17, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB2"); // 18, 5 + helper.insert(typeIDProductID, "label", "instance", "process"); // 19, 20 + helper.insert(typeIDEventID, "label", "instance", "process"); // 21, 22 + helper.insert(typeIDProductID, "labelA", "instanceA", "processA"); // 23, 24 + helper.insert(typeIDSetInt, "labelC", "instanceC", "processC"); // 25, 26 + helper.insert(typeIDVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 helper.setFrozen(); @@ -315,27 +315,27 @@ TestEDConsumerBase::testViewType() { edm::ProductHolderIndexHelper helper; - edm::TypeWithDict typeWithDictProductID(typeid(edm::ProductID)); - edm::TypeWithDict typeWithDictEventID(typeid(edm::EventID)); - edm::TypeWithDict typeWithDictVectorInt(typeid(std::vector)); - edm::TypeWithDict typeWithDictSetInt(typeid(std::set)); - edm::TypeWithDict typeWithDictVSimpleDerived(typeid(std::vector)); + edm::TypeID typeIDProductID(typeid(edm::ProductID)); + edm::TypeID typeIDEventID(typeid(edm::EventID)); + edm::TypeID typeIDVectorInt(typeid(std::vector)); + edm::TypeID typeIDSetInt(typeid(std::set)); + edm::TypeID typeIDVSimpleDerived(typeid(std::vector)); - helper.insert(typeWithDictVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 - helper.insert(typeWithDictVectorInt, "label", "instance", "process"); // 3, 4, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB"); // 6, 7 - helper.insert(typeWithDictEventID, "label", "instanceB", "processB"); // 8, 9 - helper.insert(typeWithDictEventID, "labelX", "instanceB", "processB"); // 10, 11 - helper.insert(typeWithDictEventID, "labelB", "instance", "processB"); // 12, 13 - helper.insert(typeWithDictEventID, "labelB", "instanceX", "processB"); // 14, 15 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB1"); // 16, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB3"); // 17, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB2"); // 18, 5 - helper.insert(typeWithDictProductID, "label", "instance", "process"); // 19, 20 - helper.insert(typeWithDictEventID, "label", "instance", "process"); // 21, 22 - helper.insert(typeWithDictProductID, "labelA", "instanceA", "processA"); // 23, 24 - helper.insert(typeWithDictSetInt, "labelC", "instanceC", "processC"); // 25, 26 - helper.insert(typeWithDictVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 + helper.insert(typeIDVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 + helper.insert(typeIDVectorInt, "label", "instance", "process"); // 3, 4, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB"); // 6, 7 + helper.insert(typeIDEventID, "label", "instanceB", "processB"); // 8, 9 + helper.insert(typeIDEventID, "labelX", "instanceB", "processB"); // 10, 11 + helper.insert(typeIDEventID, "labelB", "instance", "processB"); // 12, 13 + helper.insert(typeIDEventID, "labelB", "instanceX", "processB"); // 14, 15 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB1"); // 16, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB3"); // 17, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB2"); // 18, 5 + helper.insert(typeIDProductID, "label", "instance", "process"); // 19, 20 + helper.insert(typeIDEventID, "label", "instance", "process"); // 21, 22 + helper.insert(typeIDProductID, "labelA", "instanceA", "processA"); // 23, 24 + helper.insert(typeIDSetInt, "labelC", "instanceC", "processC"); // 25, 26 + helper.insert(typeIDVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 helper.setFrozen(); @@ -436,27 +436,27 @@ TestEDConsumerBase::testMany() edm::ProductHolderIndexHelper helper; - edm::TypeWithDict typeWithDictProductID(typeid(edm::ProductID)); - edm::TypeWithDict typeWithDictEventID(typeid(edm::EventID)); - edm::TypeWithDict typeWithDictVectorInt(typeid(std::vector)); - edm::TypeWithDict typeWithDictSetInt(typeid(std::set)); - edm::TypeWithDict typeWithDictVSimpleDerived(typeid(std::vector)); + edm::TypeID typeIDProductID(typeid(edm::ProductID)); + edm::TypeID typeIDEventID(typeid(edm::EventID)); + edm::TypeID typeIDVectorInt(typeid(std::vector)); + edm::TypeID typeIDSetInt(typeid(std::set)); + edm::TypeID typeIDVSimpleDerived(typeid(std::vector)); - helper.insert(typeWithDictVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 - helper.insert(typeWithDictVectorInt, "label", "instance", "process"); // 3, 4, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB"); // 6, 7 - helper.insert(typeWithDictEventID, "label", "instanceB", "processB"); // 8, 9 - helper.insert(typeWithDictEventID, "labelX", "instanceB", "processB"); // 10, 11 - helper.insert(typeWithDictEventID, "labelB", "instance", "processB"); // 12, 13 - helper.insert(typeWithDictEventID, "labelB", "instanceX", "processB"); // 14, 15 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB1"); // 16, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB3"); // 17, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB2"); // 18, 5 - helper.insert(typeWithDictProductID, "label", "instance", "process"); // 19, 20 - helper.insert(typeWithDictEventID, "label", "instance", "process"); // 21, 22 - helper.insert(typeWithDictProductID, "labelA", "instanceA", "processA"); // 23, 24 - helper.insert(typeWithDictSetInt, "labelC", "instanceC", "processC"); // 25, 26 - helper.insert(typeWithDictVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 + helper.insert(typeIDVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 + helper.insert(typeIDVectorInt, "label", "instance", "process"); // 3, 4, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB"); // 6, 7 + helper.insert(typeIDEventID, "label", "instanceB", "processB"); // 8, 9 + helper.insert(typeIDEventID, "labelX", "instanceB", "processB"); // 10, 11 + helper.insert(typeIDEventID, "labelB", "instance", "processB"); // 12, 13 + helper.insert(typeIDEventID, "labelB", "instanceX", "processB"); // 14, 15 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB1"); // 16, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB3"); // 17, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB2"); // 18, 5 + helper.insert(typeIDProductID, "label", "instance", "process"); // 19, 20 + helper.insert(typeIDEventID, "label", "instance", "process"); // 21, 22 + helper.insert(typeIDProductID, "labelA", "instanceA", "processA"); // 23, 24 + helper.insert(typeIDSetInt, "labelC", "instanceC", "processC"); // 25, 26 + helper.insert(typeIDVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 helper.setFrozen(); @@ -482,27 +482,27 @@ TestEDConsumerBase::testMay() edm::ProductHolderIndexHelper helper; - edm::TypeWithDict typeWithDictProductID(typeid(edm::ProductID)); - edm::TypeWithDict typeWithDictEventID(typeid(edm::EventID)); - edm::TypeWithDict typeWithDictVectorInt(typeid(std::vector)); - edm::TypeWithDict typeWithDictSetInt(typeid(std::set)); - edm::TypeWithDict typeWithDictVSimpleDerived(typeid(std::vector)); + edm::TypeID typeIDProductID(typeid(edm::ProductID)); + edm::TypeID typeIDEventID(typeid(edm::EventID)); + edm::TypeID typeIDVectorInt(typeid(std::vector)); + edm::TypeID typeIDSetInt(typeid(std::set)); + edm::TypeID typeIDVSimpleDerived(typeid(std::vector)); - helper.insert(typeWithDictVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 - helper.insert(typeWithDictVectorInt, "label", "instance", "process"); // 3, 4, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB"); // 6, 7 - helper.insert(typeWithDictEventID, "label", "instanceB", "processB"); // 8, 9 - helper.insert(typeWithDictEventID, "labelX", "instanceB", "processB"); // 10, 11 - helper.insert(typeWithDictEventID, "labelB", "instance", "processB"); // 12, 13 - helper.insert(typeWithDictEventID, "labelB", "instanceX", "processB"); // 14, 15 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB1"); // 16, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB3"); // 17, 5 - helper.insert(typeWithDictEventID, "labelB", "instanceB", "processB2"); // 18, 5 - helper.insert(typeWithDictProductID, "label", "instance", "process"); // 19, 20 - helper.insert(typeWithDictEventID, "label", "instance", "process"); // 21, 22 - helper.insert(typeWithDictProductID, "labelA", "instanceA", "processA"); // 23, 24 - helper.insert(typeWithDictSetInt, "labelC", "instanceC", "processC"); // 25, 26 - helper.insert(typeWithDictVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 + helper.insert(typeIDVectorInt, "labelC", "instanceC", "processC"); // 0, 1, 2 + helper.insert(typeIDVectorInt, "label", "instance", "process"); // 3, 4, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB"); // 6, 7 + helper.insert(typeIDEventID, "label", "instanceB", "processB"); // 8, 9 + helper.insert(typeIDEventID, "labelX", "instanceB", "processB"); // 10, 11 + helper.insert(typeIDEventID, "labelB", "instance", "processB"); // 12, 13 + helper.insert(typeIDEventID, "labelB", "instanceX", "processB"); // 14, 15 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB1"); // 16, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB3"); // 17, 5 + helper.insert(typeIDEventID, "labelB", "instanceB", "processB2"); // 18, 5 + helper.insert(typeIDProductID, "label", "instance", "process"); // 19, 20 + helper.insert(typeIDEventID, "label", "instance", "process"); // 21, 22 + helper.insert(typeIDProductID, "labelA", "instanceA", "processA"); // 23, 24 + helper.insert(typeIDSetInt, "labelC", "instanceC", "processC"); // 25, 26 + helper.insert(typeIDVSimpleDerived, "labelC", "instanceC", "processC"); // 27, 28, 29, 30 helper.setFrozen(); edm::TypeID typeID_vint(typeid(std::vector)); diff --git a/FWCore/Framework/test/stubs/DeleteEarlyModules.cc b/FWCore/Framework/test/stubs/DeleteEarlyModules.cc index 6c8f59bc58aa3..bcfcf476fc001 100644 --- a/FWCore/Framework/test/stubs/DeleteEarlyModules.cc +++ b/FWCore/Framework/test/stubs/DeleteEarlyModules.cc @@ -32,6 +32,11 @@ namespace edmtest { produces(); } + virtual void beginJob() { + // Needed because DeleteEarly objects may be allocated and deleted in initialization + edmtest::DeleteEarly::resetDeleteCount(); + } + virtual void produce(edm::Event& e, edm::EventSetup const& ){ std::unique_ptr p(new DeleteEarly); e.put(std::move(p)); diff --git a/FWCore/Utilities/interface/DictionaryTools.h b/FWCore/Utilities/interface/DictionaryTools.h index d4c6e2fc2536c..dbd775eea445f 100644 --- a/FWCore/Utilities/interface/DictionaryTools.h +++ b/FWCore/Utilities/interface/DictionaryTools.h @@ -17,42 +17,6 @@ namespace edm { class TypeWithDict; typedef std::set StringSet; - bool - find_nested_type_named(std::string const& nested_type, - TypeWithDict const& type_to_search, - TypeWithDict& found_type); - bool - find_nested_type_named(std::string const& nested_type, - TypeWithDict const& type_to_search, - TypeWithDict& found_type); - - inline - bool - value_type_of(TypeWithDict const& t, TypeWithDict& found_type) { - return find_nested_type_named("value_type", t, found_type); - } - - - inline - bool - wrapper_type_of(TypeWithDict const& possible_wrapper, - TypeWithDict& found_wrapped_type) { - return find_nested_type_named("wrapped_type", - possible_wrapper, - found_wrapped_type); - } - - bool - is_RefVector(TypeWithDict const& possible_ref_vector, - TypeWithDict& value_type); - - bool - is_PtrVector(TypeWithDict const& possible_ref_vector, - TypeWithDict& value_type); - bool - is_RefToBaseVector(TypeWithDict const& possible_ref_vector, - TypeWithDict& value_type); - void checkDictionaries(std::string const& name, bool noComponents = false); void throwMissingDictionariesException(); void loadMissingDictionaries(); diff --git a/FWCore/Utilities/interface/getAnyPtr.h b/FWCore/Utilities/interface/getAnyPtr.h new file mode 100644 index 0000000000000..bfdd649fe7d63 --- /dev/null +++ b/FWCore/Utilities/interface/getAnyPtr.h @@ -0,0 +1,26 @@ +#ifndef FWCore_Utilities_getAnyPtr_h +#define FWCore_Utilities_getAnyPtr_h + +#include +#include + +namespace edm { + template + inline + std::unique_ptr getAnyPtr(void* p, int offset) { + // A union is used to avoid possible copies during the triple cast that would otherwise be needed. + // std::unique_ptr edp(static_cast(static_cast(static_cast(p) + offset))); + union { + void* vp; + unsigned char* ucp; + T* tp; + } pointerUnion; + assert(p != nullptr); + pointerUnion.vp = p; + pointerUnion.ucp += offset; + std::unique_ptr tp(pointerUnion.tp); + return(std::move(tp)); + } +} + +#endif diff --git a/FWCore/Utilities/src/DictionaryTools.cc b/FWCore/Utilities/src/DictionaryTools.cc index 5a6c7e2529400..22882eb71892d 100644 --- a/FWCore/Utilities/src/DictionaryTools.cc +++ b/FWCore/Utilities/src/DictionaryTools.cc @@ -27,59 +27,6 @@ namespace edm { static StringSet foundTypes_; static StringSet missingTypes_; - bool - find_nested_type_named(std::string const& nested_type, - TypeWithDict const& typeToSearch, - TypeWithDict& found_type) { - // Look for a sub-type named 'nested_type' - TypeWithDict foundType = typeToSearch.nestedType(nested_type); - if(bool(foundType)) { - found_type = foundType; - return true; - } - return false; - } - - bool - is_RefVector(TypeWithDict const& possibleRefVector, - TypeWithDict& value_type) { - - static std::string const template_name("edm::RefVector"); - static std::string const member_type("member_type"); - if(template_name == possibleRefVector.templateName()) { - return find_nested_type_named(member_type, possibleRefVector, value_type); - } - return false; - } - - bool - is_PtrVector(TypeWithDict const& possibleRefVector, - TypeWithDict& value_type) { - - static std::string const template_name("edm::PtrVector"); - static std::string const member_type("member_type"); - static std::string const val_type("value_type"); - if(template_name == possibleRefVector.templateName()) { - TypeWithDict ptrType; - if(find_nested_type_named(val_type, possibleRefVector, ptrType)) { - return find_nested_type_named(val_type, ptrType, value_type); - } - } - return false; - } - - bool - is_RefToBaseVector(TypeWithDict const& possibleRefVector, - TypeWithDict& value_type) { - - static std::string const template_name("edm::RefToBaseVector"); - static std::string const member_type("member_type"); - if(template_name == possibleRefVector.templateName()) { - return find_nested_type_named(member_type, possibleRefVector, value_type); - } - return false; - } - namespace { int const oneParamArraySize = 6; diff --git a/IOPool/Common/interface/getWrapperBasePtr.h b/IOPool/Common/interface/getWrapperBasePtr.h index 86e3fbb4467c5..fb3a9793cae28 100644 --- a/IOPool/Common/interface/getWrapperBasePtr.h +++ b/IOPool/Common/interface/getWrapperBasePtr.h @@ -1,26 +1,13 @@ #ifndef IOPool_Common_getWrapperBasePtr_h #define IOPool_Common_getWrapperBasePtr_h -#include -#include -#include "TClass.h" #include "DataFormats/Common/interface/WrapperBase.h" +#include "FWCore/Utilities//interface/getAnyPtr.h" namespace edm { inline std::unique_ptr getWrapperBasePtr(void* p, int offset) { - // A union is used to avoid possible copies during the triple cast that would otherwise be needed. - // std::unique_ptr edp(static_cast(static_cast(static_cast(p) + branchInfo.offsetToWrapperBase_))); - union { - void* vp; - unsigned char* ucp; - WrapperBase* edp; - } pointerUnion; - assert(p != nullptr); - pointerUnion.vp = p; - pointerUnion.ucp += offset; - std::unique_ptr edp(pointerUnion.edp); - return(std::move(edp)); + return(std::move(getAnyPtr(p, offset))); } }