Skip to content
Snippets Groups Projects
Commit ca4dd909 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'inputRenameMap.AthLinks-20241216' into 'main'

AthLinks+AthenaKernel+AthContainers+SGComps: Break out InputRenameEntry to reduce header dependencies.

See merge request atlas/athena!76778
parents e957ea0e 5515a8aa
No related branches found
No related tags found
No related merge requests found
Showing
with 113 additions and 52 deletions
......@@ -19,7 +19,7 @@
#include "AthContainersInterfaces/IAuxTypeVectorFactory.h"
#include "AthContainers/tools/AuxTypeVectorFactory.h"
#ifndef XAOD_STANDALONE
#include "AthenaKernel/IInputRename.h"
#include "AthenaKernel/InputRenameMap.h"
#include "AthenaKernel/IStringPool.h"
#endif
#include <cstddef>
......@@ -497,7 +497,7 @@ public:
* of auxiliary variables and makes that information available via
* @c inputRename.
*/
void setInputRenameMap (const Athena::IInputRename::InputRenameMap_t* map,
void setInputRenameMap (const Athena::InputRenameMap_t* map,
const IStringPool& pool);
#endif
......
......@@ -1234,7 +1234,7 @@ AuxTypeRegistry::~AuxTypeRegistry()
* @c inputRename.
*/
void
AuxTypeRegistry::setInputRenameMap (const Athena::IInputRename::InputRenameMap_t* map,
AuxTypeRegistry::setInputRenameMap (const Athena::InputRenameMap_t* map,
const IStringPool& pool)
{
auto impl = static_cast<AuxTypeRegistryImpl*> (this);
......
......@@ -441,7 +441,7 @@ void test_copyForOutput()
#ifndef XAOD_STANDALONE
void addto_renameMap (Athena::IInputRename::InputRenameMap_t& map,
void addto_renameMap (Athena::InputRenameMap_t& map,
IStringPool& pool,
const char* from,
const char* to)
......@@ -449,7 +449,7 @@ void addto_renameMap (Athena::IInputRename::InputRenameMap_t& map,
CLID clid = 123;
sgkey_t from_key = pool.stringToKey (from, clid);
sgkey_t to_key = pool.stringToKey (to, clid);
map[from_key] = Athena::IInputRename::Rename { to_key, to };
map[from_key] = Athena::InputRenameEntry { to_key, to };
}
#endif // NOT XAOD_STANDALONE
......@@ -460,7 +460,7 @@ void test_renameMap()
#ifndef XAOD_STANDALONE
TestStringPool pool;
Athena::IInputRename::InputRenameMap_t map;
Athena::InputRenameMap_t map;
addto_renameMap (map, pool, "a", "a_renamed");
addto_renameMap (map, pool, "b.c", "b.c_renamed");
......
// This file's extension implies that it's C, but it's really -*- 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
*/
/**
* @file AthLinks/tools/DataProxyHolder.h
......@@ -15,11 +15,11 @@
#define ATHLINKS_DATAPROXYHOLDER_H
#include "CxxUtils/sgkey_t.h"
#include "SGTools/CurrentEventStore.h"
#include "SGTools/DataProxy.h"
#include "AthenaKernel/IStringPool.h"
#include "AthenaKernel/RCUObject.h"
#include "AthenaKernel/IInputRename.h"
#include "CxxUtils/checker_macros.h"
#include <string>
#include <unordered_map>
......@@ -61,22 +61,18 @@ class DataProxyHolder
{
public:
/// Type of hashed keys.
typedef IStringPool::sgkey_t sgkey_t;
using sgkey_t = SG::sgkey_t;
/// Type of string keys.
typedef std::string ID_type;
using ID_type = std::string;
/// Generic pointer type.
typedef void* pointer_t;
typedef const void* const_pointer_t;
using pointer_t = void*;
using const_pointer_t = const void*;
/// Function casting from a @c SG::DataProxy to a pointer.
typedef void* castfn_t (SG::DataProxy*);
/// Input renaming map.
typedef Athena::IInputRename::InputRenameMap_t InputRenameMap_t;
typedef Athena::IInputRename::InputRenameRCU_t InputRenameRCU_t;
/**
* @brief Default constructor.
......@@ -379,13 +375,6 @@ public:
void throwInvalidLink (sgkey_t sgkey) const;
/**
* @brief Set map used for performing input renaming in toTransient.
* @param map The new map, or nullptr for no renmaing.
*/
static void setInputRenameMap ATLAS_NOT_THREAD_SAFE (const InputRenameRCU_t* map);
private:
/**
* @brief Test to see if we're pointing directly at an object.
......
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
* Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file AthLinks/DataProxyHolderInputRename.h
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2024
* @brief Set map used for performing input renaming in toTransient.
*
* Broken out from DataProxyHolder.h to reduce header dependencies.
*/
#ifndef ATHLINKS_DATAPROXYHOLDERINPUTRENAME_H
#define ATHLINKS_DATAPROXYHOLDERINPUTRENAME_H
#include "AthenaKernel/IInputRename.h"
#include "CxxUtils/checker_macros.h"
namespace SG {
/**
* @brief Set map used for performing input renaming in toTransient.
* @param map The new map, or nullptr for no renmaing.
*/
void setDataProxyHolderInputRenameMap ATLAS_NOT_THREAD_SAFE
(const Athena::IInputRename::InputRenameRCU_t* map);
} // namespace SG
#endif // not ATHLINKS_DATAPROXYHOLDERINPUTRENAME_H
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
/**
......@@ -11,6 +11,7 @@
#include "AthLinks/tools/DataProxyHolder.h"
#include "AthLinks/tools/DataProxyHolderInputRename.h"
#include "AthLinks/exceptions.h"
#include "SGTools/DataProxy.h"
#include "SGTools/TransientAddress.h"
......@@ -28,7 +29,7 @@ namespace {
/// Current input renaming map.
const SG::DataProxyHolder::InputRenameRCU_t* s_inputRenameMap ATLAS_THREAD_SAFE
const Athena::IInputRename::InputRenameRCU_t* s_inputRenameMap ATLAS_THREAD_SAFE
= nullptr;
......@@ -333,6 +334,7 @@ DataProxyHolder::toTransient (sgkey_t sgkey, IProxyDict* sg /*= 0*/)
// Do input renaming.
if (s_inputRenameMap) {
using InputRenameMap_t = Athena::InputRenameMap_t;
Athena::RCURead<InputRenameMap_t> r (*s_inputRenameMap);
auto it = r->find (sgkey);
if (it != r->end())
......@@ -611,7 +613,8 @@ bool DataProxyHolder::operator== (const DataProxyHolder& other) const
* @brief Set map used for performing input renaming in toTransient.
* @param map The new map, or nullptr for no renmaing.
*/
void DataProxyHolder::setInputRenameMap ATLAS_NOT_THREAD_SAFE (const InputRenameRCU_t* map)
void setDataProxyHolderInputRenameMap ATLAS_NOT_THREAD_SAFE
(const Athena::IInputRename::InputRenameRCU_t* map)
{
s_inputRenameMap = map;
}
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file AthLinks/test/DataProxyHolder_test.cxx
......@@ -10,6 +10,7 @@
#undef NDEBUG
#include "AthLinks/tools/DataProxyHolder.h"
#include "AthLinks/tools/DataProxyHolderInputRename.h"
#include "AthLinks/exceptions.h"
#include "SGTools/StringPool.h"
#include "AthenaKernel/getMessageSvc.h"
......@@ -367,18 +368,19 @@ void test7 (SGTest::TestStore& store)
}
SG::DataProxyHolder::InputRenameRCU_t inputRenameMap(1);
Athena::IInputRename::InputRenameRCU_t inputRenameMap(1);
void initInputRename ATLAS_NOT_THREAD_SAFE ()
{
using InputRenameMap_t = Athena::InputRenameMap_t;
SG::StringPool sp;
auto m = std::make_unique<SG::DataProxyHolder::InputRenameMap_t>();
Athena::IInputRename::Rename ren { sp.stringToKey("fooy", fooclid), "fooy" };
auto m = std::make_unique<InputRenameMap_t>();
Athena::InputRenameEntry ren { sp.stringToKey("fooy", fooclid), "fooy" };
(*m)[sp.stringToKey("foox", fooclid)] = ren;
Athena::RCUUpdate<SG::DataProxyHolder::InputRenameMap_t> u (inputRenameMap);
Athena::RCUUpdate<InputRenameMap_t> u (inputRenameMap);
u.update (std::move (m));
SG::DataProxyHolder::setInputRenameMap (&inputRenameMap);
SG::setDataProxyHolderInputRenameMap (&inputRenameMap);
}
......
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file AthenaKernel/IInputRename.h
......@@ -15,9 +15,8 @@
#include "AthenaKernel/RCUObject.h"
#include "CxxUtils/sgkey_t.h"
#include "AthenaKernel/InputRenameMap.h"
#include "GaudiKernel/IInterface.h"
#include <unordered_map>
namespace Athena {
......@@ -36,14 +35,7 @@ class IInputRename
: virtual public IInterface
{
public:
/// Type of the input rename map: sgkey_t -> sgkey_t.
struct Rename
{
SG::sgkey_t m_sgkey;
std::string m_key;
};
typedef SG::SGKeyMap<Rename> InputRenameMap_t;
typedef RCUObject<InputRenameMap_t> InputRenameRCU_t;
using InputRenameRCU_t = RCUObject<InputRenameMap_t>;
DeclareInterfaceID (IInputRename,1,0);
......
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
* Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file AthenaKernel/InputRenameMap.h
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2024
* @brief Map keeping track of requested input renames.
*
* Broken out from IInputRename in order to reduce header dependencies.
*/
#ifndef ATHENAKERNEL_INPUTRENAMEMAP_H
#define ATHENAKERNEL_INPUTRENAMEMAP_H
#include "CxxUtils/sgkey_t.h"
#include <string>
namespace Athena {
/// Type of the input rename map: sgkey_t -> sgkey_t.
struct InputRenameEntry
{
SG::sgkey_t m_sgkey;
std::string m_key;
};
using InputRenameMap_t = SG::SGKeyMap<InputRenameEntry>;
} // namespace Athena
#endif // not ATHENAKERNEL_INPUTRENAMEMAP_H
......@@ -21,7 +21,7 @@
#include "SGTools/DataProxy.h"
#include "SGTools/TransientAddress.h"
#include "AthLinks/tools/DataProxyHolder.h"
#include "AthLinks/tools/DataProxyHolderInputRename.h"
#include "AthContainers/AuxTypeRegistry.h"
#include "AthContainersInterfaces/IAuxStore.h"
#include "CxxUtils/checker_macros.h"
......@@ -156,14 +156,14 @@ StatusCode AddressRemappingSvc::initInputRenames()
// Translate to sgkeys and add to the map.
SG::sgkey_t from_key = m_proxyDict->stringToKey (from, clid);
SG::sgkey_t to_key = m_proxyDict->stringToKey (to, clid);
newmap[from_key] = Athena::IInputRename::Rename { to_key, to };
newmap[from_key] = Athena::InputRenameEntry { to_key, to };
}
// Publish the map.
addInputRenames (newmap);
if (!m_typeKeyRenameMaps.empty()) {
SG::DataProxyHolder::setInputRenameMap (m_inputRenames.get());
SG::setDataProxyHolderInputRenameMap (m_inputRenames.get());
Athena::RCURead<InputRenameMap_t> r (*m_inputRenames);
SG::AuxTypeRegistry::instance().setInputRenameMap (&*r,
*m_proxyDict);
......@@ -401,7 +401,7 @@ StatusCode AddressRemappingSvc::renameTads (IAddressProvider::tadList& tads) con
SG::sgkey_t from_key = m_proxyDict->stringToKey (tad->name(), clid);
if (r->find(from_key) == r->end()) {
SG::sgkey_t to_key = m_proxyDict->stringToKey (name_renamed, clid);
newmap[from_key] = Athena::IInputRename::Rename { to_key, name_renamed };
newmap[from_key] = Athena::InputRenameEntry { to_key, name_renamed };
}
}
......
......@@ -109,8 +109,8 @@ private: // Data
/// Map of sgkey->sgkey for input renames.
/// This object is exported via inputRenameMap and is synchronized
/// via RCU.
typedef Athena::IInputRename::InputRenameMap_t InputRenameMap_t;
typedef Athena::IInputRename::InputRenameRCU_t InputRenameRCU_t;
using InputRenameMap_t = Athena::InputRenameMap_t;
using InputRenameRCU_t = Athena::IInputRename::InputRenameRCU_t;
std::unique_ptr<InputRenameRCU_t> m_inputRenames;
Gaudi::Property<bool> m_skipBadRemappings{this,"SkipBadRemappings",false,
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
......@@ -283,13 +283,13 @@ void test1 (Athena::IInputRename& svc,
checkTADList (tads, addrs);
}
Athena::RCURead<Athena::IInputRename::InputRenameMap_t> r
Athena::RCURead<Athena::InputRenameMap_t> r
(*svc.inputRenameMap());
assert (r->size() == 5);
CLID fooclid = ClassID_traits<xAODFoo>::ID();
SG::StringPool sp;
Athena::IInputRename::InputRenameMap_t::const_iterator it;
Athena::InputRenameMap_t::const_iterator it;
it = r->find (sp.stringToKey ("foo1", fooclid));
assert (it != r->end());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment