From c533eb4d9d155ba002b72f53ab889dbbd8cce458 Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Tue, 26 Jul 2022 10:18:17 -0400
Subject: [PATCH 1/2] CxxUtils: Prepare for a possible migration to 64-bit
 sgkey.

Move definition of sgkey_t here from AthenaKernel so that it can be used
in standalone xAOD builds.

Introduce functions for comparing sgkey_t values, and introduce names
for maps and sets with sgkey_t values as keys.
---
 Control/CxxUtils/CxxUtils/sgkey_t.h | 76 +++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Control/CxxUtils/CxxUtils/sgkey_t.h

diff --git a/Control/CxxUtils/CxxUtils/sgkey_t.h b/Control/CxxUtils/CxxUtils/sgkey_t.h
new file mode 100644
index 000000000000..52266cd7edcf
--- /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
-- 
GitLab


From 2c941b9ce5f29860107eadf7fb8bb76d7bb1bebb Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Mon, 25 Jul 2022 12:30:32 -0400
Subject: [PATCH 2/2] AthenaKernel: Prepare for a possible migration to 64-bit
 sgkey.

Introduce functions for comparing sgkey_t values, and introduce names
for maps and sets with sgkey_t values as keys.
---
 .../AthenaKernel/AthenaKernel/IInputRename.h  |  9 +++-----
 .../AthenaKernel/AthenaKernel/IProxyDict.h    |  4 ++--
 .../AthenaKernel/AthenaKernel/IStringPool.h   |  5 ++---
 .../AthenaKernel/AthenaKernel/ThinningCache.h |  6 +++---
 .../AthenaKernel/getThinningCache.h           |  4 ++--
 Control/AthenaKernel/AthenaKernel/sgkey_t.h   | 21 ++++---------------
 6 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/Control/AthenaKernel/AthenaKernel/IInputRename.h b/Control/AthenaKernel/AthenaKernel/IInputRename.h
index 62d6dbbcf9f5..442cd2ffb879 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 affdaf3b27c2..e0800fddce85 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 2b89bcca0b6c..af7c5e8ca31b 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 eed9b3d96cde..28626d99e3ba 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 a86ea1d1b726..5c5d7fa3e4c7 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 097984144c8b..2e9e03263ca9 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
-- 
GitLab