Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

GaudiPython::Helper Struct Reference

#include <Helpers.h>

List of all members.


Detailed Description

Definition at line 39 of file Helpers.h.


Public Member Functions

 Helper ()

Static Public Member Functions

static IServiceservice (ISvcLocator *svcloc, const std::string &name, bool createif=false)
static IAlgorithmalgorithm (IAlgManager *algmgr, const std::string &name)
static DataObjectdataobject (IDataProviderSvc *dpsvc, const std::string &path)
static IAlgTooltool (IToolSvc *toolsvc, const std::string &type, const std::string &name, IInterface *p, bool cif)
static long loadDynamicLib (const std::string &name)
static IHistogram1D * histo1D (IHistogramSvc *hsvc, const std::string &path)
static IHistogram2D * histo2D (IHistogramSvc *hsvc, const std::string &path)
static IHistogram3D * histo3D (IHistogramSvc *hsvc, const std::string &path)
static IProfile1D * profile1D (IHistogramSvc *hsvc, const std::string &path)
static IProfile2D * profile2D (IHistogramSvc *hsvc, const std::string &path)
template<class T>
static PyObject * toArray (T *ptr, Py_ssize_t size)
static PyObject * toIntArray (void *ptr, Py_ssize_t size)
static PyObject * toShortArray (void *ptr, Py_ssize_t size)
static PyObject * toFloatArray (void *ptr, Py_ssize_t size)
static PyObject * toDoubleArray (void *ptr, Py_ssize_t size)
template<class T>
static T * toAddress (std::vector< T > &v)
template<class T>
static T * toAddress (void *a)

Static Private Member Functions

template<class T>
static Py_ssize_t Array_length (PyObject *self)
template<class T>
static PyObject * toPython (T *o)
static PyObject * toPython (int *o)
static PyObject * toPython (short *o)
static PyObject * toPython (char *o)
static PyObject * toPython (long *o)
static PyObject * toPython (float *o)
static PyObject * toPython (double *o)
template<class T>
static PyObject * Array_item (PyObject *self, Py_ssize_t idx)

Constructor & Destructor Documentation

GaudiPython::Helper::Helper (  )  [inline]

Definition at line 43 of file Helpers.h.

00043 {}


Member Function Documentation

static IService* GaudiPython::Helper::service ( ISvcLocator svcloc,
const std::string name,
bool  createif = false 
) [inline, static]

Definition at line 45 of file Helpers.h.

00045                                                                                             {
00046     return svcloc->service(name, createif).get();
00047   }

static IAlgorithm* GaudiPython::Helper::algorithm ( IAlgManager algmgr,
const std::string name 
) [inline, static]

Definition at line 49 of file Helpers.h.

00049                                                                            {
00050     const bool createIf = false;
00051     return algmgr->algorithm(name, createIf).get();
00052   }

static DataObject* GaudiPython::Helper::dataobject ( IDataProviderSvc dpsvc,
const std::string path 
) [inline, static]

Definition at line 53 of file Helpers.h.

00053                                                                                  {
00054     DataObject* o;
00055     if ( dpsvc->retrieveObject(path,o).isSuccess() ) return o;
00056     else return 0;
00057   }

static IAlgTool* GaudiPython::Helper::tool ( IToolSvc toolsvc,
const std::string type,
const std::string name,
IInterface p,
bool  cif 
) [inline, static]

Definition at line 58 of file Helpers.h.

00058                                                                                                                    {
00059     IAlgTool* o;
00060     if ( toolsvc->retrieve(type, name, IAlgTool::interfaceID(), o, p, cif).isSuccess() ) return o;
00061     else return 0;
00062   }

static long GaudiPython::Helper::loadDynamicLib ( const std::string name  )  [inline, static]

Definition at line 63 of file Helpers.h.

00063                                                     {
00064     void* h;
00065     return System::loadDynamicLib(name, &h);
00066   }

static IHistogram1D* GaudiPython::Helper::histo1D ( IHistogramSvc hsvc,
const std::string path 
) [inline, static]

Definition at line 67 of file Helpers.h.

00067                                                                              {
00068     IHistogram1D* h;
00069     if ( hsvc->findObject(path, h ).isSuccess() ) return h;
00070     else                                          return 0;
00071   }

static IHistogram2D* GaudiPython::Helper::histo2D ( IHistogramSvc hsvc,
const std::string path 
) [inline, static]

Definition at line 72 of file Helpers.h.

00072                                                                              {
00073     IHistogram2D* h;
00074     if ( hsvc->findObject(path, h ).isSuccess() ) return h;
00075     else                                          return 0;
00076   }

static IHistogram3D* GaudiPython::Helper::histo3D ( IHistogramSvc hsvc,
const std::string path 
) [inline, static]

Definition at line 77 of file Helpers.h.

00077                                                                              {
00078     IHistogram3D* h;
00079     if ( hsvc->findObject(path, h ).isSuccess() ) return h;
00080     else                                          return 0;
00081   }

static IProfile1D* GaudiPython::Helper::profile1D ( IHistogramSvc hsvc,
const std::string path 
) [inline, static]

Definition at line 84 of file Helpers.h.

00086   {
00087     IProfile1D* h = 0 ;
00088     if ( 0 != hsvc && hsvc->findObject ( path , h ).isSuccess() ) { return h ; }
00089     return 0 ;
00090   }

static IProfile2D* GaudiPython::Helper::profile2D ( IHistogramSvc hsvc,
const std::string path 
) [inline, static]

Definition at line 93 of file Helpers.h.

00095   {
00096     IProfile2D* h = 0 ;
00097     if ( 0 != hsvc && hsvc->findObject ( path , h ).isSuccess() ) { return h ; }
00098     return 0 ;
00099   }

template<class T>
static Py_ssize_t GaudiPython::Helper::Array_length ( PyObject *  self  )  [inline, static, private]

Definition at line 103 of file Helpers.h.

00103                                                    {
00104 #if PY_VERSION_HEX < 0x02050000
00105     const
00106 #endif
00107     char* buf = 0;
00108     Py_ssize_t size = (*(self->ob_type->tp_as_buffer->bf_getcharbuffer))( self, 0, &buf );
00109     return size/sizeof(T);
00110   }

template<class T>
static PyObject* GaudiPython::Helper::toPython ( T *  o  )  [inline, static, private]

Definition at line 112 of file Helpers.h.

00112 { return 0; }

static PyObject* GaudiPython::Helper::toPython ( int *  o  )  [inline, static, private]

Definition at line 113 of file Helpers.h.

00113 { return PyInt_FromLong((long)*o); }

static PyObject* GaudiPython::Helper::toPython ( short *  o  )  [inline, static, private]

Definition at line 114 of file Helpers.h.

00114 { return PyInt_FromLong((long)*o); }

static PyObject* GaudiPython::Helper::toPython ( char *  o  )  [inline, static, private]

Definition at line 115 of file Helpers.h.

00115 { return PyInt_FromLong((long)*o); }

static PyObject* GaudiPython::Helper::toPython ( long *  o  )  [inline, static, private]

Definition at line 116 of file Helpers.h.

00116 { return PyInt_FromLong(*o); }

static PyObject* GaudiPython::Helper::toPython ( float *  o  )  [inline, static, private]

Definition at line 117 of file Helpers.h.

00117 { return PyFloat_FromDouble((double)*o); }

static PyObject* GaudiPython::Helper::toPython ( double *  o  )  [inline, static, private]

Definition at line 118 of file Helpers.h.

00118 { return PyFloat_FromDouble(*o); }

template<class T>
static PyObject* GaudiPython::Helper::Array_item ( PyObject *  self,
Py_ssize_t  idx 
) [inline, static, private]

Definition at line 121 of file Helpers.h.

00121                                                                 {
00122 #if PY_VERSION_HEX < 0x02050000
00123     const
00124 #endif
00125     char* buf = 0;
00126     Py_ssize_t size = (*(self->ob_type->tp_as_buffer->bf_getcharbuffer))( self, 0, &buf );
00127     if ( idx < 0 || idx >= size/int(sizeof(T)) ) {
00128        PyErr_SetString( PyExc_IndexError, "buffer index out of range" );
00129        return 0;
00130     }
00131     return toPython((T*)buf + idx);
00132   }

template<class T>
static PyObject* GaudiPython::Helper::toArray ( T *  ptr,
Py_ssize_t  size 
) [inline, static]

Definition at line 136 of file Helpers.h.

00136                                                       {
00137    static PyTypeObject      type = PyBuffer_Type;
00138    static PySequenceMethods meth = *(PyBuffer_Type.tp_as_sequence);
00139 #if PY_VERSION_HEX < 0x02050000
00140    meth.sq_item         = (intargfunc) &Array_item<T>;
00141    meth.sq_length       = (inquiry) &Array_length<T>;
00142 #else
00143    meth.sq_item         = (ssizeargfunc) &Array_item<T>;
00144    meth.sq_length       = (lenfunc) &Array_length<T>;
00145 #endif
00146    type.tp_as_sequence  = &meth;
00147    PyObject* buf = PyBuffer_FromReadWriteMemory( ptr, size*sizeof(T) );
00148    Py_INCREF( &type );
00149    buf->ob_type = &type;
00150    return buf;
00151   }

static PyObject* GaudiPython::Helper::toIntArray ( void *  ptr,
Py_ssize_t  size 
) [inline, static]

Definition at line 152 of file Helpers.h.

00152 { return toArray( (int*)    ptr , size ); }

static PyObject* GaudiPython::Helper::toShortArray ( void *  ptr,
Py_ssize_t  size 
) [inline, static]

Definition at line 153 of file Helpers.h.

00153 { return toArray( (short*)  ptr , size ); }

static PyObject* GaudiPython::Helper::toFloatArray ( void *  ptr,
Py_ssize_t  size 
) [inline, static]

Definition at line 154 of file Helpers.h.

00154 { return toArray( (float*)  ptr , size ); }

static PyObject* GaudiPython::Helper::toDoubleArray ( void *  ptr,
Py_ssize_t  size 
) [inline, static]

Definition at line 155 of file Helpers.h.

00155 { return toArray( (double*) ptr , size ); }

template<class T>
static T* GaudiPython::Helper::toAddress ( std::vector< T > &  v  )  [inline, static]

Definition at line 158 of file Helpers.h.

00158                                          {
00159     return &(*v.begin());
00160   }

template<class T>
template double * GaudiPython::Helper::toAddress< double > ( void *  a  )  [inline, static]

Definition at line 162 of file Helpers.h.

00162                                  {
00163     return (T*)a;
00164   }


The documentation for this struct was generated from the following file:

Generated at Mon Sep 7 18:26:27 2009 for Gaudi Framework, version v21r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004