Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Control/AthenaKernel/AthenaKernel/ClassID_traits.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENAKERNEL_CLASSID_TRAITS_H
6 #define ATHENAKERNEL_CLASSID_TRAITS_H
7 
14 #include "AthenaKernel/ClassName.h"
15 #include "GaudiKernel/ClassID.h"
16 
17 #include <string>
18 #include <typeinfo>
19 #include <type_traits>
20 #include <concepts>
21 
22 
24 #define MY_STATIC_ASSERT( B ) \
25  static_assert (B, "You should use the CLASS_DEF macro to define CLID and VERSION")
27 
36 template <typename T>
38  // Always false, but needs to depend on T to prevent the assertions
39  // from being instantiated too early.
40  static const bool s_isDataObject = std::same_as<T, ClassID_trait_dummy>;
41  using has_classID_tag = std::false_type;
42  static const int s_version = 0;
43 
44  static CLID ID() {
46  return CLID_NULL;
47  }
48 
49  static const std::string& typeName() {
51  static const std::string dummy;
52  return dummy;
53  }
54 
55  static const std::type_info& typeInfo() {
57  return typeid(int);
58  }
59 };
60 
61 
67 template <typename T>
69  { T::classID() } -> std::convertible_to<CLID>;
70 }
71 struct ClassID_traits<T> {
72  static const bool s_isDataObject = true;
73 
75  static const CLID& ID() {
76  return T::classID();
77  }
78 
80  static const std::string& typeName() {
81  static const std::string tname = Athena::typeinfoName(typeid(T));
82  return tname;
83  }
84 
86  static const std::type_info& typeInfo() {
87  return typeid(T);
88  }
89 
90  using has_version_tag = std::false_type;
91  using has_classID_tag = std::false_type;
92 
93  static const int s_version = 0;
94 
95  // Is this is true, these types will automatically be made
96  // const when added to StoreGate.
97  static const bool s_isConst = false;
98 };
99 
100 #undef MY_STATIC_ASSERT
101 
102 #endif // not ATHENAKERNEL_CLASSID_TRAITS_H
requires
requires requires()
This specialization is used for classes deriving from DataObject.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:68
ClassID_trait_dummy
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:26
ClassID_traits::s_version
static const int s_version
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:42
ClassID_traits::typeName
static const std::string & typeName()
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:49
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition: AthenaKernel/src/ClassName.cxx:23
ClassName.h
An interface for getting the name of a class as a string.
ClassID_traits< T >::has_classID_tag
std::false_type has_classID_tag
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:91
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
ClassID_traits< T >::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:75
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
python.xAODType.dummy
dummy
Definition: xAODType.py:4
ClassID_traits< DV >::has_classID_tag
std::false_type has_classID_tag
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:41
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ClassID_traits< T >::has_version_tag
std::false_type has_version_tag
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:90
MY_STATIC_ASSERT
#define MY_STATIC_ASSERT(B)
internal use: issues a compilation error when condition B is false
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:24
ClassID_traits::s_isDataObject
static const bool s_isDataObject
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
ClassID_traits::typeInfo
static const std::type_info & typeInfo()
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:55
ClassID_traits< T >::typeName
static const std::string & typeName()
the demangled type name of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:80
ClassID_traits::ID
static CLID ID()
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
ClassID_traits< T >::typeInfo
static const std::type_info & typeInfo()
the type id of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:86
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35