28#include "GaudiKernel/System.h"
29#include "GaudiKernel/INamedInterface.h"
30#include "GaudiKernel/ServiceHandle.h"
42Aud::Aud(
const std::string& name, ISvcLocator* svcLocator ) :
43 Gaudi::Auditor( name, svcLocator ),
63 return PyAthena::callPyMethod(
m_self,
"sysInitialize" );
70 (
"PyAthena::PyComponentMgr/PyComponentMgr", name() );
71 if ( !pyMgr.retrieve().isSuccess() ) {
72 return StatusCode::FAILURE;
76 m_self = pyMgr->pyObject(
this );
79 return StatusCode::FAILURE;
83 return Gaudi::Auditor::sysInitialize();
89 return PyAthena::callPyMethod(
m_self,
"sysFinalize" );
99 static const std::string tname = System::typeinfoName(
typeid(*
this));
100 return tname.c_str();
111 std::string evtname = evt;
112 std::transform(evt.begin(), evt.end(), evtname.begin(),
::tolower);
113 PyAthena::pyAudit (
m_self,
"before", evtname.c_str(), name.c_str());
118 const EventContext&,
const StatusCode&
sc)
120 std::string evtname = evt;
121 std::transform(evt.begin(), evt.end(), evtname.begin(),
::tolower);
122 PyAthena::pyAudit (
m_self,
"after", evtname.c_str(), name.c_str(),
sc);
134 PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
139 pyobj = TPython::CPPInstance_FromVoidPtr ((
void*)
this,
"PyAthena::Aud");
140 MsgStream
msg( msgSvc(), name() );
142 <<
"could not dyncast component [" << name() <<
"] to a python "
143 <<
"object of type [" << this->
typeName() <<
"] (probably a missing "
144 <<
"dictionary)" <<
endmsg
145 <<
"fallback to [PyAthena::Aud]..."
150 MsgStream
msg( msgSvc(), name() );
151 msg << MSG::WARNING <<
"Could not dyncast component ["
152 << name() <<
"] to a pyobject of type ["
156 if ( -1 == PyObject_SetAttrString(o,
"_cppHandle", pyobj) ) {
158 MsgStream
msg( msgSvc(), name() );
160 <<
"Could not attach C++ handle [" << name() <<
"] to its python "
163 if ( -1 == PyObject_SetAttrString(o,
"_cppHandle", Py_None) ) {
166 <<
"could not attach a dummy C++ handle [" << name() <<
"] to its "
void tolower(std::string &s)
virtual void after(const std::string &evt, const std::string &name, const EventContext &ctx, const StatusCode &sc) override
virtual ~Aud()
Destructor:
virtual StatusCode sysInitialize() override
virtual StatusCode initialize() override
Gaudi Aud Implementation.
PyObject * m_self
Pointer to self (from the python world)
virtual const char * typeName() const override
return the std::type_info name of the underlying py-component This is used by concrete implementation...
virtual void before(const std::string &evt, const std::string &name, const EventContext &ctx) override
Auditor interface
virtual StatusCode finalize() override
Aud()
Default constructor:
virtual bool setPyAttr(PyObject *pyobj) override
attach the C++ component to its python cousin
=============================================================================