From 4ed56db066b7e49f8337e2f24cd453fe23e34d39 Mon Sep 17 00:00:00 2001 From: Christos Anastopoulos <christos.anastopoulos@cern.ch> Date: Fri, 10 Apr 2020 18:09:49 +0000 Subject: [PATCH] auto_ptr removal from StoreGateSvc ATLASRECTS-5296 --- .../test/ProxyProviderSvc_test.cxx | 4 +- Control/StoreGate/StoreGate/StoreGateSvc.h | 42 ++----------------- Control/StoreGate/StoreGate/StoreGateSvc.icc | 38 ----------------- Control/StoreGate/StoreGate/tools/SGImplSvc.h | 4 +- 4 files changed, 8 insertions(+), 80 deletions(-) diff --git a/AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx b/AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx index 65293fb1b8f..1f2613e2486 100644 --- a/AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx +++ b/AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx @@ -124,7 +124,7 @@ void testReadPrivate(StoreGateSvc& rSG) { cout << "*** ProxyProviderSvc_test readPrivate BEGINS ***" <<endl; std::unique_ptr<Foo> apFoo; - SGASSERTERROR((rSG.readPrivateCopy<Foo>("NotThere")).get() != nullptr); + SGASSERTERROR((rSG.readUniquePrivateCopy<Foo>("NotThere")).get() != nullptr); apFoo=rSG.readUniquePrivateCopy<Foo>("diskFoo"); assert(nullptr != apFoo.get()); @@ -161,7 +161,7 @@ void testReadPrivate(StoreGateSvc& rSG) { assert(floatEQ(3.14f, static_cast<float>(pFoo33->a()))); assert(pFoo33 == pFoo33Orig); //the private copy we recorded. assert(pFoo33 != &*bpFoo); //not one of the private copies - SGASSERTERROR((rSG.readPrivateCopy<Foo>("silly33")).get() != nullptr); + SGASSERTERROR((rSG.readUniquePrivateCopy<Foo>("silly33")).get() != nullptr); assert(rSG.retrieve<Foo>("silly33")); std::unique_ptr<Foo> aptrFoo33(rSG.retrieveUniquePrivateCopy<Foo>("silly33")); assert(aptrFoo33.get() == pFoo33); diff --git a/Control/StoreGate/StoreGate/StoreGateSvc.h b/Control/StoreGate/StoreGate/StoreGateSvc.h index f808539228f..cf011a6bff0 100644 --- a/Control/StoreGate/StoreGate/StoreGateSvc.h +++ b/Control/StoreGate/StoreGate/StoreGateSvc.h @@ -1,7 +1,7 @@ /* -*- C++ -*- */ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef STOREGATE_STOREGATESVC_H @@ -33,7 +33,7 @@ #include <cstddef> // for size_t #include <list> -#include <memory> /* auto_ptr */ +#include <memory> #include <mutex> #include <string> #include <sys/types.h> // for off_t @@ -181,9 +181,6 @@ public: template <typename T, typename TKEY> StatusCode record(const T* p2BRegistered, const TKEY& key); - /// Record an object with a key, take ownership of the auto_pointed obj - template <typename T, typename TKEY> - StatusCode record(std::auto_ptr<T> p2BRegistered, const TKEY& key); /// Record an object with a key, allow possibility of specifying /// const-access. @@ -296,9 +293,6 @@ public: StatusCode overwrite(T* p2BRegistered, const TKEY& key, bool allowMods, bool noHist=false); - /// Record an object with a key, overwriting any existing object with same key, take ownership of the auto_pointed obj - template <typename T, typename TKEY> - StatusCode overwrite(std::auto_ptr<T> p2BRegistered, const TKEY& key); /// Record an object with a key, overwriting any existing object with same key template <typename T, typename TKEY> @@ -392,18 +386,6 @@ public: - /// EXPERTS ONLY: reads from disk your very own private copy of a StoreGate - /// object of type T and given key, if available and locked. - /// readPrivateCopy does not look up the object in SG transient memory - /// so it will fail to return a newly recorded object. - /// You are responsible for managing the returned object and for keeping it - /// in sync with the "main" copy in transient memory, if any. - /// DEPRECATED: Prefer readUniquePrivateCopy. - /// @param key The key to use for the lookup. - /// @return null auto_ptr if the object isn't found or if it is unlocked. - template <typename T> - std::auto_ptr<T> readPrivateCopy (const std::string& key); - /// EXPERTS ONLY: reads from disk your very own private copy of a StoreGate /// object of type T and given key, if available and locked. /// readPrivateCopy does not look up the object in SG transient memory @@ -411,7 +393,7 @@ public: /// You are responsible for managing the returned object and for keeping it /// in sync with the "main" copy in transient memory, if any. /// @param key The key to use for the lookup. - /// @return null auto_ptr if the object isn't found or if it is unlocked. + /// @return null unique_ptr if the object isn't found or if it is unlocked. template <typename T> std::unique_ptr<T> readUniquePrivateCopy (const std::string& key); @@ -420,22 +402,6 @@ public: typeless_readPrivateCopy(const CLID& clid, const std::string& key); - /// EXPERTS ONLY: like readPrivateCopy this method returns your own private - /// copy of a data object of type T and given key, if available and locked. - /// The difference is that it will return you also an object in SG transient - /// memory. Since we are taking ownership of it, the object in SG - /// will be released after retrievePrivateCopy returns, making - /// all cached references to the object potentially invalid and - /// obviously preventing it from being written out. - /// Sequencing becomes critical. Caveat emptor! - /// - /// DEPRECATED: Prefer retrieveUniquePrivateCopy. - /// - /// @param key The key to use for the lookup. - /// @return null auto_ptr if the object isn't found or if it is unlocked. - template <typename T> - std::auto_ptr<T> retrievePrivateCopy (const std::string& key); - /// EXPERTS ONLY: like readPrivateCopy this method returns your own private /// copy of a data object of type T and given key, if available and locked. /// The difference is that it will return you also an object in SG transient @@ -446,7 +412,7 @@ public: /// Sequencing becomes critical. Caveat emptor! /// /// @param key The key to use for the lookup. - /// @return null auto_ptr if the object isn't found or if it is unlocked. + /// @return null unique_ptr if the object isn't found or if it is unlocked. template <typename T> std::unique_ptr<T> retrieveUniquePrivateCopy (const std::string& key); diff --git a/Control/StoreGate/StoreGate/StoreGateSvc.icc b/Control/StoreGate/StoreGate/StoreGateSvc.icc index 3791154c46c..1e7384135fb 100644 --- a/Control/StoreGate/StoreGate/StoreGateSvc.icc +++ b/Control/StoreGate/StoreGate/StoreGateSvc.icc @@ -179,22 +179,6 @@ StoreGateSvc::create(const TKEY& key, ARGS... constructorArgs) { // record an object with key ////////////////////////////////////////////////////////////////// template <typename T, typename TKEY> -StatusCode StoreGateSvc::record(std::auto_ptr<T> pAuto, const TKEY& key) -{ - const bool ALLOWMODS(true); - return record (pAuto.release(), key, ALLOWMODS); //SG takes ownership -} - -template <typename T, typename TKEY> -StatusCode -StoreGateSvc::overwrite(std::auto_ptr<T> pAuto, const TKEY& key) -{ - const bool ALLOWMODS(true); - return overwrite(pAuto.release(), key, ALLOWMODS); //SG takes ownership -} - -//------------------------------------------------------------------- -template <typename T, typename TKEY> StatusCode StoreGateSvc::record(T* pObject, const TKEY& key) { const bool ALLOWMODS(true); @@ -813,28 +797,6 @@ StoreGateSvc::retrieveAllVersions(std::list< SG::ObjectWithVersion<T> >& allVers } -template <typename T> -std::auto_ptr<T> -StoreGateSvc::readPrivateCopy (const std::string& key) { - return std::auto_ptr<T>(SG::Storable_cast<T>( - this->typeless_readPrivateCopy(ClassID_traits<T>::ID(), key))); -} - - -template <typename T> -std::auto_ptr<T> -StoreGateSvc::retrievePrivateCopy (const std::string& key) { - CLID clid = ClassID_traits<T>::ID(); - DataObject* obj = this->currentStore()->typeless_retrievePrivateCopy(clid, key); - std::auto_ptr<T> ret (SG::Storable_cast<T>(obj)); - if (DataBucketBase* dbb = dynamic_cast<DataBucketBase*> (obj)) - { - dbb->relinquish(); - } - obj->release(); - return ret; -} - template <typename T> std::unique_ptr<T> StoreGateSvc::readUniquePrivateCopy (const std::string& key) { diff --git a/Control/StoreGate/StoreGate/tools/SGImplSvc.h b/Control/StoreGate/StoreGate/tools/SGImplSvc.h index 93c61cbf732..eef4075a2ae 100644 --- a/Control/StoreGate/StoreGate/tools/SGImplSvc.h +++ b/Control/StoreGate/StoreGate/tools/SGImplSvc.h @@ -1,7 +1,7 @@ /* -*- C++ -*- */ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef STOREGATE_SGIMPLSVC_H @@ -30,7 +30,7 @@ #include <cstddef> // for size_t #include <list> -#include <memory> /* auto_ptr */ +#include <memory> #include <string> #include <sys/types.h> // for off_t #include <vector> -- GitLab