The Gaudi Framework  master (594c33fa)
GaudiPython Namespace Reference

Namespace for all classes interfacing Gaudi to Python. More...

Namespaces

 Bindings
 
 GaudiAlgs
 
 GaudiHandles
 
 HistoUtils
 
 Persistency
 
 Pythonizations
 
 TupleUtils
 

Classes

struct  _identity
 
class  AlgDecorator
 simple class that allows to "decorate" the python algorithm with 'basic' functionality from class GaudiAlgorithm More...
 
class  CallbackStreamBuf
 
struct  Helper
 
class  HistoDecorator
 
struct  Interface
 
struct  Interface< IInterface >
 
struct  Printer
 
struct  Printer< ContainedObject >
 
struct  Printer< DataObject >
 
class  PyAlg
 
class  PyAlgorithm
 
class  TupleAlgDecorator
 
class  TupleDecorator
 
class  TupleToolDecorator
 

Typedefs

typedef std::vector< double > Vector
 useful type definition for implicit loos More...
 
typedef Vector Row
 
typedef std::vector< RowMatrix
 

Functions

GAUDI_API StatusCode call_python_method (PyObject *self, const char *method)
 call the python method More...
 
int GAUDI_API call_python_method (PyObject *self, const char *method, char *buf)
 call a python method with a string as an argument More...
 

Detailed Description

Namespace for all classes interfacing Gaudi to Python.

GaudiPython.h GaudiPython/GaudiPython.h

The general namespace to hide all Gaudi-python related classes

Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
2005-08-04

Typedef Documentation

◆ Matrix

Definition at line 30 of file Vector.h.

◆ Row

Definition at line 29 of file Vector.h.

◆ Vector

useful type definition for implicit loos

Definition at line 28 of file Vector.h.

Function Documentation

◆ call_python_method() [1/2]

StatusCode GaudiPython::call_python_method ( PyObject *  self,
const char *  method 
)

call the python method

Definition at line 48 of file Algorithm.cpp.

48  {
50  // check arguments
51  if ( !self || !method ) { return StatusCode::FAILURE; }
52 
53  // call Python
54  PyObject* r = PyObject_CallMethod( self, chr( method ), nullptr );
55 
56  if ( !r ) {
57  PyErr_Print();
58  return sc;
59  } // RETURN
60 
61  if ( PyInt_Check( r ) ) {
62  sc = StatusCode( PyInt_AS_LONG( r ) );
63  Py_DECREF( r );
64  return sc;
65  } // RETURN
66 
67  // look for the method getCode with the signature:
68  // ' int getCode() '
69  PyObject* c = PyObject_CallMethod( r, chr( "getCode" ), nullptr );
70 
71  if ( !c ) {
72  PyErr_Print();
73  } else if ( PyLong_Check( c ) ) {
74  sc = StatusCode( PyLong_AsLong( c ) );
75  } else {
76  std::string msg( " call_python_method unexpected type from '" );
77  msg += method;
78  msg += "().getCode()' ";
79  PyErr_SetString( PyExc_TypeError, msg.c_str() );
80  PyErr_Print();
81  }
82  // release used objects
83  Py_XDECREF( c );
84  Py_XDECREF( r );
85  //
86  return sc;
87 }

◆ call_python_method() [2/2]

int GaudiPython::call_python_method ( PyObject *  self,
const char *  method,
char *  buf 
)

call a python method with a string as an argument

Definition at line 22 of file CallbackStreamBuf.cpp.

22  {
23  if ( !self || !method ) { return 1; }
24  PyObject* r = PyObject_CallMethod( self, const_cast<char*>( method ), const_cast<char*>( "s" ), buf );
25  if ( !r ) {
26  std::string err( "Unsuccessful call to bound Python method" );
27  err += method;
28  PyErr_SetString( PyExc_TypeError, err.c_str() );
29  PyErr_Print();
30  return 1;
31  }
32  Py_DECREF( r );
33  return 0;
34 }
std::string
STL class.
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
gaudirun.c
c
Definition: gaudirun.py:525
StatusCode
Definition: StatusCode.h:65
SmartRefVectorImpl::PyObject
_object PyObject
Definition: SmartRefVector.h:32
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101