ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaServices
src
AthTPCnvSvc.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// AthTPCnvSvc.cxx
8
// Implementation file for class AthTPCnvSvc
9
// Author: S.Binet<binet@cern.ch>
11
12
#include "
AthTPCnvSvc.h
"
13
#include "GaudiKernel/Converter.h"
14
15
16
namespace
{
17
18
std::string
prefix
(
Athena::TPCnvType::Value
type
)
19
{
20
switch
(
type
)
21
{
22
case
Athena::TPCnvType::Trigger
:
23
return
"_TRIG"
;
24
default
:
25
break
;
26
}
27
return
""
;
28
}
29
30
}
// anonymous namespace
31
32
33
// Constructors
35
AthTPCnvSvc::AthTPCnvSvc
(
const
std::string& name,
36
ISvcLocator* pSvcLocator ) :
37
base_class ( name, pSvcLocator ),
38
m_clidSvc
(
"ClassIDSvc/ClassIDSvc"
, name)
39
{
40
}
41
42
// Destructor
44
AthTPCnvSvc::~AthTPCnvSvc
()
45
{
46
}
47
48
53
ITPCnvBase
*
54
AthTPCnvSvc::load_tpcnv
(
const
std::string& cls)
55
{
56
ITPCnvBase
* cnv = ITPCnvBase::Factory::create (cls).release();
57
if
(cnv ==
nullptr
) {
58
ATH_MSG_INFO
(
"could not load class [{}] via Reflex::PluginService"
, cls);
59
}
60
else
{
61
std::scoped_lock
lock
(
m_mutex
);
62
m_cnvs
.emplace_back (cnv);
63
}
64
return
cnv;
65
}
66
70
ITPCnvBase
*
71
AthTPCnvSvc::t2p_cnv
(
const
std::string& transClassName,
72
Athena::TPCnvType::Value
type
/*= Athena::TPCnvType::Athena*/
)
73
74
{
75
ITPCnvBase
* cnv = ITPCnvBase::Factory::create (prefix(
type
) +
"_TRANS_"
+ transClassName).release();
76
if
(cnv ==
nullptr
&&
type
!=
Athena::TPCnvType::Athena
)
77
return
t2p_cnv
(transClassName);
78
if
(cnv ==
nullptr
) {
79
ATH_MSG_WARNING
(
"Could not load converter for transient class [{}]"
,
80
transClassName);
81
}
82
else
{
83
std::scoped_lock
lock
(
m_mutex
);
84
m_cnvs
.emplace_back (cnv);
85
}
86
return
cnv;
87
}
88
92
ITPCnvBase
*
93
AthTPCnvSvc::t2p_cnv
(
const
CLID
& transClid,
94
Athena::TPCnvType::Value
type
/*= Athena::TPCnvType::Athena*/
)
95
{
96
std::string trans_type;
97
if
(!
m_clidSvc
->getTypeNameOfID(transClid, trans_type).isSuccess()) {
98
ATH_MSG_INFO
(
"could not get a type-name for clid [{}]"
, transClid);
99
return
nullptr
;
100
}
101
102
ITPCnvBase
* cnv = ITPCnvBase::Factory::create (prefix(
type
) +
"_TRANS_"
+ trans_type).release();
103
if
(cnv ==
nullptr
) {
104
// try a typeinfo-name before bailing out...
105
if
(!
m_clidSvc
->getTypeInfoNameOfID(transClid, trans_type).isSuccess()) {
106
ATH_MSG_INFO
(
"could not get a typeinfo-name for clid [{}]"
, transClid);
107
return
nullptr
;
108
}
109
cnv = ITPCnvBase::Factory::create (prefix(
type
) +
"_TRANS_"
+ trans_type).release();
110
}
111
if
(cnv ==
nullptr
&&
type
!=
Athena::TPCnvType::Athena
)
112
return
t2p_cnv
(transClid);
113
if
(cnv ==
nullptr
) {
114
ATH_MSG_WARNING
(
"could not load converter for transient CLID [{}] ({})"
,
115
transClid, trans_type);
116
}
117
else
{
118
std::scoped_lock
lock
(
m_mutex
);
119
m_cnvs
.emplace_back (cnv);
120
}
121
return
cnv;
122
}
123
127
ITPCnvBase
*
128
AthTPCnvSvc::p2t_cnv
(
const
std::string& persClassName,
129
Athena::TPCnvType::Value
type
/*= Athena::TPCnvType::Athena*/
)
130
{
131
ITPCnvBase
* cnv = ITPCnvBase::Factory::create (prefix(
type
) +
"_PERS_"
+ persClassName).release();
132
if
(cnv ==
nullptr
&&
type
!=
Athena::TPCnvType::Athena
)
133
return
p2t_cnv
(persClassName);
134
if
(cnv ==
nullptr
) {
135
ATH_MSG_WARNING
(
"Could not load converter for persistent class [{}]"
,
136
persClassName);
137
}
138
else
{
139
std::scoped_lock
lock
(
m_mutex
);
140
m_cnvs
.emplace_back (cnv);
141
}
142
return
cnv;
143
}
144
145
149
std::unique_ptr<ITPCnvBase>
150
AthTPCnvSvc::t2p_cnv_unique
(
const
std::string& transClassName)
const
151
{
152
return
ITPCnvBase::Factory::create (
"_TRANS_"
+ transClassName);
153
}
154
155
160
std::unique_ptr<ITPCnvBase>
161
AthTPCnvSvc::t2p_cnv_unique
(
const
CLID
transClid)
const
162
{
163
std::string trans_type;
164
if
(!
m_clidSvc
->getTypeNameOfID(transClid, trans_type).isSuccess()) {
165
return
nullptr
;
166
}
167
168
std::unique_ptr<ITPCnvBase> cnv = ITPCnvBase::Factory::create (
/*prefix(type) +*/
"_TRANS_"
+ trans_type);
169
if
(cnv ==
nullptr
) {
170
// try a typeinfo-name before bailing out...
171
if
(!
m_clidSvc
->getTypeInfoNameOfID(transClid, trans_type).isSuccess()) {
172
return
nullptr
;
173
}
174
cnv = ITPCnvBase::Factory::create (
/*prefix(type) +*/
"_TRANS_"
+ trans_type);
175
}
176
/*
177
** FIXME: support other types.
178
if (cnv == nullptr && type != Athena::TPCnvType::Athena)
179
return t2p_cnv (transClid);
180
*/
181
return
cnv;
182
}
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
AthTPCnvSvc.h
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
AthTPCnvSvc::AthTPCnvSvc
AthTPCnvSvc()
Default constructor:
AthTPCnvSvc::~AthTPCnvSvc
virtual ~AthTPCnvSvc() override
Destructor:
Definition
AthTPCnvSvc.cxx:44
AthTPCnvSvc::load_tpcnv
virtual ITPCnvBase * load_tpcnv(const std::string &cls) override
load the T/P converter class named cls return NULL on failure.
Definition
AthTPCnvSvc.cxx:54
AthTPCnvSvc::m_clidSvc
ServiceHandle< IClassIDSvc > m_clidSvc
handle to a IClassIDSvc to handle loading of types by CLID
Definition
AthTPCnvSvc.h:106
AthTPCnvSvc::p2t_cnv
virtual ITPCnvBase * p2t_cnv(const std::string &persClassName, Athena::TPCnvType::Value type=Athena::TPCnvType::Athena) override
return the T/P converter for a persistent class (NULL if failure) ITPCnvSvc owns the ITPCnvBase point...
Definition
AthTPCnvSvc.cxx:128
AthTPCnvSvc::t2p_cnv
virtual ITPCnvBase * t2p_cnv(const std::string &transClassName, Athena::TPCnvType::Value type=Athena::TPCnvType::Athena) override
return the T/P converter for a transient class (NULL if failure) ITPCnvSvc owns the ITPCnvBase pointe...
Definition
AthTPCnvSvc.cxx:71
AthTPCnvSvc::m_mutex
std::mutex m_mutex
Definition
AthTPCnvSvc.h:114
AthTPCnvSvc::m_cnvs
TpCnvs_t m_cnvs
a registry of ITPCnvBase* instances
Definition
AthTPCnvSvc.h:111
AthTPCnvSvc::t2p_cnv_unique
virtual std::unique_ptr< ITPCnvBase > t2p_cnv_unique(const std::string &transClassName) const override
return the T/P converter for a transient class (NULL if failure) Ownership is returned to the caller.
Definition
AthTPCnvSvc.cxx:150
ITPCnvBase
Definition
ITPCnvBase.h:24
checkCorrelInHIST.prefix
dict prefix
Definition
checkCorrelInHIST.py:391
Athena::TPCnvType::Value
Value
Definition
TPCnvFactory.h:108
Athena::TPCnvType::Trigger
@ Trigger
Definition
TPCnvFactory.h:111
Athena::TPCnvType::Athena
@ Athena
Definition
TPCnvFactory.h:109
type
Generated on
for ATLAS Offline Software by
1.17.0