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-2025 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 ["
<< cls
59
<<
"] via Reflex::PluginService"
);
60
}
61
else
{
62
std::scoped_lock
lock
(
m_mutex
);
63
m_cnvs
.emplace_back (cnv);
64
}
65
return
cnv;
66
}
67
71
ITPCnvBase
*
72
AthTPCnvSvc::t2p_cnv
(
const
std::string& transClassName,
73
Athena::TPCnvType::Value
type
/*= Athena::TPCnvType::Athena*/
)
74
75
{
76
ITPCnvBase
* cnv = ITPCnvBase::Factory::create (prefix(
type
) +
"_TRANS_"
+ transClassName).release();
77
if
(cnv ==
nullptr
&&
type
!=
Athena::TPCnvType::Athena
)
78
return
t2p_cnv
(transClassName);
79
if
(cnv ==
nullptr
) {
80
ATH_MSG_WARNING
(
"Could not load converter for transient class ["
81
<< transClassName <<
"]"
);
82
}
83
else
{
84
std::scoped_lock
lock
(
m_mutex
);
85
m_cnvs
.emplace_back (cnv);
86
}
87
return
cnv;
88
}
89
93
ITPCnvBase
*
94
AthTPCnvSvc::t2p_cnv
(
const
CLID
& transClid,
95
Athena::TPCnvType::Value
type
/*= Athena::TPCnvType::Athena*/
)
96
{
97
std::string trans_type;
98
if
(!
m_clidSvc
->getTypeNameOfID(transClid, trans_type).isSuccess()) {
99
ATH_MSG_INFO
(
"could not get a type-name for clid ["
<< transClid <<
"]"
);
100
return
nullptr
;
101
}
102
103
ITPCnvBase
* cnv = ITPCnvBase::Factory::create (prefix(
type
) +
"_TRANS_"
+ trans_type).release();
104
if
(cnv ==
nullptr
) {
105
// try a typeinfo-name before bailing out...
106
if
(!
m_clidSvc
->getTypeInfoNameOfID(transClid, trans_type).isSuccess()) {
107
ATH_MSG_INFO
(
"could not get a typeinfo-name for clid ["
108
<< transClid <<
"]"
);
109
return
nullptr
;
110
}
111
cnv = ITPCnvBase::Factory::create (prefix(
type
) +
"_TRANS_"
+ trans_type).release();
112
}
113
if
(cnv ==
nullptr
&&
type
!=
Athena::TPCnvType::Athena
)
114
return
t2p_cnv
(transClid);
115
if
(cnv ==
nullptr
) {
116
ATH_MSG_WARNING
(
"could not load converter for transient CLID ["
117
<< transClid <<
"] ("
<< trans_type <<
")"
);
118
}
119
else
{
120
std::scoped_lock
lock
(
m_mutex
);
121
m_cnvs
.emplace_back (cnv);
122
}
123
return
cnv;
124
}
125
129
ITPCnvBase
*
130
AthTPCnvSvc::p2t_cnv
(
const
std::string& persClassName,
131
Athena::TPCnvType::Value
type
/*= Athena::TPCnvType::Athena*/
)
132
{
133
ITPCnvBase
* cnv = ITPCnvBase::Factory::create (prefix(
type
) +
"_PERS_"
+ persClassName).release();
134
if
(cnv ==
nullptr
&&
type
!=
Athena::TPCnvType::Athena
)
135
return
p2t_cnv
(persClassName);
136
if
(cnv ==
nullptr
) {
137
ATH_MSG_WARNING
(
"Could not load converter for persistent class ["
138
<< persClassName <<
"]"
);
139
}
140
else
{
141
std::scoped_lock
lock
(
m_mutex
);
142
m_cnvs
.emplace_back (cnv);
143
}
144
return
cnv;
145
}
146
147
151
std::unique_ptr<ITPCnvBase>
152
AthTPCnvSvc::t2p_cnv_unique
(
const
std::string& transClassName)
const
153
{
154
return
ITPCnvBase::Factory::create (
"_TRANS_"
+ transClassName);
155
}
156
157
162
std::unique_ptr<ITPCnvBase>
163
AthTPCnvSvc::t2p_cnv_unique
(
const
CLID
transClid)
const
164
{
165
std::string trans_type;
166
if
(!
m_clidSvc
->getTypeNameOfID(transClid, trans_type).isSuccess()) {
167
return
nullptr
;
168
}
169
170
std::unique_ptr<ITPCnvBase> cnv = ITPCnvBase::Factory::create (
/*prefix(type) +*/
"_TRANS_"
+ trans_type);
171
if
(cnv ==
nullptr
) {
172
// try a typeinfo-name before bailing out...
173
if
(!
m_clidSvc
->getTypeInfoNameOfID(transClid, trans_type).isSuccess()) {
174
return
nullptr
;
175
}
176
cnv = ITPCnvBase::Factory::create (
/*prefix(type) +*/
"_TRANS_"
+ trans_type);
177
}
178
/*
179
** FIXME: support other types.
180
if (cnv == nullptr && type != Athena::TPCnvType::Athena)
181
return t2p_cnv (transClid);
182
*/
183
return
cnv;
184
}
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
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:130
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:72
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:152
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