ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
python.tests.PyTestsLib.MyNameAud Class Reference
Inheritance diagram for python.tests.PyTestsLib.MyNameAud:
Collaboration diagram for python.tests.PyTestsLib.MyNameAud:

Public Member Functions

def __init__ (self, name="MyNameAud", **kw)
 
def initialize (self)
 
def finalize (self)
 
def before (self, evt_name, comp_name)
 
def after (self, evt_name, comp_name, sc)
 
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
 
virtual void beforeInitialize (INamedInterface *) override
 
virtual void afterInitialize (INamedInterface *) override
 
virtual void beforeReinitialize (INamedInterface *) override
 
virtual void afterReinitialize (INamedInterface *) override
 
virtual void beforeExecute (INamedInterface *) override
 
virtual void afterExecute (INamedInterface *, const StatusCode &) override
 
virtual void beforeFinalize (INamedInterface *) override
 
virtual void afterFinalize (INamedInterface *) override
 

Protected Attributes

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

Detailed Description

Simple test of a py-auditor

Definition at line 99 of file PyTestsLib.py.

Constructor & Destructor Documentation

◆ __init__()

def python.tests.PyTestsLib.MyNameAud.__init__ (   self,
  name = "MyNameAud",
**  kw 
)

Definition at line 102 of file PyTestsLib.py.

102  def __init__(self, name="MyNameAud", **kw):
103 
104  kw['name'] = name
105  super(MyNameAud,self).__init__(**kw)
106 

Member Function Documentation

◆ after() [1/5]

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

Definition at line 149 of file PyAthenaAud.cxx.

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

◆ after() [2/5]

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

Definition at line 143 of file PyAthenaAud.cxx.

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

◆ after() [3/5]

def python.tests.PyTestsLib.MyNameAud.after (   self,
  evt_name,
  comp_name,
  sc 
)

Definition at line 119 of file PyTestsLib.py.

119  def after (self, evt_name, comp_name, sc):
120  self.msg.info("Exiting %s [%s]...", evt_name.lower(), comp_name)
121  return
122 

◆ after() [4/5]

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

Definition at line 137 of file PyAthenaAud.cxx.

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

◆ after() [5/5]

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

Definition at line 131 of file PyAthenaAud.cxx.

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

◆ afterExecute()

void PyAthena::Aud::afterExecute ( INamedInterface *  comp,
const StatusCode &  sc 
)
overrideprotectedvirtualinherited

Definition at line 187 of file PyAthenaAud.cxx.

188 {
189  py_after (IAuditor::Execute, comp->name(), sc);
190 }

◆ afterFinalize()

void PyAthena::Aud::afterFinalize ( INamedInterface *  comp)
overrideprotectedvirtualinherited

Definition at line 199 of file PyAthenaAud.cxx.

200 {
201  py_after (IAuditor::Finalize, comp->name(), StatusCode::SUCCESS);
202 }

◆ afterInitialize()

void PyAthena::Aud::afterInitialize ( INamedInterface *  comp)
overrideprotectedvirtualinherited

Definition at line 163 of file PyAthenaAud.cxx.

164 {
165  py_after (IAuditor::Initialize, comp->name(), StatusCode::SUCCESS);
166 }

◆ afterReinitialize()

void PyAthena::Aud::afterReinitialize ( INamedInterface *  comp)
overrideprotectedvirtualinherited

Definition at line 175 of file PyAthenaAud.cxx.

176 {
177  py_after (IAuditor::ReInitialize, comp->name(), StatusCode::SUCCESS);
178 }

◆ before() [1/5]

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

Definition at line 125 of file PyAthenaAud.cxx.

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

◆ before() [2/5]

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

Definition at line 119 of file PyAthenaAud.cxx.

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

◆ before() [3/5]

def python.tests.PyTestsLib.MyNameAud.before (   self,
  evt_name,
  comp_name 
)

Definition at line 115 of file PyTestsLib.py.

115  def before(self, evt_name, comp_name):
116  self.msg.info("Entering %s [%s]...", evt_name.lower(), comp_name)
117  return
118 

◆ before() [4/5]

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

Definition at line 113 of file PyAthenaAud.cxx.

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

◆ before() [5/5]

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

Auditor interface

Definition at line 107 of file PyAthenaAud.cxx.

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

◆ beforeExecute()

void PyAthena::Aud::beforeExecute ( INamedInterface *  comp)
overrideprotectedvirtualinherited

Definition at line 181 of file PyAthenaAud.cxx.

182 {
183  py_before (IAuditor::Execute, comp->name());
184 }

◆ beforeFinalize()

void PyAthena::Aud::beforeFinalize ( INamedInterface *  comp)
overrideprotectedvirtualinherited

Definition at line 193 of file PyAthenaAud.cxx.

194 {
195  py_before (IAuditor::Finalize, comp->name());
196 }

◆ beforeInitialize()

void PyAthena::Aud::beforeInitialize ( INamedInterface *  comp)
overrideprotectedvirtualinherited

Definition at line 157 of file PyAthenaAud.cxx.

158 {
160 }

◆ beforeReinitialize()

void PyAthena::Aud::beforeReinitialize ( INamedInterface *  comp)
overrideprotectedvirtualinherited

Definition at line 169 of file PyAthenaAud.cxx.

170 {
171  py_before (IAuditor::ReInitialize, comp->name());
172 }

◆ DeclareInterfaceID()

IPyComponent::DeclareInterfaceID ( IPyComponent  ,
,
 
)
inherited

◆ finalize() [1/2]

StatusCode PyAthena::Aud::finalize ( )
overridevirtualinherited

Definition at line 86 of file PyAthenaAud.cxx.

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

◆ finalize() [2/2]

def python.tests.PyTestsLib.MyNameAud.finalize (   self)

Definition at line 111 of file PyTestsLib.py.

111  def finalize(self):
112  self.msg.info("==> finalizing [%s]...", self.name)
113  return StatusCode.Success
114 

◆ initialize() [1/2]

StatusCode PyAthena::Aud::initialize ( )
overridevirtualinherited

Gaudi Aud Implementation.

Definition at line 60 of file PyAthenaAud.cxx.

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

◆ initialize() [2/2]

def python.tests.PyTestsLib.MyNameAud.initialize (   self)

Definition at line 107 of file PyTestsLib.py.

107  def initialize(self):
108  self.msg.info("==> initializing [%s]...", self.name)
109  return StatusCode.Success
110 

◆ py_after() [1/2]

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

Audit the end of a custom "event".

Definition at line 246 of file PyAthenaAud.cxx.

249 {
250  return PyAthena::pyAudit (m_self,
251  "after", evt.c_str(), component.c_str(), sc);
252 }

◆ py_after() [2/2]

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

Audit the end of a standard "event".

Definition at line 228 of file PyAthenaAud.cxx.

231 {
232  const char* evtname = 0;
233  switch (evt) {
234  case Initialize: evtname = "initialize"; break;
235  case ReInitialize: evtname = "reinitialize"; break;
236  case Execute: evtname = "execute"; break;
237  case Finalize: evtname = "finalize"; break;
238  case Start: evtname = "start"; break;
239  case Stop: evtname = "stop"; break;
240  case ReStart: evtname = "restart"; break;
241  }
242  return PyAthena::pyAudit (m_self, "after", evtname, component.c_str(), sc);
243 }

◆ py_before() [1/2]

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

Audit the start of a custom "event".

Definition at line 222 of file PyAthenaAud.cxx.

223 {
224  return PyAthena::pyAudit (m_self, "before", evt.c_str(), component.c_str());
225 }

◆ py_before() [2/2]

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

Audit the start of a standard "event".

Definition at line 206 of file PyAthenaAud.cxx.

207 {
208  const char* evtname = 0;
209  switch (evt) {
210  case Initialize: evtname = "initialize"; break;
211  case ReInitialize: evtname = "reinitialize"; break;
212  case Execute: evtname = "execute"; break;
213  case Finalize: evtname = "finalize"; break;
214  case Start: evtname = "start"; break;
215  case Stop: evtname = "stop"; break;
216  case ReStart: evtname = "restart"; break;
217  }
218  return PyAthena::pyAudit (m_self, "before", evtname, component.c_str());
219 }

◆ self()

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

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)
overrideprotectedvirtualinherited

attach the C++ component to its python cousin

Implements IPyComponent.

Definition at line 260 of file PyAthenaAud.cxx.

261 {
262  // now we tell the PyObject which C++ object it is the cousin of.
264  PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
265  ( (void*)this, this->typeName() );
266  if ( !pyobj ) {
267  PyErr_Clear();
268  // try PyAthena::Aud
269  pyobj = TPython::CPPInstance_FromVoidPtr ((void*)this, "PyAthena::Aud");
270  MsgStream msg( msgSvc(), name() );
271  msg << MSG::INFO
272  << "could not dyncast component [" << name() << "] to a python "
273  << "object of type [" << this->typeName() << "] (probably a missing "
274  << "dictionary)" << endmsg
275  << "fallback to [PyAthena::Aud]..."
276  << endmsg;
277  }
278  if ( !pyobj ) {
279  PyErr_Clear();
280  MsgStream msg( msgSvc(), name() );
281  msg << MSG::WARNING << "Could not dyncast component ["
282  << name() << "] to a pyobject of type ["
283  << this->typeName() << "]"
284  << endmsg;
285  } else {
286  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", pyobj) ) {
287  PyErr_Clear();
288  MsgStream msg( msgSvc(), name() );
289  msg << MSG::WARNING
290  << "Could not attach C++ handle [" << name() << "] to its python "
291  << "cousin !"
292  << endmsg;
293  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", Py_None) ) {
294  PyErr_Clear();
295  msg << MSG::WARNING
296  << "could not attach a dummy C++ handle [" << name() << "] to its "
297  << "python cousin !"
298  << endmsg;
299  }
300  } else {
301  return true;
302  }
303  }
304  return false;
305 }

◆ sysInitialize()

StatusCode PyAthena::Aud::sysInitialize ( )
overridevirtualinherited

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
overridevirtualinherited

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
protectedinherited

Pointer to self (from the python world)

Definition at line 123 of file PyAthenaAud.h.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
plotting.yearwise_luminosity_vs_mu.comp
comp
Definition: yearwise_luminosity_vs_mu.py:24
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
PyAthena::Aud::py_before
virtual void py_before(IAuditor::StandardEventType, const std::string &)
Audit the start of a standard "event".
Definition: PyAthenaAud.cxx:206
initialize
void initialize()
Definition: run_EoverP.cxx:894
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:228
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
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:192
jobOptions.Initialize
Initialize
Definition: jobOptions.pA.py:28
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
PyAthena::Aud::m_self
PyObject * m_self
Pointer to self (from the python world)
Definition: PyAthenaAud.h:123
PyObject
_object PyObject
Definition: IPyComponent.h:26
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ServiceHandle
Definition: ClusterMakerTool.h:37