ATLAS Offline Software
Loading...
Searching...
No Matches
Control/AthenaKernel/AthenaKernel/CLASS_DEF.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_CLASS_DEF_H
6#define ATHENAKERNEL_CLASS_DEF_H
12
17#include "GaudiKernel/DataObject.h"
18
19#ifdef __CLING__
20# define CLIDREGISTRY_ADDENTRY(CID, NAME) \
21 namespace detail { \
22 [[maybe_unused]] \
23 const bool clidEntry_ ## CID = \
24 CLIDRegistry::addEntry(CID, typeid(NAME), \
25 ClassID_traits< NAME >::typeNameString(), \
26 ClassName< NAME >::name()); \
27 }
28# define CLIDREGISTRY_ADDENTRY2(CID, ARG1, ARG2) \
29 namespace detail { \
30 [[maybe_unused]] \
31 const bool clidEntry_ ## CID = \
32 CLIDRegistry::addEntry \
33 (CID, typeid(ARG1,ARG2), \
34 ClassID_traits< ARG1,ARG2 >::typeNameString(), \
35 ClassName< ARG1,ARG2 >::name()); \
36 }
37#else
38# define CLIDREGISTRY_ADDENTRY(CID, NAME) \
39 namespace detail { \
40 [[maybe_unused]] \
41 const bool clidEntry_ ## CID = \
42 CLIDRegistry::addEntry<CID>(typeid(NAME), \
43 ClassID_traits< NAME >::typeNameString(), \
44 ClassName< NAME >::name()); \
45 }
46# define CLIDREGISTRY_ADDENTRY2(CID, ARG1, ARG2) \
47 namespace detail { \
48 [[maybe_unused]] \
49 const bool clidEntry_ ## CID = \
50 CLIDRegistry::addEntry<CID> \
51 (typeid(ARG1,ARG2), \
52 ClassID_traits< ARG1,ARG2 >::typeNameString(), \
53 ClassName< ARG1,ARG2 >::name()); \
54 }
55#endif
56
67#define CLASS_DEF(NAME, CID , VERSION) \
68 template <> \
69 struct ClassID_traits< NAME > { \
70 typedef std::is_base_of<DataObject, NAME> isDObj_t; \
71 static const bool s_isDataObject = isDObj_t::value; \
72 typedef std::true_type has_classID_tag; \
73 static const CLID& ID ATLAS_CHECK_THREAD_SAFETY () { static const CLID c(CID); return c; } \
74 static const char* typeNameString ATLAS_CHECK_THREAD_SAFETY () { \
75 return #NAME; \
76 } \
77 static const std::string& typeName ATLAS_CHECK_THREAD_SAFETY () { \
78 static const std::string name = typeNameString(); \
79 return name; \
80 } \
81 static const std::type_info& typeInfo() { \
82 return typeid (NAME); \
83 } \
84 typedef std::true_type has_version_tag; \
85 static const int s_version = VERSION; \
86 static const bool s_isConst = false; \
87 }; \
88 CLIDREGISTRY_ADDENTRY(CID, NAME)
89
90
102#define CLASS_DEF2(ARG1, ARG2, CID , VERSION) \
103 template <> \
104 struct ClassID_traits< ARG1,ARG2 > { \
105 typedef std::is_base_of<DataObject, ARG1, ARG2 > isDObj_t; \
106 static const bool s_isDataObject = isDObj_t::value; \
107 typedef std::true_type has_classID_tag; \
108 static const CLID& ID ATLAS_CHECK_THREAD_SAFETY () { \
109 static const CLID c(CID); return c; \
110 } \
111 static const char* typeNameString ATLAS_CHECK_THREAD_SAFETY () { \
112 return #ARG1 "," #ARG2; \
113 } \
114 static const std::string& typeName ATLAS_CHECK_THREAD_SAFETY () { \
115 static const std::string name = typeNameString(); \
116 return name; \
117 } \
118 static const std::type_info& typeInfo() { \
119 return typeid (ARG1,ARG2); \
120 } \
121 typedef std::true_type has_version_tag; \
122 static const int s_version = VERSION; \
123 static const bool s_isConst = false; \
124 }; \
125 CLIDREGISTRY_ADDENTRY2(CID, ARG1, ARG2)
126
127#endif // not ATHENAKERNEL_CLASS_DEF_H
An interface for getting the name of a class as a string.
a static registry of CLID->typeName entries.
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Define macros for attributes used to control the static checker.