Gaudi Framework, version v20r2

Generated: 18 Jul 2008

GaudiPython Namespace Reference


Detailed Description

GaudiPython.h GaudiPython/GaudiPython.h.

The general namespace to hide all Gaudi-python related classes

Author:
Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr
Date:
2005-08-04


Classes

class  AlgDecorator
class  PyAlgorithm
 Python Algorithm base class. More...
class  PyAlg
 general class to embedd the existing algorithm/base class into the python More...
class  CallbackStreamBuf
struct  Helper
class  HistoDecorator
 Simple decorator class to allow to reuse the functionality of GaudiHistos<TYPE> class in pythin. More...
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
 
Author:
Vanya BELYAEV Ivan.Belyaev@itep.ru
More...
struct  Printer< ContainedObject >
struct  Printer< DataObject >
class  PyROOTPickle
class  TupleDecorator
 Simple class which performs the decoration of the standard N-Tuple. More...
class  TupleAlgDecorator
 Simple class to perform the "decoration" of Tuples in Python/Reflex. More...
class  TupleToolDecorator
 Simple class to perform the "decoration" of Tuples in Python/Reflex. More...
struct  _identity
 It is here due to 'missing'(?) std::identity. More...

Typedefs

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

Functions

StatusCode call_python_method (PyObject *self, char *method)
 call the python method
bool has_python_method (PyObject *self, char *method)
 check the existence of the method
int call_python_method (PyObject *self, char *method, char *buf)
 call a python method with a string as an argument
StatusCode call_python_method (PyObject *self, char *method)
 call the python method
int call_python_method (PyObject *self, char *method, char *buf)
 call a python method with a string as an argument


Typedef Documentation

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

Definition at line 23 of file Vector.h.

typedef Vector GaudiPython::Row

Definition at line 22 of file Vector.h.

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

useful type definition for implicit loos

Definition at line 21 of file Vector.h.


Function Documentation

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

call a python method with a string as an argument

Definition at line 23 of file CallbackStreamBuf.cpp.

00024 {
00025   if ( 0 == self || 0 == method ) { return 1 ; }
00026   PyObject* r = PyObject_CallMethod ( self , method , "s", buf ) ;
00027   if ( 0 == r ) {
00028     string err("Unsuccsesful call to bound Python method");
00029     err += method;
00030     PyErr_SetString( PyExc_TypeError , err.c_str() ) ;
00031     PyErr_Print() ;
00032     return 1 ;
00033   }
00034   Py_DECREF( r );
00035   return 0 ;
00036 }

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

call the python method

Definition at line 24 of file Algorithm.cpp.

References c, std::basic_string< _CharT, _Traits, _Alloc >::c_str(), and StatusCode::FAILURE.

00025 {
00026   StatusCode sc = StatusCode::FAILURE;
00027   // check arguments 
00028   if ( 0 == self || 0 == method ) { return StatusCode::FAILURE ; }
00029   
00030   // call Python 
00031   PyObject*  r  = PyObject_CallMethod ( self , method , "" ) ;
00032   
00033   if ( 0 == r ) { PyErr_Print() ;              return sc ; } // RETURN
00034   
00035   if ( PyInt_Check ( r ) ) 
00036   { sc = PyInt_AS_LONG( r ) ; Py_DECREF( r ) ; return sc ; } // RETURN 
00037   
00038   // look for the method getCode with the signature: 
00039   //  ' int getCode() '
00040   PyObject* c = PyObject_CallMethod( r  , "getCode" , "" ) ;   
00041   
00042   if      ( 0 == c           ) {      PyErr_Print()      ; }
00043   else if ( PyLong_Check( c )) { sc = PyLong_AsLong( c ); }
00044   else 
00045   {
00046     std::string msg( " call_python_method unexpected type from '" );
00047     msg += method ;
00048     msg += "().getCode()' " ;
00049     PyErr_SetString( PyExc_TypeError , msg.c_str() ) ;
00050     PyErr_Print() ; 
00051   }
00052   // release used objects 
00053   Py_XDECREF( c ) ;
00054   Py_XDECREF( r ) ;
00055   // 
00056   return sc;
00057 } ;

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

call a python method with a string as an argument

Definition at line 23 of file CallbackStreamBuf.cpp.

00024 {
00025   if ( 0 == self || 0 == method ) { return 1 ; }
00026   PyObject* r = PyObject_CallMethod ( self , method , "s", buf ) ;
00027   if ( 0 == r ) {
00028     string err("Unsuccsesful call to bound Python method");
00029     err += method;
00030     PyErr_SetString( PyExc_TypeError , err.c_str() ) ;
00031     PyErr_Print() ;
00032     return 1 ;
00033   }
00034   Py_DECREF( r );
00035   return 0 ;
00036 }

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

call the python method

Definition at line 24 of file Algorithm.cpp.

Referenced by GaudiPython::PyAlgorithm::beginRun(), GaudiPython::PyAlg< ALGORITHM >::beginRun(), GaudiPython::PyAlgorithm::endRun(), GaudiPython::PyAlg< ALGORITHM >::endRun(), GaudiPython::PyAlgorithm::execute(), GaudiPython::PyAlg< ALGORITHM >::execute(), GaudiPython::PyAlgorithm::finalize(), GaudiPython::PyAlg< ALGORITHM >::finalize(), GaudiPython::PyAlgorithm::initialize(), GaudiPython::PyAlg< ALGORITHM >::initialize(), GaudiPython::PyAlgorithm::start(), GaudiPython::PyAlg< ALGORITHM >::start(), GaudiPython::PyAlgorithm::stop(), GaudiPython::PyAlg< ALGORITHM >::stop(), and GaudiPython::CallbackStreamBuf::sync().

00025 {
00026   StatusCode sc = StatusCode::FAILURE;
00027   // check arguments 
00028   if ( 0 == self || 0 == method ) { return StatusCode::FAILURE ; }
00029   
00030   // call Python 
00031   PyObject*  r  = PyObject_CallMethod ( self , method , "" ) ;
00032   
00033   if ( 0 == r ) { PyErr_Print() ;              return sc ; } // RETURN
00034   
00035   if ( PyInt_Check ( r ) ) 
00036   { sc = PyInt_AS_LONG( r ) ; Py_DECREF( r ) ; return sc ; } // RETURN 
00037   
00038   // look for the method getCode with the signature: 
00039   //  ' int getCode() '
00040   PyObject* c = PyObject_CallMethod( r  , "getCode" , "" ) ;   
00041   
00042   if      ( 0 == c           ) {      PyErr_Print()      ; }
00043   else if ( PyLong_Check( c )) { sc = PyLong_AsLong( c ); }
00044   else 
00045   {
00046     std::string msg( " call_python_method unexpected type from '" );
00047     msg += method ;
00048     msg += "().getCode()' " ;
00049     PyErr_SetString( PyExc_TypeError , msg.c_str() ) ;
00050     PyErr_Print() ; 
00051   }
00052   // release used objects 
00053   Py_XDECREF( c ) ;
00054   Py_XDECREF( r ) ;
00055   // 
00056   return sc;
00057 } ;

bool GaudiPython::has_python_method ( PyObject *  self,
char *  method 
)

check the existence of the method


Generated at Fri Jul 18 12:10:31 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004