ATLAS Offline Software
Loading...
Searching...
No Matches
AthTPCnvSvc Class Reference

#include <AthTPCnvSvc.h>

Inheritance diagram for AthTPCnvSvc:
Collaboration diagram for AthTPCnvSvc:

Public Member Functions

 AthTPCnvSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
virtual ~AthTPCnvSvc () override
 Destructor:
virtual ITPCnvBaseload_tpcnv (const std::string &cls) override
 load the T/P converter class named cls return NULL on failure.
virtual ITPCnvBaset2p_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 pointer
virtual ITPCnvBaset2p_cnv (const CLID &transClid, Athena::TPCnvType::Value type=Athena::TPCnvType::Athena) override
 return the T/P converter for a transient class (NULL if failure) ITPCnvSvc owns the ITPCnvBase pointer
virtual ITPCnvBasep2t_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 pointer
virtual std::unique_ptr< ITPCnvBaset2p_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.
virtual std::unique_ptr< ITPCnvBaset2p_cnv_unique (const CLID transClid) const override
 Return the T/P converter for a transient class.

Private Types

typedef std::vector< std::unique_ptr< ITPCnvBase > > TpCnvs_t

Private Member Functions

 AthTPCnvSvc ()
 Default constructor:

Private Attributes

ServiceHandle< IClassIDSvc > m_clidSvc
 handle to a IClassIDSvc to handle loading of types by CLID
TpCnvs_t m_cnvs
 a registry of ITPCnvBase* instances
std::mutex m_mutex

Detailed Description

Definition at line 30 of file AthTPCnvSvc.h.

Member Typedef Documentation

◆ TpCnvs_t

typedef std::vector<std::unique_ptr<ITPCnvBase> > AthTPCnvSvc::TpCnvs_t
private

Definition at line 108 of file AthTPCnvSvc.h.

Constructor & Destructor Documentation

◆ AthTPCnvSvc() [1/2]

AthTPCnvSvc::AthTPCnvSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters:

Definition at line 35 of file AthTPCnvSvc.cxx.

36 :
37 base_class ( name, pSvcLocator ),
38 m_clidSvc("ClassIDSvc/ClassIDSvc", name)
39{
40}
ServiceHandle< IClassIDSvc > m_clidSvc
handle to a IClassIDSvc to handle loading of types by CLID

◆ ~AthTPCnvSvc()

AthTPCnvSvc::~AthTPCnvSvc ( )
overridevirtual

Destructor:

Definition at line 44 of file AthTPCnvSvc.cxx.

45{
46}

◆ AthTPCnvSvc() [2/2]

AthTPCnvSvc::AthTPCnvSvc ( )
private

Default constructor:

Member Function Documentation

◆ load_tpcnv()

ITPCnvBase * AthTPCnvSvc::load_tpcnv ( const std::string & cls)
overridevirtual

load the T/P converter class named cls return NULL on failure.

the converter is OWNED by the T/P converter service

Definition at line 54 of file AthTPCnvSvc.cxx.

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}
#define ATH_MSG_INFO(x)
std::mutex m_mutex
TpCnvs_t m_cnvs
a registry of ITPCnvBase* instances

◆ p2t_cnv()

ITPCnvBase * AthTPCnvSvc::p2t_cnv ( const std::string & persClassName,
Athena::TPCnvType::Value type = Athena::TPCnvType::Athena )
overridevirtual

return the T/P converter for a persistent class (NULL if failure) ITPCnvSvc owns the ITPCnvBase pointer

Definition at line 130 of file AthTPCnvSvc.cxx.

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}
#define ATH_MSG_WARNING(x)
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...

◆ t2p_cnv() [1/2]

ITPCnvBase * AthTPCnvSvc::t2p_cnv ( const CLID & transClid,
Athena::TPCnvType::Value type = Athena::TPCnvType::Athena )
overridevirtual

return the T/P converter for a transient class (NULL if failure) ITPCnvSvc owns the ITPCnvBase pointer

Definition at line 94 of file AthTPCnvSvc.cxx.

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}
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...

◆ t2p_cnv() [2/2]

ITPCnvBase * AthTPCnvSvc::t2p_cnv ( const std::string & transClassName,
Athena::TPCnvType::Value type = Athena::TPCnvType::Athena )
overridevirtual

return the T/P converter for a transient class (NULL if failure) ITPCnvSvc owns the ITPCnvBase pointer

Definition at line 72 of file AthTPCnvSvc.cxx.

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}

◆ t2p_cnv_unique() [1/2]

std::unique_ptr< ITPCnvBase > AthTPCnvSvc::t2p_cnv_unique ( const CLID transClid) const
overridevirtual

Return the T/P converter for a transient class.

Returns null on failure (with no warning printed). Ownership is returned to the caller.

Definition at line 163 of file AthTPCnvSvc.cxx.

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}

◆ t2p_cnv_unique() [2/2]

std::unique_ptr< ITPCnvBase > AthTPCnvSvc::t2p_cnv_unique ( const std::string & transClassName) const
overridevirtual

return the T/P converter for a transient class (NULL if failure) Ownership is returned to the caller.

Return the T/P converter for a transient class.

Ownership is returned to the caller.

Definition at line 152 of file AthTPCnvSvc.cxx.

153{
154 return ITPCnvBase::Factory::create ("_TRANS_" + transClassName);
155}

Member Data Documentation

◆ m_clidSvc

ServiceHandle<IClassIDSvc> AthTPCnvSvc::m_clidSvc
private

handle to a IClassIDSvc to handle loading of types by CLID

Definition at line 106 of file AthTPCnvSvc.h.

◆ m_cnvs

TpCnvs_t AthTPCnvSvc::m_cnvs
private

a registry of ITPCnvBase* instances

Definition at line 111 of file AthTPCnvSvc.h.

◆ m_mutex

std::mutex AthTPCnvSvc::m_mutex
mutableprivate

Definition at line 114 of file AthTPCnvSvc.h.


The documentation for this class was generated from the following files: