| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

GaudiPython::Helper Struct Reference

#include <Helpers.h>

List of all members.


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)

Detailed Description

Definition at line 39 of file Helpers.h.


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 44 of file Helpers.h.

00044                                                                                             {
00045     IService* svc;
00046     if ( svcloc->getService(name, svc, createif).isSuccess() ) return svc;
00047     else                                                       return 0;
00048   }  

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

Definition at line 49 of file Helpers.h.

00049                                                                            {
00050     IAlgorithm* alg;
00051     if ( algmgr->getAlgorithm(name, alg ).isSuccess() ) return alg;
00052     else                                                return 0;
00053   }

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

Definition at line 54 of file Helpers.h.

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

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

Definition at line 59 of file Helpers.h.

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

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

Definition at line 64 of file Helpers.h.

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

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

Definition at line 68 of file Helpers.h.

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

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

Definition at line 73 of file Helpers.h.

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

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

Definition at line 78 of file Helpers.h.

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

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

Definition at line 85 of file Helpers.h.

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

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

Definition at line 94 of file Helpers.h.

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

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

Definition at line 104 of file Helpers.h.

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

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

Definition at line 113 of file Helpers.h.

00113 { return 0; }

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

Definition at line 114 of file Helpers.h.

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

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

Definition at line 115 of file Helpers.h.

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

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

Definition at line 116 of file Helpers.h.

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

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

Definition at line 117 of file Helpers.h.

00117 { return PyInt_FromLong(*o); }

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

Definition at line 118 of file Helpers.h.

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

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

Definition at line 119 of file Helpers.h.

00119 { 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 122 of file Helpers.h.

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

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

Definition at line 137 of file Helpers.h.

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

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

Definition at line 153 of file Helpers.h.

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

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

Definition at line 154 of file Helpers.h.

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

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

Definition at line 155 of file Helpers.h.

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

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

Definition at line 156 of file Helpers.h.

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

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

Definition at line 159 of file Helpers.h.

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

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

Definition at line 163 of file Helpers.h.

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


The documentation for this struct was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:58:57 2011 for GaudiPython by doxygen 1.4.7