From 3e5aea93e81479b711060a83f958adbfff4b0095 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Thu, 9 May 2019 15:34:13 +0200 Subject: [PATCH] SGComps: Have AddressRemappingSvc implement deletions via renaming. When a clid/key is mentioned in a WriteHandleKey, we hide the corresponding object from an input file. This has been handled in AddressRemappingSvc by removing any such TAD from the list of TADS. However, it turns out to be useful in some cases to be able to get a proxy for the original objects in the input file. This is the case, for example, when we want to wrap converters with algorithms. Change so that instead of deleting a TAD, we rename it by appending `_DELETED' to the key. We do not preserve symlinks/aliases at this time. --- Control/SGComps/src/AddressRemappingSvc.cxx | 15 +++++++++-- .../SGComps/test/AddressRemappingSvc_test.cxx | 25 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Control/SGComps/src/AddressRemappingSvc.cxx b/Control/SGComps/src/AddressRemappingSvc.cxx index 8efdb0af1a2..adbd41f0bc8 100644 --- a/Control/SGComps/src/AddressRemappingSvc.cxx +++ b/Control/SGComps/src/AddressRemappingSvc.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /** @file AddressRemappingSvc.cxx @@ -32,6 +32,7 @@ #include "boost/range.hpp" + //________________________________________________________________________________ AddressRemappingSvc::AddressRemappingSvc(const std::string& name, ISvcLocator* pSvcLocator) : extends1<AthService, Athena::IInputRename>(name, pSvcLocator), @@ -413,7 +414,17 @@ StatusCode AddressRemappingSvc::renameTads (IAddressProvider::tadList& tads) } else if (isDeleted (*tad)) { - pos = tads.erase (pos); + // Rename the existing TAD to end in _DELETED. + // Drop alias/symlinks in the process. + auto tad_new = std::make_unique<SG::TransientAddress> + (tad->clID(), tad->name() + "_DELETED", + tad->address(), tad->clearAddress()); + tad_new->setProvider (tad->provider(), tad->storeID()); + // Replace the old TAD in the list with the new one. + delete tad; + tad = tad_new.release(); + + ++pos; } else { diff --git a/Control/SGComps/test/AddressRemappingSvc_test.cxx b/Control/SGComps/test/AddressRemappingSvc_test.cxx index 3cf6cfd00cd..2e91a4e60e2 100644 --- a/Control/SGComps/test/AddressRemappingSvc_test.cxx +++ b/Control/SGComps/test/AddressRemappingSvc_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id$ @@ -195,12 +195,15 @@ void fillTADList (IAddressProvider::tadList& tads, // Foo/bar1 // Foo/bar2 + symlink 321 + aliases bar2.d1, bar2.d2, bar2.x2 // Foo/foo3 + aliases foo3.x1, foo3.d2 +// Foo/fee1_DELETED +// Foo/fee1Aux._DELETED void checkTADList (const IAddressProvider::tadList& tads, const Addrs& addrs) { CLID fooclid = ClassID_traits<xAODFoo>::ID(); + CLID auxclid = ClassID_traits<SG::IConstAuxStore>::ID(); - assert (tads.size() == 3); + assert (tads.size() == 5); size_t i = 0; for (const SG::TransientAddress* tad : tads) { if (i == 0) { @@ -235,6 +238,24 @@ void checkTADList (const IAddressProvider::tadList& tads, (SG::TransientAddress::TransientAliasSet { "foo3.x1", "foo3.d2" })); } + else if (i == 3) { + assert (tad->clID() == fooclid); + assert (tad->name() == "fee1_DELETED"); + assert (tad->address() == &addrs.addr4); + assert (tad->clearAddress() == false); + assert (tad->transientID() == + SG::TransientAddress::TransientClidSet { fooclid }); + assert (tad->alias().empty()); + } + else if (i == 4) { + assert (tad->clID() == auxclid); + assert (tad->name() == "fee1Aux._DELETED"); + assert (tad->address() == &addrs.addr5); + assert (tad->clearAddress() == false); + assert (tad->transientID() == + SG::TransientAddress::TransientClidSet { auxclid }); + assert (tad->alias().empty()); + } ++i; } } -- GitLab