diff --git a/Control/DataModelRoot/src/RootType.cxx b/Control/DataModelRoot/src/RootType.cxx index 58f03590ae1d84eb78daa83e4d3c13a60a08837a..644ba04310986962aab221e6f26af5a2f89e39b8 100644 --- a/Control/DataModelRoot/src/RootType.cxx +++ b/Control/DataModelRoot/src/RootType.cxx @@ -551,27 +551,14 @@ TScopeAdapter TScopeAdapter::ByName( const std::string& name, Bool_t load, Bool_t quiet ) { return TScopeAdapter(name, load, quiet); - - /* MN: causes problems in ROOT6, do we need it? - if (klass.GetClass() && klass->GetListOfAllPublicMethods()->GetSize() == 0) { - // sometimes I/O interferes, leading to zero methods: reload from CINT - ClassInfo_t* cl = gInterpreter->ClassInfo_Factory( name.c_str() ); - if ( cl ) { - gInterpreter->SetClassInfo( klass, kTRUE ); - gInterpreter->ClassInfo_Delete(cl); - } - } - return klass.GetClass(); - */ } //____________________________________________________________________________ TScopeAdapter TScopeAdapter::TypeAt( size_t nth ) { -// this is dreadful, but is the way checkDictionary() works ... it better make -// sure that it does not load extra classes inside its loop (seems to be how -// it should be, but is not how it is) - return TScopeAdapter( gClassTable->At( nth ) ); + const char *class_name = gClassTable->At( nth ); + // prevent autoloading, as it could change gClassTable + return class_name? TScopeAdapter( string(class_name), false, false ) : TScopeAdapter(); } //____________________________________________________________________________ diff --git a/Database/APR/StorageSvc/src/DbReflex.cpp b/Database/APR/StorageSvc/src/DbReflex.cpp index 9870baf574274933fdc189ade2a5049f9c822498..d2bcc0eed17a381fea9b3fc5fcf4041ba547a3c2 100644 --- a/Database/APR/StorageSvc/src/DbReflex.cpp +++ b/Database/APR/StorageSvc/src/DbReflex.cpp @@ -13,6 +13,8 @@ #include "StorageSvc/DbTransform.h" #include "POOLCore/DbPrint.h" +#include "TInterpreter.h" + #include <cstring> #include "AthContainers/tools/threading.h" @@ -39,7 +41,7 @@ static TypeMap& type_mapping() { /// Access to reflection information by type name const TypeH DbReflex::forTypeName(const string& name) { - return TypeH::ByName(name); + return TypeH(name); } /// Access to reflection information by type info @@ -63,12 +65,6 @@ Guid DbReflex::guid(const TypeH& type) } string idstr; if( type ) { -# if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0) - Reflex::PropertyList pl = type.Properties(); - if( pl.HasProperty("ClassID") ) { - idstr = pl.PropertyAsString("ClassID"); - } -# else idstr = type.Properties().PropertyAsString("id"); /* if( idstr.empty() ) { @@ -77,7 +73,6 @@ Guid DbReflex::guid(const TypeH& type) } cout << "GUID: Class " << type.Name() << " has GUID= " << idstr << endl; */ -# endif lock.upgrade(); if( !idstr.empty() ) { Guid id(idstr); @@ -97,6 +92,7 @@ Guid DbReflex::guid(const TypeH& type) return Guid::null(); } + /// Access to reflection information by Guid const TypeH DbReflex::forGuid(const Guid& id) { @@ -126,6 +122,20 @@ const TypeH DbReflex::forGuid(const Guid& id) // GUID not in the map: scan all known types. refresh the map log << DbPrintLvl::Warning << " doing GUID scan on ALL types for Class ID=" << id << DbPrint::endmsg; + // disable TClass autoloading/parsing, restore settings on return + class AutoloadGuard { + public: + int al = 0, ap = 0; + AutoloadGuard() { + al = gInterpreter->SetClassAutoloading( 0 ); + ap = gInterpreter->SetClassAutoparsing( 0 ); + } + ~AutoloadGuard() { + gInterpreter->SetClassAutoloading( al ); + gInterpreter->SetClassAutoparsing( ap ); + } + } ALG; + for(size_t i=0; i<TypeH::TypeSize(); ++i) { TypeH t = TypeH::TypeAt(i); if( t.IsClass() || t.IsStruct() ) { diff --git a/Trigger/TrigDataAccess/TrigSerializeCnvSvc/CMakeLists.txt b/Trigger/TrigDataAccess/TrigSerializeCnvSvc/CMakeLists.txt index f616a6f0f95d85bc78ebe76f9c302d730d1bb8e3..cfa6a5b557983eeaf142595cde6dfa309291b9b9 100644 --- a/Trigger/TrigDataAccess/TrigSerializeCnvSvc/CMakeLists.txt +++ b/Trigger/TrigDataAccess/TrigSerializeCnvSvc/CMakeLists.txt @@ -21,19 +21,15 @@ atlas_depends_on_subdirs( PUBLIC Trigger/TrigDataAccess/TrigSerializeResult Trigger/TrigDataAccess/TrigSerializeTP ) -# External dependencies: -find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) # Component(s) in the package: atlas_add_library( TrigSerializeCnvSvcLib src/*.cxx PUBLIC_HEADERS TrigSerializeCnvSvc - PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES AthContainers AthenaBaseComps SGTools GaudiKernel StoreGateLib SGtests TrigSerializeResultLib TrigSerializeTPLib PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel DataModelRoot StorageSvc PersistentDataModel ) atlas_add_component( TrigSerializeCnvSvc src/components/*.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers AthenaBaseComps SGTools StoreGateLib SGtests GaudiKernel AthenaKernel DataModelRoot StorageSvc PersistentDataModel TrigSerializeResultLib TrigSerializeTPLib TrigSerializeCnvSvcLib ) + LINK_LIBRARIES AthContainers AthenaBaseComps SGTools StoreGateLib SGtests GaudiKernel AthenaKernel DataModelRoot StorageSvc PersistentDataModel TrigSerializeResultLib TrigSerializeTPLib TrigSerializeCnvSvcLib ) diff --git a/Trigger/TrigDataAccess/TrigSerializeCnvSvc/src/TrigSerializeConvHelper.cxx b/Trigger/TrigDataAccess/TrigSerializeCnvSvc/src/TrigSerializeConvHelper.cxx index aae0a1e80a1860e36b925352598f6b3438301670..9ba32e455ee44876dc6670543090549223265177 100644 --- a/Trigger/TrigDataAccess/TrigSerializeCnvSvc/src/TrigSerializeConvHelper.cxx +++ b/Trigger/TrigDataAccess/TrigSerializeCnvSvc/src/TrigSerializeConvHelper.cxx @@ -2,22 +2,15 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ - #include "TrigSerializeCnvSvc/TrigSerializeConvHelper.h" -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/ClassID.h" -#include "AthenaKernel/getMessageSvc.h" #include "StoreGate/StoreGateSvc.h" - #include "TrigSerializeCnvSvc/TrigStreamAddress.h" #include "TrigSerializeResult/ITrigSerializerToolBase.h" #include "TrigSerializeTP/TrigSerTPTool.h" #include "TrigSerializeCnvSvc/ITrigSerGuidHelper.h" -// -#include "TROOT.h" -#include "TClass.h" +#include "DataModelRoot/RootType.h" TrigSerializeConvHelper::TrigSerializeConvHelper(const std::string& toolname, const std::string& type, const IInterface* parent) : @@ -120,9 +113,8 @@ StatusCode TrigSerializeConvHelper::initialize(){ } StatusCode TrigSerializeConvHelper::createObj(const std::string &clname, IOpaqueAddress* iAddr, void *&ptr, bool isxAOD){ - ptr = 0; - msg(MSG::DEBUG) << "in TrigSerializeConvHelper::createObj for clname" << clname << " is xAOD? " << (isxAOD?"yes":"no") << endmsg; + msg(MSG::DEBUG) << "in TrigSerializeConvHelper::createObj for clname: " << clname << " is xAOD? " << (isxAOD?"yes":"no") << endmsg; //could alse get DATA (perhaps as boost::any) from the IOA TrigStreamAddress *addr = dynamic_cast<TrigStreamAddress*>(iAddr); @@ -137,11 +129,8 @@ StatusCode TrigSerializeConvHelper::createObj(const std::string &clname, IOpaque std::vector<uint32_t> v = addr->get(); //we need to find the name of the ob - std::string cl = clname; - - if (m_doTP and !isxAOD) cl = m_TPTool->persClassName(clname); @@ -165,9 +154,9 @@ StatusCode TrigSerializeConvHelper::createObj(const std::string &clname, IOpaque } } else { //get the pers version from the BS - std::string nclass; + std::string nclass = cl; StatusCode ai = m_guidTool->IntsToClassName(guid, nclass); - if (ai.isFailure()){ + if (ai.isFailure()) { //better do not decode return StatusCode::FAILURE; } @@ -201,9 +190,8 @@ StatusCode TrigSerializeConvHelper::createObj(const std::string &clname, IOpaque if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "was converted to " << transclass << " at " << transObj << endmsg; //persistent object not needed anymore - TClass *persClObj = gROOT->GetClass(cl.c_str()); - if (persClObj) - persClObj->Destructor(ptr); + RootType persClObj(cl); + persClObj.Destruct(ptr); ptr = transObj; } @@ -259,9 +247,8 @@ StatusCode TrigSerializeConvHelper::createRep(const std::string &clname, if (m_doTP and !isxAOD){ //we don't need the persistent object anymore - TClass *persClObj = gROOT->GetClass(cl.c_str()); - if (persClObj) - persClObj->Destructor(pObj); + RootType persClObj(cl); + persClObj.Destruct(pObj); } if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "pObj: " << pObj << " of " << cl diff --git a/Trigger/TrigDataAccess/TrigSerializeCnvSvc/src/TrigSerializeGuidHelper.cxx b/Trigger/TrigDataAccess/TrigSerializeCnvSvc/src/TrigSerializeGuidHelper.cxx index e33a94bf376e6fc1d017cfbd141b11cfcdb6defe..a08c0eea802180d2663d1d5b23f02b3c6ddb8041 100644 --- a/Trigger/TrigDataAccess/TrigSerializeCnvSvc/src/TrigSerializeGuidHelper.cxx +++ b/Trigger/TrigDataAccess/TrigSerializeCnvSvc/src/TrigSerializeGuidHelper.cxx @@ -9,7 +9,6 @@ #include "StorageSvc/DbReflex.h" - TrigSerializeGuidHelper::TrigSerializeGuidHelper(const std::string& name, const std::string& type, const IInterface* parent) : AthAlgTool(name, type, parent) @@ -52,7 +51,7 @@ StatusCode TrigSerializeGuidHelper::ClassNameToInts(const std::string &clname, u return StatusCode::SUCCESS; } -StatusCode TrigSerializeGuidHelper::IntsToClassName(const uint32_t *iarr, std::string &clname){ +StatusCode TrigSerializeGuidHelper::IntsToClassName(const uint32_t *iarr, std::string &clname) { Guid guid; guid.setData1(iarr[0]); @@ -68,16 +67,24 @@ StatusCode TrigSerializeGuidHelper::IntsToClassName(const uint32_t *iarr, std::s guid.setData4(iarr[3] & 0xFF, 7); if (msgLvl(MSG::DEBUG)) - msg(MSG::DEBUG) << "constructed " << guid.toString() << " from ints" << endmsg; - RootType cltype(pool::DbReflex::forGuid(guid)); - - clname = cltype.Name(Reflex::SCOPED); - /* - std::string scope = cltype.DeclaringScope().Name(); - if (!scope.empty()) { - clname = scope+"::"+clname; + msg(MSG::DEBUG) << "constructed " << guid.toString() << " from ints" << endmsg; + + if( clname != "" ) { + // Instead of getting a typename for a known guid (quite costly in ROOT6) + // and comparing names, + // get a class by name and compare guids + Guid g( pool::DbReflex::guid( RootType(clname) ) ); + if( g != guid ) { + // the typename was wrong, will need to look it up by GUID + clname = ""; + } + } + + if( clname == "" ) { + RootType cltype( pool::DbReflex::forGuid(guid) ); + clname = cltype.Name(Reflex::SCOPED); } - */ + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "corresponds to " << clname << endmsg;