27#include "GaudiKernel/System.h"
28#include "GaudiKernel/MsgStream.h"
29#include "GaudiKernel/ServiceHandle.h"
41Svc::Svc(
const std::string& name, ISvcLocator* svcLocator ) :
42 base_class( name, svcLocator ),
60 return PyAthena::callPyMethod(
m_self,
"sysInitialize" );
67 return PyAthena::callPyMethod(
m_self,
"sysReinitialize" );
74 return PyAthena::callPyMethod(
m_self,
"sysFinalize" );
80 return PyAthena::callPyMethod(
m_self,
"sysStart" );
86 return PyAthena::callPyMethod(
m_self,
"sysStop" );
93 (
"PyAthena::PyComponentMgr/PyComponentMgr", name() );
94 if ( !pyMgr.retrieve().isSuccess() ) {
96 (
"Could not retrieve service [" << pyMgr.typeAndName() <<
"] !!");
97 return StatusCode::FAILURE;
101 m_self = pyMgr->pyObject(
this );
103 if (
m_self == Py_None ) {
105 return StatusCode::FAILURE;
109 return SvcBase_t::sysInitialize();
116 static const std::string tname = System::typeinfoName(
typeid(*
this));
117 return tname.c_str();
125 if (0 == PyObject_HasAttrString (
m_self, (
char*)
"handle")) {
132 PyObject *o = TPython::CPPInstance_FromVoidPtr ((
void*)(&inc),
"Incident");
158 PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
163 pyobj = TPython::CPPInstance_FromVoidPtr ((
void*)
this,
"PyAthena::Svc");
165 (
"could not dyncast component [" << name() <<
"] to a python "
166 <<
"object of type [" << this->
typeName() <<
"] (probably a missing "
167 <<
"dictionary)" <<
endmsg
168 <<
"fallback to [PyAthena::Svc]...");
173 (
"Could not dyncast component [" << name() <<
"] to a pyobject of type ["
176 if ( -1 == PyObject_SetAttrString(o,
"_cppHandle", pyobj) ) {
179 (
"Could not attach C++ handle [" << name() <<
"] to its python "
181 if ( -1 == PyObject_SetAttrString(o,
"_cppHandle", Py_None) ) {
184 (
"could not attach a dummy C++ handle [" << name() <<
"] to its "
185 <<
"python cousin !");
#define ATH_MSG_WARNING(x)
std::pair< std::vector< unsigned int >, bool > res
virtual bool setPyAttr(PyObject *pyobj) override
attach the C++ component to its python cousin
PyObject * m_self
Pointer to self (from the python world)
virtual StatusCode finalize() override
virtual StatusCode start() override
virtual StatusCode reinitialize() override
virtual StatusCode initialize() override
Gaudi Service Implementation.
virtual StatusCode sysInitialize() override
virtual void handle(const Incident &incident) override
callback method for the IIncidentSvc
virtual StatusCode stop() override
virtual ~Svc()
Destructor:
Svc()=delete
Default constructor:
const char * typeName() const override
return the std::type_info name of the underlying py-component This is used by concrete implementation...
void throw_py_exception(bool display=true)
helper function to capture the boilerplate code for user friendly stack trace display