27#include "GaudiKernel/System.h"
28#include "GaudiKernel/MsgStream.h"
29#include "GaudiKernel/ServiceHandle.h"
40Alg::Alg(
const std::string& name, ISvcLocator* svcLocator ) :
63 return PyAthena::callPyMethod(
m_self,
"sysInitialize" );
70 return PyAthena::callPyMethod(
m_self,
"sysReinitialize" );
76 return PyAthena::callPyMethod(
m_self,
"sysStart" );
82 return PyAthena::callPyMethod(
m_self,
"sysStop" );
89 return PyAthena::callPyMethod(
m_self,
"sysFinalize" );
96 PyObject* pycontext = PyCapsule_New (
const_cast<EventContext*
>(&ctx),
nullptr,
nullptr);
98 StatusCode
sc = PyAthena::callPyMethod(
m_self,
"sysExecute", pycontext );
99 Py_DECREF (pycontext);
107 (
"PyAthena::PyComponentMgr/PyComponentMgr", name() );
108 if ( !pyMgr.retrieve().isSuccess() ) {
109 ATH_MSG_ERROR(
"Could not retrieve service [" << pyMgr.typeAndName()
111 return StatusCode::FAILURE;
115 m_self = pyMgr->pyObject(
this );
117 if (
m_self == Py_None ) {
119 return StatusCode::FAILURE;
133 static const std::string tname = System::typeinfoName(
typeid(*
this));
134 return tname.c_str();
146 PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
151 pyobj = TPython::CPPInstance_FromVoidPtr ((
void*)
this,
"PyAthena::Alg");
153 (
"could not dyncast component [" << name() <<
"] to a python "
154 <<
"object of type [" << this->
typeName() <<
"] (probably a missing "
155 <<
"dictionary)" <<
endmsg
156 <<
"fallback to [PyAthena::Alg]...");
161 << name() <<
"] to a pyobject of type ["
164 if ( -1 == PyObject_SetAttrString(o,
"_cppHandle", pyobj) ) {
167 (
"Could not attach C++ handle [" << name() <<
"] to its python "
169 if ( -1 == PyObject_SetAttrString(o,
"_cppHandle", Py_None) ) {
172 (
"could not attach a dummy C++ handle [" << name() <<
"] to its "
#define ATH_MSG_WARNING(x)
virtual StatusCode sysInitialize() override
Override sysInitialize.
virtual StatusCode reinitialize() override
PyObject * m_self
Pointer to self (from the python world).
virtual StatusCode stop() override
virtual StatusCode sysInitialize() override
Override sysInitialize.
virtual bool setPyAttr(PyObject *pyobj) override
attach the C++ component to its python cousin
virtual const char * typeName() const override
return the std::type_info name of the underlying py-component This is used by concrete implementation...
virtual StatusCode start() override
Alg()
Default constructor:
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
virtual StatusCode finalize() override
virtual ~Alg()
Destructor:
virtual StatusCode initialize() override