From 43b1d612aaf11095b727c838f5759f76c494743c Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <frank.winklmeier@cern.ch> Date: Thu, 26 Sep 2024 15:13:25 +0200 Subject: [PATCH] StoreGateSvc: cleanup service retrievals SGImplSvc: move remaining service pointers to ServiceHandle Use ServiceHandle instead of bare pointers. The reference updates are needed because service retrieval is done "quietly" by the handle. --- .../ControlTest/share/CircularDep_test.ref | 2 - .../ControlTest/share/ClearStore_test.ref | 2 - .../share/ElementLinkVector_test.ref | 2 - .../ControlTest/share/ElementLink_test.ref | 2 - .../share/ProxyProviderSvc_test.ref | 6 -- .../ControlTest/share/SGDataLink_test.ref | 2 - AtlasTest/ControlTest/share/StoreGateGen.ref | 2 - .../ControlTest/share/StoreGateReentrant.ref | 2 - .../share/StoreGateSvcClient_test.ref | 2 - AtlasTest/ControlTest/share/StoreID.ref | 2 - AtlasTest/ControlTest/share/StoreID_test.ref | 2 - Control/StoreGate/StoreGate/tools/SGImplSvc.h | 11 ++- .../StoreGate/share/ActiveStoreHive_test.ref | 2 - Control/StoreGate/share/SGHive_test.ref | 10 --- Control/StoreGate/src/SGImplSvc.cxx | 71 +++++-------------- Control/StoreGate/src/StoreGateSvc.cxx | 21 ++---- Control/StoreGate/test/ActiveStore_test.cxx | 10 +-- Control/StoreGate/test/ReadHandle_test.cxx | 6 +- Control/StoreGate/test/SGHive_test.cxx | 10 +-- Control/StoreGate/test/SGTiming_test.cxx | 4 +- Control/StoreGate/test/SGtests.cxx | 4 +- Control/StoreGate/test/SegMemSvc_test.cxx | 6 +- .../test/ShallowCopyDecorDeps_test.cxx | 6 +- .../StoreGate/test/WriteCondHandle_test.cxx | 4 +- .../share/HLTNavigation_test.ref | 2 - .../TrigNavigation/share/Holder_test.ref | 2 - .../TrigNavigation/share/Ownership_test.ref | 2 - .../share/Registration_test.ref | 2 - 28 files changed, 54 insertions(+), 145 deletions(-) diff --git a/AtlasTest/ControlTest/share/CircularDep_test.ref b/AtlasTest/ControlTest/share/CircularDep_test.ref index 104f44ee10ef..911a4bc9531d 100644 --- a/AtlasTest/ControlTest/share/CircularDep_test.ref +++ b/AtlasTest/ControlTest/share/CircularDep_test.ref @@ -35,8 +35,6 @@ StoreGateSvc DEBUG trying to create store SGImplSvc/StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Property update for OutputLevel : new value = 1 StoreGateSvc_Impl VERBOSE Initializing StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Service base class initialized successfully -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc StoreGateSvc DEBUG Recorded object @0xfe61c0 with key circVector of type CircularVector(CLID 218202856) in DataObject @0xfe62d0 object modifiable when retrieved diff --git a/AtlasTest/ControlTest/share/ClearStore_test.ref b/AtlasTest/ControlTest/share/ClearStore_test.ref index df66f3471b75..7244fa494ce3 100644 --- a/AtlasTest/ControlTest/share/ClearStore_test.ref +++ b/AtlasTest/ControlTest/share/ClearStore_test.ref @@ -8,8 +8,6 @@ ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr Ready StoreGateSvc VERBOSE Initializing StoreGateSvc StoreGateSvc VERBOSE Initializing StoreGateSvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc *** ClearStore_test run standard testRecord a first time *** *** StoreGateSvcClient_test record BEGINS *** object modifiable when retrieved diff --git a/AtlasTest/ControlTest/share/ElementLinkVector_test.ref b/AtlasTest/ControlTest/share/ElementLinkVector_test.ref index fc4870d92505..c6115d897f7f 100644 --- a/AtlasTest/ControlTest/share/ElementLinkVector_test.ref +++ b/AtlasTest/ControlTest/share/ElementLinkVector_test.ref @@ -32,8 +32,6 @@ StoreGateSvc DEBUG trying to create store SGImplSvc/StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Property update for OutputLevel : new value = 1 StoreGateSvc_Impl VERBOSE Initializing StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Service base class initialized successfully -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc *** ElementLinkVector_test vector starts *** diff --git a/AtlasTest/ControlTest/share/ElementLink_test.ref b/AtlasTest/ControlTest/share/ElementLink_test.ref index d50a353e99ae..d68b9ea12ddf 100644 --- a/AtlasTest/ControlTest/share/ElementLink_test.ref +++ b/AtlasTest/ControlTest/share/ElementLink_test.ref @@ -32,8 +32,6 @@ StoreGateSvc DEBUG trying to create store SGImplSvc/StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Property update for OutputLevel : new value = 1 StoreGateSvc_Impl VERBOSE Initializing StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Service base class initialized successfully -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc ************* Starting Test 1 StoreGateSvc DEBUG Recorded object @0x15c61d0 with key fooVec of type DataVector<Foo>(CLID 1234) in DataObject @0x15c6160 diff --git a/AtlasTest/ControlTest/share/ProxyProviderSvc_test.ref b/AtlasTest/ControlTest/share/ProxyProviderSvc_test.ref index 714e88df711a..66fa73e78b72 100644 --- a/AtlasTest/ControlTest/share/ProxyProviderSvc_test.ref +++ b/AtlasTest/ControlTest/share/ProxyProviderSvc_test.ref @@ -4,14 +4,10 @@ ApplicationMgr DEBUG Getting my own properties ApplicationMgr INFO Application Manager Configured successfully DetectorStore VERBOSE Initializing DetectorStore DetectorStore_ImplVERBOSE Initializing DetectorStore_Impl -DetectorStore_ImplVERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -DetectorStore_ImplVERBOSE ServiceLocatorHelper::service: found service ClassIDSvc ProxyProviderSvc VERBOSE Initializing ProxyProviderSvc ProxyProviderSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc HistoryStore VERBOSE Initializing HistoryStore HistoryStore_Impl VERBOSE Initializing HistoryStore_Impl -HistoryStore_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -HistoryStore_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. HistogramDataSvc VERBOSE ServiceLocatorHelper::service: found service HistogramPersistencySvc @@ -19,8 +15,6 @@ ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr Ready StoreGateSvc VERBOSE Initializing StoreGateSvc StoreGateSvc VERBOSE Initializing StoreGateSvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc EventPersistenc...VERBOSE ServiceLocatorHelper::service: found service ToyConversionSvc StoreGateSvc: <<<<<<<<<<<<<<<<< Data Store Dump >>>>>>>>>>>>>>> StoreGateSvc: StoreGateSvc()::dump() which is NOT LOADED diff --git a/AtlasTest/ControlTest/share/SGDataLink_test.ref b/AtlasTest/ControlTest/share/SGDataLink_test.ref index af6535ad5d41..fbab46fbe41d 100644 --- a/AtlasTest/ControlTest/share/SGDataLink_test.ref +++ b/AtlasTest/ControlTest/share/SGDataLink_test.ref @@ -29,8 +29,6 @@ StoreGateSvc DEBUG trying to create store SGImplSvc/StoreGateSvc_Impl[m StoreGateSvc_Impl DEBUG Property update for OutputLevel : new value = 1[m StoreGateSvc_Impl VERBOSE Initializing StoreGateSvc_Impl[m StoreGateSvc_Impl DEBUG Service base class initialized successfully[m -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc[m -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc[m StoreGateSvc DEBUG Recorded object @0x4ce3340 with key foo2 of type Foo(CLID 8101) in DataObject @0x4ce45a0 object modifiable when retrieved[m diff --git a/AtlasTest/ControlTest/share/StoreGateGen.ref b/AtlasTest/ControlTest/share/StoreGateGen.ref index a99d9634dc16..b59d5c304978 100644 --- a/AtlasTest/ControlTest/share/StoreGateGen.ref +++ b/AtlasTest/ControlTest/share/StoreGateGen.ref @@ -6,8 +6,6 @@ AthenaEventLoopMgr INFO Initializing AthenaEventLoopMgr WriteData INFO in initialize() StoreGateSvc VERBOSE Initializing StoreGateSvc StoreGateSvc VERBOSE Initializing StoreGateSvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc ReadData INFO in initialize() ReadData INFO Data Object producer: WriteData ApplicationMgr INFO Application Manager Initialized successfully diff --git a/AtlasTest/ControlTest/share/StoreGateReentrant.ref b/AtlasTest/ControlTest/share/StoreGateReentrant.ref index c742a15e4f99..57bcc44fe298 100644 --- a/AtlasTest/ControlTest/share/StoreGateReentrant.ref +++ b/AtlasTest/ControlTest/share/StoreGateReentrant.ref @@ -6,8 +6,6 @@ AthenaEventLoopMgr INFO Initializing AthenaEventLoopMgr WriteDataReentrant INFO in initialize() StoreGateSvc VERBOSE Initializing StoreGateSvc StoreGateSvc VERBOSE Initializing StoreGateSvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc ReadDataReentrant INFO in initialize() ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr INFO Application Manager Started successfully diff --git a/AtlasTest/ControlTest/share/StoreGateSvcClient_test.ref b/AtlasTest/ControlTest/share/StoreGateSvcClient_test.ref index c90109c17382..150ca3bfeb9a 100644 --- a/AtlasTest/ControlTest/share/StoreGateSvcClient_test.ref +++ b/AtlasTest/ControlTest/share/StoreGateSvcClient_test.ref @@ -7,8 +7,6 @@ ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr Ready StoreGateSvc VERBOSE Initializing StoreGateSvc StoreGateSvc VERBOSE Initializing StoreGateSvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc *** StoreGateSvcClient_test record BEGINS *** object modifiable when retrieved Now we expect to see an error message: diff --git a/AtlasTest/ControlTest/share/StoreID.ref b/AtlasTest/ControlTest/share/StoreID.ref index 74415d1942a7..fbf3de253ab2 100644 --- a/AtlasTest/ControlTest/share/StoreID.ref +++ b/AtlasTest/ControlTest/share/StoreID.ref @@ -29,6 +29,4 @@ StoreGateSvc DEBUG trying to create store SGImplSvc/StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Property update for OutputLevel : new value = 1 StoreGateSvc_Impl VERBOSE Initializing StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Service base class initialized successfully -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc *** StoreID_test OK *** diff --git a/AtlasTest/ControlTest/share/StoreID_test.ref b/AtlasTest/ControlTest/share/StoreID_test.ref index 95f65ce48684..6cf2762014e0 100644 --- a/AtlasTest/ControlTest/share/StoreID_test.ref +++ b/AtlasTest/ControlTest/share/StoreID_test.ref @@ -26,6 +26,4 @@ ApplicationMgr INFO Application Manager Initialized successfully[m ApplicationMgr Ready StoreGateSvc DEBUG Property update for OutputLevel : new value = 1[m StoreGateSvc DEBUG Service base class initialized successfully[m -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc[m -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc[m *** StoreID_test OK *** diff --git a/Control/StoreGate/StoreGate/tools/SGImplSvc.h b/Control/StoreGate/StoreGate/tools/SGImplSvc.h index 4562932c2c09..44d81f11212a 100644 --- a/Control/StoreGate/StoreGate/tools/SGImplSvc.h +++ b/Control/StoreGate/StoreGate/tools/SGImplSvc.h @@ -1,7 +1,7 @@ /* -*- C++ -*- */ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #ifndef STOREGATE_SGIMPLSVC_H @@ -687,15 +687,15 @@ private: /// Only intended to be called by ActiveStoreSvc. void makeCurrent(); - IClassIDSvc* m_pCLIDSvc; - IConversionSvc* m_pDataLoader; + ServiceHandle<IClassIDSvc> m_pCLIDSvc; + ServiceHandle<IConversionSvc> m_pDataLoader; ServiceHandle<IProxyProviderSvc> m_pPPSHandle; // Has to be separate from handle due to setProxyProviderSvc() interface. // Can we get rid of that? IProxyProviderSvc* m_pPPS; - IHistorySvc* m_pHistorySvc; + ServiceHandle<IHistorySvc> m_pHistorySvc; SG::DataStore* m_pStore; std::list<DataObject*> m_trash; ///< The Recycle Bin @@ -709,8 +709,7 @@ private: StringArrayProperty m_folderNameList; ///< FolderNameList Property ///get the IOVSvc "just in time" (breaks recursion at initialize) - IIOVSvc* getIIOVSvc(); - IIOVSvc* m_pIOVSvc; + ServiceHandle<IIOVSvc> m_pIOVSvc; bool m_storeLoaded; ///< FIXME hack needed by loadEventProxies diff --git a/Control/StoreGate/share/ActiveStoreHive_test.ref b/Control/StoreGate/share/ActiveStoreHive_test.ref index 1e6e4c34a01e..b473737009d1 100644 --- a/Control/StoreGate/share/ActiveStoreHive_test.ref +++ b/Control/StoreGate/share/ActiveStoreHive_test.ref @@ -30,8 +30,6 @@ SG::HiveStoreSvc INFO Initializing SG::HiveStoreSvc - package version StoreG StoreGateSvc INFO Initializing StoreGateSvc - package version StoreGate-02-39-07-branch StoreGateSvc DEBUG Service base class initialized successfully StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service IncidentSvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ProxyProviderSvc ActiveStoreSvc INFO Initializing ActiveStoreSvc - package version StoreGate-02-39-07-branch ActiveStoreSvc INFO ActiveStoreSvc will use SG::HiveStoreSvc diff --git a/Control/StoreGate/share/SGHive_test.ref b/Control/StoreGate/share/SGHive_test.ref index fd26f171f5df..d78e788041ad 100644 --- a/Control/StoreGate/share/SGHive_test.ref +++ b/Control/StoreGate/share/SGHive_test.ref @@ -28,29 +28,19 @@ StoreGateSvc DEBUG trying to create store SGImplSvc/StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Property update for OutputLevel : new value = 1 StoreGateSvc_Impl VERBOSE Initializing StoreGateSvc_Impl StoreGateSvc_Impl DEBUG Service base class initialized successfully -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc ClassIDSvc INFO getRegistryEntries: read 264 CLIDRegistry entries for module ALL -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc 0_StoreGateSvc_... DEBUG Property update for OutputLevel : new value = 1 0_StoreGateSvc_...VERBOSE Initializing 0_StoreGateSvc_Impl 0_StoreGateSvc_... DEBUG Service base class initialized successfully -0_StoreGateSvc_...VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -0_StoreGateSvc_...VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc 1_StoreGateSvc_... DEBUG Property update for OutputLevel : new value = 1 1_StoreGateSvc_...VERBOSE Initializing 1_StoreGateSvc_Impl 1_StoreGateSvc_... DEBUG Service base class initialized successfully -1_StoreGateSvc_...VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -1_StoreGateSvc_...VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc 2_StoreGateSvc_... DEBUG Property update for OutputLevel : new value = 1 2_StoreGateSvc_...VERBOSE Initializing 2_StoreGateSvc_Impl 2_StoreGateSvc_... DEBUG Service base class initialized successfully -2_StoreGateSvc_...VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -2_StoreGateSvc_...VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc 3_StoreGateSvc_... DEBUG Property update for OutputLevel : new value = 1 3_StoreGateSvc_...VERBOSE Initializing 3_StoreGateSvc_Impl 3_StoreGateSvc_... DEBUG Service base class initialized successfully -3_StoreGateSvc_...VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -3_StoreGateSvc_...VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc Now we expect to see an error message: ----Error Message Starts--->> HiveMgrSvc FATAL Too late to change the number of slots! diff --git a/Control/StoreGate/src/SGImplSvc.cxx b/Control/StoreGate/src/SGImplSvc.cxx index 6ebc684ee29e..8a8c6d57bdec 100644 --- a/Control/StoreGate/src/SGImplSvc.cxx +++ b/Control/StoreGate/src/SGImplSvc.cxx @@ -100,15 +100,18 @@ namespace SG { /////////////////////////////////////////////////////////////////////////// /// Standard Constructor SGImplSvc::SGImplSvc(const string& name,ISvcLocator* svc) - : Service(name, svc), m_pCLIDSvc(0), m_pDataLoader(0), + : Service(name, svc), + m_pCLIDSvc("ClassIDSvc", name), + m_pDataLoader("EventPersistencySvc", name), m_pPPSHandle("ProxyProviderSvc", name), m_pPPS(nullptr), - m_pHistorySvc(0), m_pStore(new DataStore(*this)), + m_pHistorySvc("HistorySvc", name), + m_pStore(new DataStore(*this)), m_pIncSvc("IncidentSvc", name), m_DumpStore(false), m_ActivateHistory(false), m_DumpArena(false), - m_pIOVSvc(0), + m_pIOVSvc("IOVSvc", name), m_storeLoaded(false), m_remap_impl (new SG::RemapImpl), m_arena (name), @@ -168,26 +171,11 @@ StatusCode SGImplSvc::initialize() { return StatusCode::FAILURE; } - //start listening to "EndEvent" - // const int PRIORITY = 100; - // Mother svc should register these incidents - // m_pIncSvc->addListener(this, "EndEvent", PRIORITY); - // m_pIncSvc->addListener(this, "BeginEvent", PRIORITY); + // We explicitly do not retrieve m_pIOVSvc and rely on retrieval + // on first use to avoid an initialization loop here. - const bool CREATEIF(true); - // cache pointer to Persistency Service - if (!(service("EventPersistencySvc", m_pDataLoader, CREATEIF)).isSuccess()) { - m_pDataLoader = 0; - error() << "Could not get pointer to Persistency Service" - << endmsg; - return StatusCode::FAILURE; - } - - if (!(service("ClassIDSvc", m_pCLIDSvc, CREATEIF)).isSuccess()) { - error() << "Could not get pointer to ClassID Service" - << endmsg; - return StatusCode::FAILURE; - } + CHECK( m_pDataLoader.retrieve() ); + CHECK( m_pCLIDSvc.retrieve() ); if (!m_pPPSHandle.empty()) { CHECK( m_pPPSHandle.retrieve() ); @@ -201,11 +189,8 @@ StatusCode SGImplSvc::initialize() { } // Get hold of History Service - if (m_ActivateHistory && - !(service("HistorySvc", m_pHistorySvc, CREATEIF)).isSuccess()) { - error() << "Could not locate History Service" - << endmsg; - return StatusCode::FAILURE; + if (m_ActivateHistory) { + CHECK( m_pHistorySvc.retrieve() ); } return StatusCode::SUCCESS; @@ -243,16 +228,6 @@ StatusCode SGImplSvc::stop() { return StatusCode::SUCCESS; } -////////////////////////////////////////////////////////////// -IIOVSvc* SGImplSvc::getIIOVSvc() { - // Get hold of the IOVSvc - if (0 == m_pIOVSvc && !(service("IOVSvc", m_pIOVSvc)).isSuccess()) { - warning() << "Could not locate IOVSvc " - << endmsg; - } - return m_pIOVSvc; -} - ////////////////////////////////////////////////////////////// void SGImplSvc::handle(const Incident &inc) { @@ -335,12 +310,6 @@ StatusCode SGImplSvc::finalize() { const bool FORCEREMOVE(true); clearStore(FORCEREMOVE).ignore(); - //protect against double release - if (m_pHistorySvc) { - m_pHistorySvc->release(); - m_pHistorySvc = 0; - } - m_stringpool.clear(); delete m_pStore; m_pStore = nullptr; @@ -445,7 +414,7 @@ StatusCode SGImplSvc::recordAddress(const std::string& skey, // create the proxy object and register it dp = new DataProxy (TransientAddress (dataID, skey, pAddress, clearAddressFlag), - m_pDataLoader, true, true); + m_pDataLoader.get(), true, true); m_pStore->addToStore(dataID, dp).ignore(); addAutoSymLinks (skey, dataID, dp, 0, false); @@ -568,7 +537,7 @@ SGImplSvc::regFcn( const CallBackID& c1, bool trigger) { lock_t lock (m_mutex); - return ( getIIOVSvc()->regFcn(c1,c2,fcn,trigger) ); + return ( m_pIOVSvc->regFcn(c1,c2,fcn,trigger) ); } @@ -579,7 +548,7 @@ SGImplSvc::regFcn( const std::string& toolName, bool trigger) { lock_t lock (m_mutex); - return ( getIIOVSvc()->regFcn(toolName,c2,fcn,trigger) ); + return ( m_pIOVSvc->regFcn(toolName,c2,fcn,trigger) ); } @@ -1153,7 +1122,7 @@ SGImplSvc::typeless_overwrite( const CLID& clid, } //for detector store objects managed by IIOVSvc, replace the old proxy with the new one (#104311) if (toRemove && sc.isSuccess() && store()->storeID() == StoreID::DETECTOR_STORE) { - sc = getIIOVSvc()->replaceProxy(toRemove, proxy(clid, key)); + sc = m_pIOVSvc->replaceProxy(toRemove, proxy(clid, key)); } if (toRemove) toRemove->release(); @@ -1457,7 +1426,7 @@ bool SGImplSvc::bindHandleToProxyAndRegister (const CLID& id, const std::string& lock_t lock (m_mutex); bool ret = bindHandleToProxy (id, key, ir, dp); if (ret) { - StatusCode sc = getIIOVSvc()->regProxy(dp,key); + StatusCode sc = m_pIOVSvc->regProxy(dp,key); if (sc.isFailure()) return false; } return true; @@ -1474,9 +1443,9 @@ bool SGImplSvc::bindHandleToProxyAndRegister (const CLID& id, const std::string& lock_t lock (m_mutex); bool ret = bindHandleToProxy (id, key, ir, dp); if (ret) { - StatusCode sc = getIIOVSvc()->regProxy(dp,key); + StatusCode sc = m_pIOVSvc->regProxy(dp,key); if (sc.isFailure()) return false; - sc = getIIOVSvc()->regFcn(dp,c,fcn,trigger); + sc = m_pIOVSvc->regFcn(dp,c,fcn,trigger); if (sc.isFailure()) return false; } return true; @@ -1489,8 +1458,6 @@ SGImplSvc::record_HistObj(const CLID& id, const std::string& key, const std::string& store, bool allowMods, bool resetOnly) { - assert(m_pHistorySvc); - DataHistory *dho; dho = m_pHistorySvc->createDataHistoryObj( id, key, store ); diff --git a/Control/StoreGate/src/StoreGateSvc.cxx b/Control/StoreGate/src/StoreGateSvc.cxx index a295d458aa6c..c7fb23bcfaff 100644 --- a/Control/StoreGate/src/StoreGateSvc.cxx +++ b/Control/StoreGate/src/StoreGateSvc.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #include "GaudiKernel/IIncidentSvc.h" @@ -70,9 +70,8 @@ StoreGateSvc *StoreGateSvc::currentStoreGate() { if (!::currentStoreGate) { // this is a static function so we don't have many conveniences ISvcLocator *svcLocator = Gaudi::svcLocator(); - StoreGateSvc *sg = nullptr; - if (!svcLocator->service("StoreGateSvc/StoreGateSvc", sg, false) - .isSuccess()) { + SmartIF<StoreGateSvc> sg{svcLocator->service("StoreGateSvc/StoreGateSvc")}; + if ( !sg.isValid() ) { throw GaudiException( "Could not get \"StoreGateSvc\" to initialize currentStoreGate", "StoreGateSvc", StatusCode::FAILURE); @@ -124,16 +123,8 @@ StatusCode StoreGateSvc::initialize() { verbose() << "Initializing " << name() << endmsg; - // lifted from AlwaysPrivateToolSvc (see Wim comment about lack of global jo svc accessor - // retrieve the job options svc (TODO: the code below relies heavily on - // internals; figure out if there's no global getJobOptionsSvc() ... ) - IAppMgrUI* appmgr = Gaudi::createApplicationMgr(); - IProperty* appmgrprop = 0; - appmgr->queryInterface( IProperty::interfaceID(), (void**)&appmgrprop ).ignore(); - //all of the above to get the jo svc type - const Gaudi::Details::PropertyBase& prop = appmgrprop->getProperty( "JobOptionsSvcType" ); - Gaudi::Interfaces::IOptionsSvc* pJOSvc(0); - if ( serviceLocator()->service( prop.toString(), "JobOptionsSvc", pJOSvc ).isFailure() ) { + SmartIF<Gaudi::Interfaces::IOptionsSvc> pJOSvc{serviceLocator()->service("JobOptionsSvc")}; + if ( !pJOSvc.isValid() ) { error() << "Failed to retrieve JobOptionsSvc" << endmsg; } //copy our properties to the prototype (default) SGImplSvc @@ -141,8 +132,6 @@ StatusCode StoreGateSvc::initialize() { for (const Gaudi::Details::PropertyBase* p : getProperties()) { pJOSvc->set( implStoreName + "." + p->name(), p->toString() ); } - pJOSvc->release(); - pJOSvc=0; //HACK ALERT: using createService rather then the customary service(...,CREATEIF=true) we set our pointer // to SGImplSvc early (even before it is initialized). This should help take care of some initialize loops diff --git a/Control/StoreGate/test/ActiveStore_test.cxx b/Control/StoreGate/test/ActiveStore_test.cxx index 002d3a7f6f55..a014beacd639 100644 --- a/Control/StoreGate/test/ActiveStore_test.cxx +++ b/Control/StoreGate/test/ActiveStore_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ /*************************************************************************** @@ -41,13 +41,13 @@ int main() { if (!initGaudi("StoreGate/ActiveStore_test.txt", pSvcLoc)) { return 1; } - ActiveStoreSvc* pASS(0); - assert( pSvcLoc->service("ActiveStoreSvc", pASS, true).isSuccess() ); + SmartIF<ActiveStoreSvc> pASS{pSvcLoc->service("ActiveStoreSvc")}; + assert( pASS.isValid() ); assert( pASS->activeStore() == pASS->operator->() ); //as set in ActiveStore_test.txt assert( pASS->activeStore()->name() == "E1" ); - StoreGateSvc* pE2(0); - assert( pSvcLoc->service("E2", pE2).isSuccess() ); + SmartIF<StoreGateSvc> pE2{pSvcLoc->service("E2")}; + assert( pE2.isValid() ); pASS->setStore(pE2); assert( pASS->activeStore()->name() == "E2" ); assert( pASS->finalize().isSuccess() ); diff --git a/Control/StoreGate/test/ReadHandle_test.cxx b/Control/StoreGate/test/ReadHandle_test.cxx index de00f13bbacb..94a4049c9b35 100644 --- a/Control/StoreGate/test/ReadHandle_test.cxx +++ b/Control/StoreGate/test/ReadHandle_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ /** * @file StoreGate/test/ReadHandle_test.cxx @@ -340,8 +340,8 @@ void test6() unsigned int perftest (ISvcLocator* svcloc, unsigned int ntry) { - StoreGateSvc* sg = nullptr; - assert (svcloc->service ("StoreGateSvc", sg).isSuccess()); + SmartIF<StoreGateSvc> sg{svcloc->service ("StoreGateSvc")}; + assert ( sg.isValid() ); assert (sg->record (std::make_unique<MyObj> (42), "MyObj", false).isSuccess()); SG::ReadHandleKey<MyObj> key ("MyObj"); diff --git a/Control/StoreGate/test/SGHive_test.cxx b/Control/StoreGate/test/SGHive_test.cxx index 7bb1b153abdf..aeca1e6001d0 100644 --- a/Control/StoreGate/test/SGHive_test.cxx +++ b/Control/StoreGate/test/SGHive_test.cxx @@ -116,10 +116,10 @@ int main() { if (!initGaudi("StoreGate/SGHive_test.txt", pSvcLoc)) { return 1; } - IHiveWhiteBoard* pWB(0); - assert( pSvcLoc->service("SG::HiveMgrSvc/HiveMgrSvc", pWB, true).isSuccess() ); + SmartIF<IHiveWhiteBoard> pWB{pSvcLoc->service("SG::HiveMgrSvc/HiveMgrSvc")}; + assert( pWB.isValid() ); - SG::HiveMgrSvc* pSGHM(dynamic_cast<SG::HiveMgrSvc*>(pWB)); + SG::HiveMgrSvc* pSGHM(dynamic_cast<SG::HiveMgrSvc*>(pWB.get())); assert( pSGHM ); //too late to change the number of stores @@ -141,8 +141,8 @@ int main() { //now test the HiveStoreSvc itself - StoreGateSvc* pHSG(0); - assert( pSvcLoc->service("StoreGateSvc", pHSG, true).isSuccess() ); + SmartIF<StoreGateSvc> pHSG{pSvcLoc->service("StoreGateSvc")}; + assert( pHSG.isValid() ); SG::TestHiveStoreSvc testHSG(*pHSG); testHSG.testNoSlot(); diff --git a/Control/StoreGate/test/SGTiming_test.cxx b/Control/StoreGate/test/SGTiming_test.cxx index 5e9aa31e62ec..1cf4403c028e 100644 --- a/Control/StoreGate/test/SGTiming_test.cxx +++ b/Control/StoreGate/test/SGTiming_test.cxx @@ -25,8 +25,8 @@ int main() { return 1; } - StoreGateSvc* pSG(0); - assert( pSvcLoc->service("StoreGateSvc", pSG, true).isSuccess() ); + SmartIF<StoreGateSvc> pSG{pSvcLoc->service("StoreGateSvc")}; + assert( pSG.isValid() ); std::chrono::time_point<std::chrono::high_resolution_clock> start, end; diff --git a/Control/StoreGate/test/SGtests.cxx b/Control/StoreGate/test/SGtests.cxx index f2f022553ac4..7def77a171ed 100644 --- a/Control/StoreGate/test/SGtests.cxx +++ b/Control/StoreGate/test/SGtests.cxx @@ -746,8 +746,8 @@ namespace Athena_test { // // try to bind it twice with a different key //FIXME assert(rSG.bind(chFoo,dbKey2).isSuccess()); - IProxyProviderSvc* pIPPSvc; - assert((rSG.serviceLocator()->service("ProxyProviderSvc", pIPPSvc, true)).isSuccess()); + SmartIF<IProxyProviderSvc> pIPPSvc{rSG.serviceLocator()->service("ProxyProviderSvc")}; + assert(pIPPSvc.isValid()); //FIXME TransientID id(ClassID_traits<Foo>::ID(), dbKey); //FIXME DataProxy *dp = pIPPSvc->getProxy(id, rSG); diff --git a/Control/StoreGate/test/SegMemSvc_test.cxx b/Control/StoreGate/test/SegMemSvc_test.cxx index 8bab258fd7a4..b14e193b4077 100644 --- a/Control/StoreGate/test/SegMemSvc_test.cxx +++ b/Control/StoreGate/test/SegMemSvc_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #include "TestTools/initGaudi.h" @@ -12,8 +12,8 @@ namespace Athena_test { void segmem_test (ISvcLocator *psvc) { - SegMemSvc* p_sms(0); - assert((psvc->service("SegMemSvc", p_sms, true)).isSuccess()); + SmartIF<SegMemSvc> p_sms{psvc->service("SegMemSvc")}; + assert ( p_sms.isValid() ); int* p_int = new ( p_sms->allocate<int>(SegMemSvc::EVENT) ) int(1001); diff --git a/Control/StoreGate/test/ShallowCopyDecorDeps_test.cxx b/Control/StoreGate/test/ShallowCopyDecorDeps_test.cxx index 20d0a9181a28..3963a5ca974c 100644 --- a/Control/StoreGate/test/ShallowCopyDecorDeps_test.cxx +++ b/Control/StoreGate/test/ShallowCopyDecorDeps_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ /** * @file StoreGate/test/ShallowCopyDecorDeps_test.cxx @@ -50,8 +50,8 @@ void test1 (ISvcLocator* svcloc) assert (owner.getProperty ("SCDDReadKeys").toString() == "['StoreGateSvc+myObj.d1','StoreGateSvc+myObj.d2']"); assert (owner.getProperty ("SCDDReadKeys").ownerTypeName() == "TestOwner"); - StoreGateSvc* sg = nullptr; - assert (svcloc->service ("StoreGateSvc", sg).isSuccess()); + SmartIF<StoreGateSvc> sg{ svcloc->service ("StoreGateSvc") }; + assert (sg.isValid()); assert (sg->record (std::make_unique<MyObj>(), "myObj", false).isSuccess()); EventContext ctx; diff --git a/Control/StoreGate/test/WriteCondHandle_test.cxx b/Control/StoreGate/test/WriteCondHandle_test.cxx index 4b10b9092cb1..f2f4cf2846d0 100644 --- a/Control/StoreGate/test/WriteCondHandle_test.cxx +++ b/Control/StoreGate/test/WriteCondHandle_test.cxx @@ -561,8 +561,8 @@ int main() return 1; } - StoreGateSvc *cs=nullptr; - assert (svcloc->service("StoreGateSvc/ConditionStore",cs).isSuccess()); + SmartIF<StoreGateSvc> cs{ svcloc->service("StoreGateSvc/ConditionStore") }; + assert (cs.isValid()); // test1(); // std::cout << "clearing ConditionStore\n"; diff --git a/Trigger/TrigEvent/TrigNavigation/share/HLTNavigation_test.ref b/Trigger/TrigEvent/TrigNavigation/share/HLTNavigation_test.ref index f7dcc7f85d22..d91f6d10f214 100644 --- a/Trigger/TrigEvent/TrigNavigation/share/HLTNavigation_test.ref +++ b/Trigger/TrigEvent/TrigNavigation/share/HLTNavigation_test.ref @@ -28,8 +28,6 @@ ClassIDSvc INFO getRegistryEntries: read 5881 CLIDRegistry entries fo TrigSerializeCn... INFO initialize() StoreGateSvc VERBOSE Initializing StoreGateSvc - package version StoreGate-00-00-00 StoreGateSvc DEBUG Service base class initialized successfully -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. HistogramPersis...WARNING Histograms saving not required. diff --git a/Trigger/TrigEvent/TrigNavigation/share/Holder_test.ref b/Trigger/TrigEvent/TrigNavigation/share/Holder_test.ref index a0a760da275a..5adca6cc716f 100644 --- a/Trigger/TrigEvent/TrigNavigation/share/Holder_test.ref +++ b/Trigger/TrigEvent/TrigNavigation/share/Holder_test.ref @@ -26,8 +26,6 @@ ApplicationMgr INFO Successfully loaded modules : StoreGate, TrigNavigatio ApplicationMgr INFO Application Manager Configured successfully ClassIDSvc INFO getRegistryEntries: read 2289 CLIDRegistry entries for module ALL TrigSerializeCn... INFO initialize() -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. HistogramPersis...WARNING Histograms saving not required. diff --git a/Trigger/TrigEvent/TrigNavigation/share/Ownership_test.ref b/Trigger/TrigEvent/TrigNavigation/share/Ownership_test.ref index 65011a89fd76..84a9ae87af23 100644 --- a/Trigger/TrigEvent/TrigNavigation/share/Ownership_test.ref +++ b/Trigger/TrigEvent/TrigNavigation/share/Ownership_test.ref @@ -26,8 +26,6 @@ ApplicationMgr INFO Successfully loaded modules : StoreGate, TrigNavigatio ApplicationMgr INFO Application Manager Configured successfully ClassIDSvc INFO getRegistryEntries: read 1529 CLIDRegistry entries for module ALL TrigSerializeCn... INFO initialize() -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc_Impl VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. HistogramPersis...WARNING Histograms saving not required. diff --git a/Trigger/TrigEvent/TrigNavigation/share/Registration_test.ref b/Trigger/TrigEvent/TrigNavigation/share/Registration_test.ref index 4503b1b5eddf..d46d18182cb0 100644 --- a/Trigger/TrigEvent/TrigNavigation/share/Registration_test.ref +++ b/Trigger/TrigEvent/TrigNavigation/share/Registration_test.ref @@ -28,8 +28,6 @@ ClassIDSvc INFO getRegistryEntries: read 5881 CLIDRegistry entries fo TrigSerializeCn... INFO initialize() StoreGateSvc VERBOSE Initializing StoreGateSvc - package version StoreGate-00-00-00 StoreGateSvc DEBUG Service base class initialized successfully -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service EventPersistencySvc -StoreGateSvc VERBOSE ServiceLocatorHelper::service: found service ClassIDSvc EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. HistogramPersis...WARNING Histograms saving not required. -- GitLab