7#include "GaudiKernel/ServiceHandle.h"
20 TClass* cls =
nullptr;
21 PyObject* attr = PyObject_GetAttrString ((
PyObject*)Py_TYPE(obj),
"__cpp_name__");
23 const char* s = PyUnicode_AsUTF8AndSize (attr,
nullptr);
26 if (strncmp (s,
"ROOT.", 5) == 0)
28 if (strncmp (s,
"cppyy.gbl.", 10) == 0)
30 cls = TClass::GetClass (s);
71 void* o =
m_bib ?
m_bib->cast(address, clid) : 0;
72 if ( o ) {
return o; }
78 PyErr_Format( PyExc_TypeError,
"actual type of CLID %lu unknown",
79 (
long unsigned int)clid );
86 TClass* cls = TClass::GetClass (pytpstr.c_str());
88 PyErr_Format( PyExc_TypeError,
"Can't find TClass for `%s'",
92 TClass* act_class = cls->GetActualClass (address);
93 PyObject* value = TPython::CPPInstance_FromVoidPtr (address, act_class->GetName());
95 if ( value && TPython::CPPInstance_Check(value) ) {
99 throw CPyCppyy::PyException();
114 TClass* tcls = objectIsA (
m_pyObj);
115 if ( tcls && (
tinfo == *(tcls->GetTypeInfo())) ) {
123 if ( o ) {
return o; }
128 TClass* clsnew = TClass::GetClass (
tinfo);
131 ( PyExc_RuntimeError,
132 "SG::PyDataBucket::cast() can't find TClass" );
135 TClass* act_class = clsnew->GetActualClass (address);
136 PyObject* value = TPython::CPPInstance_FromVoidPtr (address, act_class->GetName());
139 if ( value && TPython::CPPInstance_Check(value) ) {
151 if (!PyObject_HasAttrString (
m_pyObj,
"lock"))
155 if (PyCallable_Check (
lock)) {
172 if ( !svc.retrieve().isSuccess()) {
173 throw std::runtime_error
174 (
"SG::PyProxyMgr: Could not retrieve ClassIDSvc");
181 if ( !svc.retrieve().isSuccess()) {
182 throw std::runtime_error
183 (
"SG::PyProxyMgr: Could not retrieve AthDictLoaderSvc");
193 if (_PyThreadState_UncheckedGet())
199 for ( PyProxyMap_t::iterator
204 delete i->second; i->second = 0;
#define CPPInstance_ASVOIDPTR(o)
uint32_t CLID
The Class ID type.
Define macros for attributes used to control the static checker.
#define ATLAS_NO_CHECK_FILE_THREAD_SAFETY
The non-template portion of the BaseInfo implementation.
Interface for registering a transient object in t2p map.
PyDataBucket(PyObject *obj, CLID clid)
Constructor.
PyObject * m_pyObj
Pointer to the held pyroot object (or 'regular' PyObject)
virtual void * cast(CLID clid, IRegisterTransient *itr=0, bool isConst=true) override
Return the contents of the DataBucket, converted to type given by clid.
virtual void lock() override
If the held object derives from ILockable, call lock() on it.
CLID m_clid
The class ID of the wrapped object.
virtual const std::type_info & tinfo() const override
Return the type_info for the stored object.
const SG::BaseInfoBase * m_bib
pointer to the SG::BaseInfoBase structure holding the converter functions for objects held by StoreGa...
std::string find(const std::string &s)
return a remapped string
std::pair< std::string, bool > PyGetString(PyObject *s)
Convert python string -> C++ string for py2 and py3.
PyObject * importDictAliases()
import the dictionary of aliases from a well known location
static PyProxyMgr & instance()
PyObject * m_aliases
a dictionary of "typedef'ed typename" -> "typename"
IDictLoaderSvc * m_dictSvc
PyObject * pytp(PyObject *clid)
returns a borrowed reference
PyObject * m_clids
a dictionary of 'typename' -> CLID (and reverse CLID->'typename')