ATLAS Offline Software
Control/AthenaKernel/AthenaKernel/ClassID_traits.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENAKERNEL_CLASSID_TRAITS_H
6 #define ATHENAKERNEL_CLASSID_TRAITS_H
7 
13 #include <string>
14 #include <typeinfo>
15 
16 
17 #include "GaudiKernel/ClassID.h"
18 #include "GaudiKernel/DataObject.h"
19 #include "GaudiKernel/System.h"
20 
22 #include "AthenaKernel/ClassName.h"
23 
24 #include <type_traits>
25 
26 
27 
30 
32 #define MY_STATIC_ASSERT( B ) \
33  static_assert (B, "You should use the CLASS_DEF macro to define CLID and VERSION");
34 
39 template <typename T>
41  //default only works for DataObjects
42  typedef std::is_base_of<DataObject, T> isDObj_t;
44  static const bool s_isDataObject = isDObj_t::value;
45 
46  //default traits for class ID assignment
47  typedef std::integral_constant<bool, s_isDataObject> is_DataObject_tag;
48 
50  static const CLID& ID() {
52  return T::classID();
53  }
54 
56  static const std::string& typeName() {
58  static const std::string tname = System::typeinfoName(typeid(T));
59  return tname;
60  }
61 
63  static const std::type_info& typeInfo() {
65  return typeid(T);
66  }
67 
68  typedef std::false_type has_version_tag;
69  typedef std::false_type has_classID_tag;
70  static const int s_version = 0;
71 
72  // Is this is true, these types will automatically be made
73  // const when added to StoreGate.
74  static const bool s_isConst = false;
75 };
76 
77 #undef MY_STATIC_ASSERT
78 
79 #endif // not ATHENAKERNEL_CLASSID_TRAITS_H
ClassID_traits::s_isConst
static const bool s_isConst
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:74
ERROR_you_should_use_the_CLASS_DEF_macro_to_define_CLID_and_VERSION
Helper used in order to get the clear error message for the developer.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:28
athena.value
value
Definition: athena.py:124
ClassID_traits::s_version
static const int s_version
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:70
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
ClassID_traits::typeName
static const std::string & typeName()
the demangled type name of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:56
ClassName.h
An interface for getting the name of a class as a string.
ClassID_traits::is_DataObject_tag
std::integral_constant< bool, s_isDataObject > is_DataObject_tag
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:47
ClassID_traits::has_classID_tag
std::false_type has_classID_tag
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:69
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
ClassID_traits::has_version_tag
std::false_type has_version_tag
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:68
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
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:32
ClassID_traits::isDObj_t
std::is_base_of< DataObject, T > isDObj_t
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:42
ClassID_traits::s_isDataObject
static const bool s_isDataObject
flags whether T inherits from DataObject
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
CLIDRegistry.h
a static registry of CLID->typeName entries. NOT for general use. Use ClassIDSvc instead.
ClassID_traits::typeInfo
static const std::type_info & typeInfo()
the type id of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:63
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35