ATLAS Offline Software
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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: More...
 
virtual ~AthTPCnvSvc () override
 Destructor: More...
 
virtual ITPCnvBaseload_tpcnv (const std::string &cls) override
 load the T/P converter class named cls return NULL on failure. More...
 
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 More...
 
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 More...
 
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 More...
 
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. More...
 
virtual std::unique_ptr< ITPCnvBaset2p_cnv_unique (const CLID transClid) const override
 Return the T/P converter for a transient class. More...
 

Private Types

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

Private Member Functions

 AthTPCnvSvc ()
 Default constructor: More...
 

Private Attributes

ServiceHandle< IClassIDSvc > m_clidSvc
 handle to a IClassIDSvc to handle loading of types by CLID More...
 
TpCnvs_t m_cnvs
 a registry of ITPCnvBase* instances More...
 
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 37 of file AthTPCnvSvc.cxx.

38  :
39  base_class ( name, pSvcLocator ),
40  m_clidSvc("ClassIDSvc/ClassIDSvc", name)
41 {
42 }

◆ ~AthTPCnvSvc()

AthTPCnvSvc::~AthTPCnvSvc ( )
overridevirtual

Destructor:

Definition at line 46 of file AthTPCnvSvc.cxx.

47 {
48 }

◆ 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 56 of file AthTPCnvSvc.cxx.

57 {
58  ITPCnvBase* cnv = ITPCnvBase::Factory::create (cls).release();
59  if (cnv == nullptr) {
60  ATH_MSG_INFO("could not load class [" << cls
61  << "] via Reflex::PluginService");
62  }
63  else {
64  std::scoped_lock lock (m_mutex);
65  m_cnvs.emplace_back (cnv);
66  }
67  return cnv;
68 }

◆ 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 132 of file AthTPCnvSvc.cxx.

134 {
135  ITPCnvBase* cnv = ITPCnvBase::Factory::create (prefix(type) + "_PERS_" + persClassName).release();
136  if (cnv == nullptr && type != Athena::TPCnvType::Athena)
137  return p2t_cnv (persClassName);
138  if (cnv == nullptr) {
139  ATH_MSG_WARNING("Could not load converter for persistent class ["
140  << persClassName << "]");
141  }
142  else {
143  std::scoped_lock lock (m_mutex);
144  m_cnvs.emplace_back (cnv);
145  }
146  return cnv;
147 }

◆ 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 96 of file AthTPCnvSvc.cxx.

98 {
99  std::string trans_type;
100  if (!m_clidSvc->getTypeNameOfID(transClid, trans_type).isSuccess()) {
101  ATH_MSG_INFO("could not get a type-name for clid [" << transClid << "]");
102  return nullptr;
103  }
104 
105  ITPCnvBase* cnv = ITPCnvBase::Factory::create (prefix(type) + "_TRANS_" + trans_type).release();
106  if (cnv == nullptr) {
107  // try a typeinfo-name before bailing out...
108  if (!m_clidSvc->getTypeInfoNameOfID(transClid, trans_type).isSuccess()) {
109  ATH_MSG_INFO("could not get a typeinfo-name for clid ["
110  << transClid << "]");
111  return nullptr;
112  }
113  cnv = ITPCnvBase::Factory::create (prefix(type) + "_TRANS_" + trans_type).release();
114  }
115  if (cnv == nullptr && type != Athena::TPCnvType::Athena)
116  return t2p_cnv (transClid);
117  if (cnv == nullptr) {
118  ATH_MSG_WARNING("could not load converter for transient CLID ["
119  << transClid << "] (" << trans_type << ")");
120  }
121  else {
122  std::scoped_lock lock (m_mutex);
123  m_cnvs.emplace_back (cnv);
124  }
125  return cnv;
126 }

◆ 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 74 of file AthTPCnvSvc.cxx.

77 {
78  ITPCnvBase* cnv = ITPCnvBase::Factory::create (prefix(type) + "_TRANS_" + transClassName).release();
79  if (cnv == nullptr && type != Athena::TPCnvType::Athena)
80  return t2p_cnv (transClassName);
81  if (cnv == nullptr) {
82  ATH_MSG_WARNING("Could not load converter for transient class ["
83  << transClassName << "]");
84  }
85  else {
86  std::scoped_lock lock (m_mutex);
87  m_cnvs.emplace_back (cnv);
88  }
89  return cnv;
90 }

◆ 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 165 of file AthTPCnvSvc.cxx.

166 {
167  std::string trans_type;
168  if (!m_clidSvc->getTypeNameOfID(transClid, trans_type).isSuccess()) {
169  return nullptr;
170  }
171 
172  std::unique_ptr<ITPCnvBase> cnv = ITPCnvBase::Factory::create (/*prefix(type) +*/ "_TRANS_" + trans_type);
173  if (cnv == nullptr) {
174  // try a typeinfo-name before bailing out...
175  if (!m_clidSvc->getTypeInfoNameOfID(transClid, trans_type).isSuccess()) {
176  return nullptr;
177  }
178  cnv = ITPCnvBase::Factory::create (/*prefix(type) +*/ "_TRANS_" + trans_type);
179  }
180  /*
181  ** FIXME: support other types.
182  if (cnv == nullptr && type != Athena::TPCnvType::Athena)
183  return t2p_cnv (transClid);
184  */
185  return cnv;
186 }

◆ 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 154 of file AthTPCnvSvc.cxx.

155 {
156  return ITPCnvBase::Factory::create ("_TRANS_" + transClassName);
157 }

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:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloClusterListBadChannel.cls
cls
Definition: CaloClusterListBadChannel.py:8
Athena::TPCnvType::Athena
@ Athena
Definition: TPCnvFactory.h:123
AthTPCnvSvc::m_mutex
std::mutex m_mutex
Definition: AthTPCnvSvc.h:114
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:74
AthTPCnvSvc::m_clidSvc
ServiceHandle< IClassIDSvc > m_clidSvc
handle to a IClassIDSvc to handle loading of types by CLID
Definition: AthTPCnvSvc.h:106
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ITPCnvBase
Definition: ITPCnvBase.h:24
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthTPCnvSvc::m_cnvs
TpCnvs_t m_cnvs
a registry of ITPCnvBase* instances
Definition: AthTPCnvSvc.h:111
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:132