Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
PyAthena::Aud Class Reference

#include <PyAthenaAud.h>

Inheritance diagram for PyAthena::Aud:
Collaboration diagram for PyAthena::Aud:

Public Member Functions

 Aud (const std::string &name, ISvcLocator *svcLocator)
 Constructor with parameters: More...
 
virtual ~Aud ()
 Destructor: More...
 
virtual StatusCode initialize () override
 Gaudi Aud Implementation. More...
 
virtual StatusCode sysInitialize () override
 
virtual StatusCode finalize () override
 
virtual const char * typeName () const override
 return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part More...
 
virtual void py_before (IAuditor::StandardEventType, const std::string &)
 Audit the start of a standard "event". More...
 
virtual void py_before (IAuditor::CustomEventTypeRef, const std::string &)
 Audit the start of a custom "event". More...
 
virtual void py_after (IAuditor::StandardEventType, const std::string &, const StatusCode &)
 Audit the end of a standard "event". More...
 
virtual void py_after (IAuditor::CustomEventTypeRef, const std::string &, const StatusCode &)
 Audit the end of a custom "event". More...
 
virtual PyObjectself () override
 return associated python object. More...
 
 DeclareInterfaceID (IPyComponent, 1, 0)
 

Protected Member Functions

virtual bool setPyAttr (PyObject *pyobj) override
 attach the C++ component to its python cousin More...
 
virtual void before (StandardEventType, INamedInterface *) override
 Auditor interface More...
 
virtual void before (StandardEventType, const std::string &) override
 
virtual void before (CustomEventTypeRef, INamedInterface *) override
 
virtual void before (CustomEventTypeRef, const std::string &) override
 
virtual void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
virtual void after (StandardEventType, const std::string &, const StatusCode &) override
 
virtual void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
virtual void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 

Protected Attributes

PyObjectm_self
 Pointer to self (from the python world) More...
 

Private Member Functions

 Aud ()
 Default constructor: More...
 

Detailed Description

Definition at line 30 of file PyAthenaAud.h.

Constructor & Destructor Documentation

◆ Aud() [1/2]

PyAthena::Aud::Aud ( const std::string &  name,
ISvcLocator *  svcLocator 
)

Constructor with parameters:

Definition at line 41 of file PyAthenaAud.cxx.

41  :
42  ::Auditor( name, svcLocator ),
43  m_self ( nullptr )
44 {}

◆ ~Aud()

PyAthena::Aud::~Aud ( )
virtual

Destructor:

Definition at line 48 of file PyAthenaAud.cxx.

49 {
50  if ( m_self ) {
52  Py_DECREF( m_self );
53  m_self = nullptr;
54  }
55 }

◆ Aud() [2/2]

PyAthena::Aud::Aud ( )
private

Default constructor:

Member Function Documentation

◆ after() [1/4]

void PyAthena::Aud::after ( CustomEventTypeRef  evt,
const std::string &  comp,
const StatusCode &  sc 
)
overrideprotectedvirtual

Definition at line 149 of file PyAthenaAud.cxx.

151 {
152  py_after (evt, comp, sc);
153 }

◆ after() [2/4]

void PyAthena::Aud::after ( CustomEventTypeRef  evt,
INamedInterface *  comp,
const StatusCode &  sc 
)
overrideprotectedvirtual

Definition at line 143 of file PyAthenaAud.cxx.

144 {
145  py_after (evt, comp->name(), sc);
146 }

◆ after() [3/4]

void PyAthena::Aud::after ( StandardEventType  evt,
const std::string &  comp,
const StatusCode &  sc 
)
overrideprotectedvirtual

Definition at line 137 of file PyAthenaAud.cxx.

138 {
139  py_after (evt, comp, sc);
140 }

◆ after() [4/4]

void PyAthena::Aud::after ( StandardEventType  evt,
INamedInterface *  comp,
const StatusCode &  sc 
)
overrideprotectedvirtual

Definition at line 131 of file PyAthenaAud.cxx.

132 {
133  py_after (evt, comp->name(), sc);
134 }

◆ before() [1/4]

void PyAthena::Aud::before ( CustomEventTypeRef  evt,
const std::string &  comp 
)
overrideprotectedvirtual

Definition at line 125 of file PyAthenaAud.cxx.

126 {
127  py_before (evt, comp);
128 }

◆ before() [2/4]

void PyAthena::Aud::before ( CustomEventTypeRef  evt,
INamedInterface *  comp 
)
overrideprotectedvirtual

Definition at line 119 of file PyAthenaAud.cxx.

120 {
121  py_before (evt, comp->name());
122 }

◆ before() [3/4]

void PyAthena::Aud::before ( StandardEventType  evt,
const std::string &  comp 
)
overrideprotectedvirtual

Definition at line 113 of file PyAthenaAud.cxx.

114 {
115  py_before (evt, comp);
116 }

◆ before() [4/4]

void PyAthena::Aud::before ( StandardEventType  evt,
INamedInterface *  comp 
)
overrideprotectedvirtual

Auditor interface

Definition at line 107 of file PyAthenaAud.cxx.

108 {
109  py_before (evt, comp->name());
110 }

◆ DeclareInterfaceID()

IPyComponent::DeclareInterfaceID ( IPyComponent  ,
,
 
)
inherited

◆ finalize()

StatusCode PyAthena::Aud::finalize ( )
overridevirtual

Definition at line 86 of file PyAthenaAud.cxx.

87 {
88  return PyAthena::callPyMethod( m_self, "sysFinalize" );
89 }

◆ initialize()

StatusCode PyAthena::Aud::initialize ( )
overridevirtual

Gaudi Aud Implementation.

Definition at line 60 of file PyAthenaAud.cxx.

61 {
62  return PyAthena::callPyMethod( m_self, "sysInitialize" );
63 }

◆ py_after() [1/2]

void PyAthena::Aud::py_after ( IAuditor::CustomEventTypeRef  evt,
const std::string &  component,
const StatusCode &  sc 
)
virtual

Audit the end of a custom "event".

Definition at line 197 of file PyAthenaAud.cxx.

200 {
201  return PyAthena::pyAudit (m_self,
202  "after", evt.c_str(), component.c_str(), sc);
203 }

◆ py_after() [2/2]

void PyAthena::Aud::py_after ( IAuditor::StandardEventType  evt,
const std::string &  component,
const StatusCode &  sc 
)
virtual

Audit the end of a standard "event".

Definition at line 179 of file PyAthenaAud.cxx.

182 {
183  const char* evtname = 0;
184  switch (evt) {
185  case Initialize: evtname = "initialize"; break;
186  case ReInitialize: evtname = "reinitialize"; break;
187  case Execute: evtname = "execute"; break;
188  case Finalize: evtname = "finalize"; break;
189  case Start: evtname = "start"; break;
190  case Stop: evtname = "stop"; break;
191  case ReStart: evtname = "restart"; break;
192  }
193  return PyAthena::pyAudit (m_self, "after", evtname, component.c_str(), sc);
194 }

◆ py_before() [1/2]

void PyAthena::Aud::py_before ( IAuditor::CustomEventTypeRef  evt,
const std::string &  component 
)
virtual

Audit the start of a custom "event".

Definition at line 173 of file PyAthenaAud.cxx.

174 {
175  return PyAthena::pyAudit (m_self, "before", evt.c_str(), component.c_str());
176 }

◆ py_before() [2/2]

void PyAthena::Aud::py_before ( IAuditor::StandardEventType  evt,
const std::string &  component 
)
virtual

Audit the start of a standard "event".

Definition at line 157 of file PyAthenaAud.cxx.

158 {
159  const char* evtname = 0;
160  switch (evt) {
161  case Initialize: evtname = "initialize"; break;
162  case ReInitialize: evtname = "reinitialize"; break;
163  case Execute: evtname = "execute"; break;
164  case Finalize: evtname = "finalize"; break;
165  case Start: evtname = "start"; break;
166  case Stop: evtname = "stop"; break;
167  case ReStart: evtname = "restart"; break;
168  }
169  return PyAthena::pyAudit (m_self, "before", evtname, component.c_str());
170 }

◆ self()

virtual PyObject* PyAthena::Aud::self ( )
inlineoverridevirtual

return associated python object.

BORROWED reference.

Implements IPyComponent.

Definition at line 76 of file PyAthenaAud.h.

76 { return m_self; }

◆ setPyAttr()

bool PyAthena::Aud::setPyAttr ( PyObject pyobj)
overrideprotectedvirtual

attach the C++ component to its python cousin

Implements IPyComponent.

Definition at line 211 of file PyAthenaAud.cxx.

212 {
213  // now we tell the PyObject which C++ object it is the cousin of.
215  PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
216  ( (void*)this, this->typeName() );
217  if ( !pyobj ) {
218  PyErr_Clear();
219  // try PyAthena::Aud
220  pyobj = TPython::CPPInstance_FromVoidPtr ((void*)this, "PyAthena::Aud");
221  MsgStream msg( msgSvc(), name() );
222  msg << MSG::INFO
223  << "could not dyncast component [" << name() << "] to a python "
224  << "object of type [" << this->typeName() << "] (probably a missing "
225  << "dictionary)" << endmsg
226  << "fallback to [PyAthena::Aud]..."
227  << endmsg;
228  }
229  if ( !pyobj ) {
230  PyErr_Clear();
231  MsgStream msg( msgSvc(), name() );
232  msg << MSG::WARNING << "Could not dyncast component ["
233  << name() << "] to a pyobject of type ["
234  << this->typeName() << "]"
235  << endmsg;
236  } else {
237  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", pyobj) ) {
238  PyErr_Clear();
239  MsgStream msg( msgSvc(), name() );
240  msg << MSG::WARNING
241  << "Could not attach C++ handle [" << name() << "] to its python "
242  << "cousin !"
243  << endmsg;
244  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", Py_None) ) {
245  PyErr_Clear();
246  msg << MSG::WARNING
247  << "could not attach a dummy C++ handle [" << name() << "] to its "
248  << "python cousin !"
249  << endmsg;
250  }
251  } else {
252  return true;
253  }
254  }
255  return false;
256 }

◆ sysInitialize()

StatusCode PyAthena::Aud::sysInitialize ( )
overridevirtual

Definition at line 66 of file PyAthenaAud.cxx.

67 {
69  ( "PyAthena::PyComponentMgr/PyComponentMgr", name() );
70  if ( !pyMgr.retrieve().isSuccess() ) {
71  return StatusCode::FAILURE;
72  }
73 
74  // first retrieve our python object cousin...
75  m_self = pyMgr->pyObject( this );
76 
77  if ( m_self == Py_None ) {
78  return StatusCode::FAILURE;
79  }
80 
81  // re-route to usual sysInit...
82  return ::Auditor::sysInitialize();
83 }

◆ typeName()

const char * PyAthena::Aud::typeName ( ) const
overridevirtual

return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part

Implements IPyComponent.

Definition at line 96 of file PyAthenaAud.cxx.

97 {
98  static const std::string tname = System::typeinfoName(typeid(*this));
99  return tname.c_str();
100 }

Member Data Documentation

◆ m_self

PyObject* PyAthena::Aud::m_self
protected

Pointer to self (from the python world)

Definition at line 112 of file PyAthenaAud.h.


The documentation for this class was generated from the following files:
plotting.yearwise_luminosity_vs_mu.comp
comp
Definition: yearwise_luminosity_vs_mu.py:23
PyAthena::Aud::py_before
virtual void py_before(IAuditor::StandardEventType, const std::string &)
Audit the start of a standard "event".
Definition: PyAthenaAud.cxx:157
PyAthena::Aud::py_after
virtual void py_after(IAuditor::StandardEventType, const std::string &, const StatusCode &)
Audit the end of a standard "event".
Definition: PyAthenaAud.cxx:179
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
RootUtils::PyGILStateEnsure
Definition: PyAthenaGILStateEnsure.h:20
LArPulseShapeRunConfig.Execute
Execute
Definition: LArPulseShapeRunConfig.py:62
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition: AthenaKernel/src/ClassName.cxx:23
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
PyAthena::Aud::typeName
virtual const char * typeName() const override
return the std::type_info name of the underlying py-component This is used by concrete implementation...
Definition: PyAthenaAud.cxx:96
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
jobOptions.Initialize
Initialize
Definition: jobOptions.pA.py:28
PyAthena::Aud::m_self
PyObject * m_self
Pointer to self (from the python world)
Definition: PyAthenaAud.h:112
PyObject
_object PyObject
Definition: IPyComponent.h:26
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ServiceHandle
Definition: ClusterMakerTool.h:37