The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
GaudiPython Namespace Reference

GaudiPython.h GaudiPython/GaudiPython.h. More...

Namespaces

namespace  Bindings
 
namespace  GaudiAlgs
 
namespace  GaudiHandles
 
namespace  HistoUtils
 
namespace  Persistency
 
namespace  Pythonizations
 
namespace  TupleUtils
 

Classes

struct  _identity
 It is here due to 'missing'(?) std::identity. More...
 
class  CallbackStreamBuf
 
struct  Helper
 
struct  Interface
 Minor mofidication of original Pere's structure GaudiPython::Interface This helper class is nesessary to perform C++ castings from python. More...
 
struct  Interface< IInterface >
 
struct  Printer
 
struct  Printer< ContainedObject >
 
struct  Printer< DataObject >
 
class  PyAlgorithm
 Python Algorithm base class. More...
 

Typedefs

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

Functions

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

Detailed Description

GaudiPython.h GaudiPython/GaudiPython.h.

Namespace for all classes interfacing Gaudi to Python.

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

typedef std::vector<Row> GaudiPython::Matrix

Definition at line 29 of file Vector.h.

◆ Row

Definition at line 28 of file Vector.h.

◆ Vector

typedef std::vector<double> GaudiPython::Vector

useful type definition for implicit loos

Definition at line 27 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}
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ 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}