|
ATLAS Offline Software
|
Go to the documentation of this file.
20 #include "PyComponentMgr.h"
26 #include "Gaudi/Property.h"
30 #include "CPyCppyy/PyException.h"
33 #include "TClassGenerator.h"
56 TCollection* gens = gROOT->GetListOfClassGenerators();
59 while( (
gen = (TClassGenerator*)
next()) ) {
60 if (System::typeinfoName (
typeid (*
gen)) ==
"TPyClassGenerator") {
73 ISvcLocator* pSvcLocator ) :
74 base_class (
name, pSvcLocator ),
107 Py_XDECREF(
i->second );
120 const std::string pyModuleName =
"AthenaPython.Configurables";
124 ATH_MSG_DEBUG(
"Importing module [" << pyModuleName <<
"]...");
125 PyObject*
module = PyImport_ImportModule(
const_cast<char*
>(pyModuleName.c_str()) );
127 ATH_MSG_ERROR(
"Could not import [" << pyModuleName <<
"] !!");
132 const std::string pyClassName =
"PyComponents";
134 pyClass = PyDict_GetItemString( PyModule_GetDict(
module ),
135 const_cast<char*
>( pyClassName.c_str() ) );
138 Py_XINCREF( pyClass );
142 <<
"] from module [" << pyModuleName <<
"] !!");
145 return StatusCode::FAILURE;
148 m_dict = PyObject_GetAttrString( pyClass,
149 const_cast<char*
>(
"instances" ) );
151 ATH_MSG_ERROR(
"Could not retrieve attribute [instances] from class ["
152 << pyClassName <<
"] !!");
155 return StatusCode::FAILURE;
164 fancy_attr = PyDict_GetItemString(PyModule_GetDict(
module),
165 (
char*)
"_install_fancy_attrs");
167 Py_XINCREF(fancy_attr);
171 (
"could not retrieve function [_install_fancy_attrs] from module ["
172 << pyModuleName <<
"]");
174 PyObject* ret = PyObject_CallFunction(fancy_attr, NULL);
177 Py_XDECREF(fancy_attr);
182 const std::string pyRootFixes =
"RootUtils.PyROOTFixes";
183 ATH_MSG_DEBUG(
"Importing module [" << pyRootFixes <<
"]...");
185 rootFixes = PyImport_ImportModule(
const_cast<char*
>(pyRootFixes.c_str()));
186 if ( !rootFixes || !PyModule_Check( rootFixes ) ) {
191 <<
"Some problem may appear with some C++->python binded classes (YMMV)");
193 Py_XDECREF(rootFixes);
194 return StatusCode::SUCCESS;
201 return StatusCode::SUCCESS;
208 const std::string&
name = cppComp->name();
214 Py_INCREF (
comp->second);
222 Py_INCREF( Py_None );
227 const_cast<char*
>(
name.c_str()) );
234 <<
"] or invalid item !!");
252 << cppComp->
typeName() <<
"/" << cppComp->name()
253 <<
"] with its python cousin !");
JetConstituentVector::iterator iterator
CPyCppyy::PyException PyException
virtual PyObject * pyObject(IPyComponent *component) override
Retrieve a python object from the python world.
PyComponents_t m_components
A fast look-up hash-map for python components { 'name' : PyObject* } PyObject* is NULL if not yet ins...
virtual StatusCode finalize() override
#define ATH_MSG_VERBOSE(x)
PyObject * m_dict
The dictionary of python components' description It should be of the form: { 'name' : { 'package' : "...
virtual const char * typeName() const =0
return the std::type_info name of the underlying py-component This is used by concrete implementation...
virtual StatusCode initialize() override
Gaudi Service Implementation.
::StatusCode StatusCode
StatusCode definition for legacy code.
virtual bool setPyAttr(PyObject *pyobj)=0
attach the C++ component to its python cousin
#define ATH_MSG_WARNING(x)
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
virtual ~PyComponentMgr()
Destructor:
macros to associate a CLID to a type