ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaKernel
AthenaKernel
Control/AthenaKernel/AthenaKernel/ClassID_traits.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef ATHENAKERNEL_CLASSID_TRAITS_H
6
#define ATHENAKERNEL_CLASSID_TRAITS_H
13
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")
26
class
ClassID_trait_dummy
{};
27
36
template
<
typename
T>
37
struct
ClassID_traits
{
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
constexpr
CLID
ID
() {
45
MY_STATIC_ASSERT
(
s_isDataObject
);
46
return
CLID_NULL;
47
}
48
49
static
const
std::string&
typeName
() {
50
MY_STATIC_ASSERT
(
s_isDataObject
);
51
static
const
std::string dummy;
52
return
dummy;
53
}
54
55
static
const
std::type_info&
typeInfo
() {
56
MY_STATIC_ASSERT
(
s_isDataObject
);
57
return
typeid
(int);
58
}
59
};
60
61
67
template
<
typename
T>
68
requires
requires
() {
69
{ T::classID() } -> std::convertible_to<CLID>;
70
}
71
struct
ClassID_traits
<T> {
72
static
const
bool
s_isDataObject
=
true
;
73
75
static
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
ClassName.h
An interface for getting the name of a class as a string.
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
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ClassID_trait_dummy
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:26
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition
AthenaKernel/src/ClassName.cxx:23
ClassID_traits< T >::ID
static CLID ID()
the CLID of T
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:75
ClassID_traits< T >::has_classID_tag
std::false_type has_classID_tag
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:91
ClassID_traits< T >::s_isDataObject
static const bool s_isDataObject
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:72
ClassID_traits< T >::s_isConst
static const bool s_isConst
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:97
ClassID_traits< T >::s_version
static const int s_version
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:93
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< T >::typeInfo
static const std::type_info & typeInfo()
the type id of T
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:86
ClassID_traits< T >::has_version_tag
std::false_type has_version_tag
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:90
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
ClassID_traits::has_classID_tag
std::false_type has_classID_tag
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:41
ClassID_traits::s_isDataObject
static const bool s_isDataObject
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
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
ClassID_traits::ID
static constexpr CLID ID()
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
ClassID_traits::typeInfo
static const std::type_info & typeInfo()
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:55
Generated on
for ATLAS Offline Software by
1.17.0