diff --git a/Control/AthenaKernel/AthenaKernel/IInputRename.h b/Control/AthenaKernel/AthenaKernel/IInputRename.h index 62d6dbbcf9f5c0246fe70152eff4e65cf16647a8..442cd2ffb879cbe37569e89c9f52cdf83b5a10c8 100644 --- a/Control/AthenaKernel/AthenaKernel/IInputRename.h +++ b/Control/AthenaKernel/AthenaKernel/IInputRename.h @@ -1,10 +1,7 @@ // This file's extension implies that it's C, but it's really -*- C++ -*-. - /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ - -// $Id$ /** * @file AthenaKernel/IInputRename.h * @author scott snyder <snyder@bnl.gov> @@ -17,8 +14,8 @@ #define ATHENAKERNEL_IINPUTRENAME_H -#include "AthenaKernel/sgkey_t.h" #include "AthenaKernel/RCUObject.h" +#include "CxxUtils/sgkey_t.h" #include "GaudiKernel/IInterface.h" #include <unordered_map> @@ -45,7 +42,7 @@ public: SG::sgkey_t m_sgkey; std::string m_key; }; - typedef std::unordered_map<SG::sgkey_t, Rename> InputRenameMap_t; + typedef SG::SGKeyMap<Rename> InputRenameMap_t; typedef RCUObject<InputRenameMap_t> InputRenameRCU_t; DeclareInterfaceID (IInputRename,1,0); diff --git a/Control/AthenaKernel/AthenaKernel/IProxyDict.h b/Control/AthenaKernel/AthenaKernel/IProxyDict.h index affdaf3b27c22e1a6496734f1d2cfbe0adfabf35..e0800fddce85979dbfd0ffdb6139c719ba35d3b8 100644 --- a/Control/AthenaKernel/AthenaKernel/IProxyDict.h +++ b/Control/AthenaKernel/AthenaKernel/IProxyDict.h @@ -1,14 +1,14 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHENAKERNEL_IPROXYDICT_H # define ATHENAKERNEL_IPROXYDICT_H // INCLUDES -#include "AthenaKernel/sgkey_t.h" +#include "CxxUtils/sgkey_t.h" #include "AthenaKernel/IStringPool.h" #include "AthenaKernel/IHiveStore.h" #include "AthenaKernel/DataObjectSharedPtr.h" diff --git a/Control/AthenaKernel/AthenaKernel/IStringPool.h b/Control/AthenaKernel/AthenaKernel/IStringPool.h index 2b89bcca0b6c54ecf17039905bd4597876e81110..af7c5e8ca31bd4705272897f64a0cf6854e4c27b 100644 --- a/Control/AthenaKernel/AthenaKernel/IStringPool.h +++ b/Control/AthenaKernel/AthenaKernel/IStringPool.h @@ -1,10 +1,9 @@ // This file's extension implies that it's C, but it's really -*- C++ -*-. /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ -// $Id: IStringPool.h,v 1.3 2008-09-03 17:19:10 ssnyder Exp $ /** * @file AthenaKernel/IStringPool.h * @author scott snyder <snyder@bnl.gov> @@ -17,7 +16,7 @@ #define ATHENAKERNEL_ISTRINGPOOL_H -#include "AthenaKernel/sgkey_t.h" +#include "CxxUtils/sgkey_t.h" #include "GaudiKernel/ClassID.h" #include <string> diff --git a/Control/AthenaKernel/AthenaKernel/ThinningCache.h b/Control/AthenaKernel/AthenaKernel/ThinningCache.h index eed9b3d96cde364b1f6b486d9b9ca1ca7d517197..28626d99e3ba77f08ad79fa319476c78c618f709 100644 --- a/Control/AthenaKernel/AthenaKernel/ThinningCache.h +++ b/Control/AthenaKernel/AthenaKernel/ThinningCache.h @@ -1,6 +1,6 @@ // This file's extension implies that it's C, but it's really -*- C++ -*-. /* - * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration. + * Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration. */ /** * @file AthKernel/ThinningCache.h @@ -16,7 +16,7 @@ #include "AthenaKernel/ThinningDecisionBase.h" #include "AthenaKernel/ThinningInfo.h" -#include "AthenaKernel/sgkey_t.h" +#include "CxxUtils/sgkey_t.h" #include "CxxUtils/ConcurrentBitset.h" #include <unordered_map> #include <string> @@ -153,7 +153,7 @@ private: map_t m_map; /// Mapping by hashed SG key. - typedef std::unordered_map<sgkey_t, ThinningInfo> sgmap_t; + typedef SGKeyMap<ThinningInfo> sgmap_t; sgmap_t m_sgmap; /// List of decision objects we've copied in order to handle merges. diff --git a/Control/AthenaKernel/AthenaKernel/getThinningCache.h b/Control/AthenaKernel/AthenaKernel/getThinningCache.h index a86ea1d1b726f22a8cbf740e5a559b75199611a2..5c5d7fa3e4c7561eeeef9f8db3b7ca573b011d10 100644 --- a/Control/AthenaKernel/AthenaKernel/getThinningCache.h +++ b/Control/AthenaKernel/AthenaKernel/getThinningCache.h @@ -1,6 +1,6 @@ // This file's extension implies that it's C, but it's really -*- C++ -*-. /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /** * @file AthenaKernel/getThinningCache.h @@ -14,7 +14,7 @@ #define ATHENAKERNEL_GETTHINNINGCACHE_H -#include "AthenaKernel/sgkey_t.h" +#include "CxxUtils/sgkey_t.h" #include <string> class EventContext; diff --git a/Control/AthenaKernel/AthenaKernel/sgkey_t.h b/Control/AthenaKernel/AthenaKernel/sgkey_t.h index 097984144c8ba1cccb14d5a1e608d6691f659434..2e9e03263ca905582d418f87c0834ad0548a24e6 100644 --- a/Control/AthenaKernel/AthenaKernel/sgkey_t.h +++ b/Control/AthenaKernel/AthenaKernel/sgkey_t.h @@ -1,18 +1,14 @@ // This file's extension implies that it's C, but it's really -*- C++ -*-. - /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ - -// $Id$ /** * @file AthenaKernel/sgkey_t.h * @author scott snyder <snyder@bnl.gov> * @date Nov, 2013 * @brief Define the type used for hashed StoreGate key+CLID pairs. * - * These are managed by @c IProxyDict. This definition was broken - * out from there due to dependency issues. + * This has now been moved to CxxUtils. */ @@ -20,17 +16,8 @@ #define ATHENAKERNEL_SGKEY_T_H -#include <stdint.h> - - -namespace SG { - - -/// Type used for hashed StoreGate key+CLID pairs. -typedef uint32_t sgkey_t; - - -} // namespace SG +// Moved to CxxUtils. +#include "CxxUtils/sgkey_t.h" #endif // not ATHENAKERNEL_SGKEY_T_H diff --git a/Control/CxxUtils/CxxUtils/sgkey_t.h b/Control/CxxUtils/CxxUtils/sgkey_t.h new file mode 100644 index 0000000000000000000000000000000000000000..52266cd7edcf5cd4d65092008c2e1b0fa36d7f4b --- /dev/null +++ b/Control/CxxUtils/CxxUtils/sgkey_t.h @@ -0,0 +1,76 @@ +// 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 +*/ +/** + * @file CxxUtils/sgkey_t.h + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2013 + * @brief Define the type used for hashed StoreGate key+CLID pairs. + * + * These are managed by @c IProxyDict. This definition was broken + * out from there due to dependency issues. This would more naturally + * be in AthenaKernel, but we put it in CxxUtils so that it can be used + * by xAOD standanone code as well. + */ + + +#ifndef CXXUTILS_SGKEY_T_H +#define CXXUTILS_SGKEY_T_H + + +#include <cstdint> +#include <unordered_map> +#include <unordered_set> + + +namespace SG { + + +/// Type used for hashed StoreGate key+CLID pairs. +typedef uint32_t sgkey_t; + + +/** + * @brief Compare two sgkeys for equality. + */ +inline +constexpr bool sgkeyEqual (const sgkey_t a, const sgkey_t b) +{ + return a == b; +} + + +/** + * @brief Compare two sgkeys for ordering. + */ +inline +constexpr bool sgkeyLess (const sgkey_t a, const sgkey_t b) +{ + return a < b; +} + + +/** + * @brief Convert a sgkey to the 32-bit form used for older data. + */ +inline +constexpr uint32_t sgkeyShort (const sgkey_t k) +{ + return k; +} + + +/// A map using sgkey_t as a key. +template <class T> +using SGKeyMap = std::unordered_map<sgkey_t, T>; + + +/// A set of sgkey_t values. +using SGKeySet = std::unordered_set<sgkey_t>; + + +} // namespace SG + + +#endif // not CXXUTILS_SGKEY_T_H