| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# GaudiPython::Helper Struct Reference

`#include <Helpers.h>`

List of all members.

## Public Member Functions
| Helper ()
## Static Public Member Functions
static IService * | service (ISvcLocator *svcloc, const std::string &name, bool createif=false)
static IAlgorithm * | algorithm (IAlgManager *algmgr, const std::string &name, const bool createIf=false)
static DataObject * | dataobject (IDataProviderSvc *dpsvc, const std::string &path)
static GAUDI_API DataObject * | findobject (IDataProviderSvc *dpsvc, const std::string &path)
| simple wrapper for IDataProviderSvc::findObject The methdod does NOT trigger the loading the object from tape or Data-On-Demand action
static GAUDI_API DataObject * | getobject (IDataProviderSvc *dpsvc, const std::string &path, const bool retrieve=true, const bool disableDoD=false)
| the generic function to get object from TES
static IAlgTool * | tool (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 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,
|  | const bool | createIf = `false` |
| ) |  |  | `[inline, static]`

Definition at line 50 of file Helpers.h.

    00053   {
    00054     return algmgr->algorithm(name, createIf).get();
    00055   }

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

Definition at line 57 of file Helpers.h.

    00059   {
    00060     DataObject* o;
    00061     if ( dpsvc->retrieveObject(path,o).isSuccess() ) return o;
    00062     else return 0;
    00063   }

DataObject * GaudiPython::Helper::findobject | ( | IDataProviderSvc * | dpsvc,
|  | const std::string & | path |
| ) |  |  | `[static]`

simple wrapper for IDataProviderSvc::findObject The methdod does NOT trigger the loading the object from tape or Data-On-Demand action

See also:
  IDataProviderSvc

  IDataProviderSvc::findObject

Parameters:

  | psvc | (INPUT) pointer to Data ProviderService
  | path | the full path in TES

Returns:
  the object

Author:
  Vanya BELYAEV Ivan.Belyaev@nikhef.nl

Date:
  2009-10-09

Definition at line 41 of file Helpers.cpp.

    00043 {
    00044   DataObject* o = 0 ;
    00045   if ( 0 == dpsvc     ) { return 0 ; }                              // RETURN
    00046   StatusCode sc = dpsvc -> findObject ( path , o ) ;  // NB!
    00047   if ( sc.isFailure() ) { return 0 ; }                              // RETURN
    00048   return o ;                                                        // RETURN
    00049 }

DataObject * GaudiPython::Helper::getobject | ( | IDataProviderSvc * | dpsvc,
|  | const std::string & | path,
|  | const bool | retrieve = `true`,
|  | const bool | disableDoD = `false` |
| ) |  |  | `[static]`

the generic function to get object from TES

See also:
  IDataProviderSvc

  IDataProviderSvc::findObject

  IDataProviderSvc::retriveObject

Parameters:

  | psvc | (INPUT) pointer to Data ProviderService
  | path | the full path in TES
  | rerieve | (INPUT) retrieve or find object ?
  | disableDoD | (INPUT) disable 'on-demand-actions' ?

Author:
  Vanya BELYAEV Ivan.Belyaev@nikhef.nl

Date:
  2009-10-09

Definition at line 133 of file Helpers.cpp.

    00137 {
    00138   if ( 0 == dpsvc ) { return 0 ; }  // RETURN 0
    00139   // create the sentry:
    00140   Disabler sentry ( dpsvc , disable ) ;
    00141   //
    00142   DataObject * result = 0 ;
    00143   //
    00144   StatusCode sc =
    00145     retrieve ?
    00146     dpsvc -> retrieveObject ( path , result ) :
    00147     dpsvc -> findObject     ( path , result ) ;
    00148   //
    00149   if ( sc.isFailure() ) { return 0 ; }                               // RETURN
    00150   //
    00151   return result ;                                                    // RETURN
    00152 }

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

Definition at line 96 of file Helpers.h.

    00096                                                                                                                    {
    00097     IAlgTool* o;
    00098     if ( toolsvc->retrieve(type, name, IAlgTool::interfaceID(), o, p, cif).isSuccess() ) return o;
    00099     else return 0;
    00100   }

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

Definition at line 101 of file Helpers.h.

    00101                                                     {
    00102     void* h;
    00103     return System::loadDynamicLib(name, &h);
    00104   }

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

Definition at line 105 of file Helpers.h.

    00105                                                                              {
    00106     IHistogram1D* h;
    00107     if ( hsvc->findObject(path, h ).isSuccess() ) return h;
    00108     else                                          return 0;
    00109   }

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

Definition at line 110 of file Helpers.h.

    00110                                                                              {
    00111     IHistogram2D* h;
    00112     if ( hsvc->findObject(path, h ).isSuccess() ) return h;
    00113     else                                          return 0;
    00114   }

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

Definition at line 115 of file Helpers.h.

    00115                                                                              {
    00116     IHistogram3D* h;
    00117     if ( hsvc->findObject(path, h ).isSuccess() ) return h;
    00118     else                                          return 0;
    00119   }

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

Definition at line 122 of file Helpers.h.

    00124   {
    00125     IProfile1D* h = 0 ;
    00126     if ( 0 != hsvc && hsvc->findObject ( path , h ).isSuccess() ) { return h ; }
    00127     return 0 ;
    00128   }

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

Definition at line 131 of file Helpers.h.

    00133   {
    00134     IProfile2D* h = 0 ;
    00135     if ( 0 != hsvc && hsvc->findObject ( path , h ).isSuccess() ) { return h ; }
    00136     return 0 ;
    00137   }

template<class T>

static Py_ssize_t GaudiPython::Helper::Array_length | ( | PyObject * | self | ) | `[inline, static, private]`

Definition at line 141 of file Helpers.h.

    00141                                                    {
    00142 #if PY_VERSION_HEX < 0x02050000
    00143     const
    00144 #endif
    00145     char* buf = 0;
    00146     Py_ssize_t size = (*(self->ob_type->tp_as_buffer->bf_getcharbuffer))( self, 0, &buf );
    00147     return size/sizeof(T);
    00148   }

template<class T>

static PyObject* GaudiPython::Helper::toPython | ( | T * | o | ) | `[inline, static, private]`

Definition at line 150 of file Helpers.h.

    00150 { return 0; }

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

Definition at line 151 of file Helpers.h.

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

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

Definition at line 152 of file Helpers.h.

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

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

Definition at line 153 of file Helpers.h.

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

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

Definition at line 154 of file Helpers.h.

    00154 { return PyInt_FromLong(*o); }

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

Definition at line 155 of file Helpers.h.

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

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

Definition at line 156 of file Helpers.h.

    00156 { 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 159 of file Helpers.h.

    00159                                                                 {
    00160 #if PY_VERSION_HEX < 0x02050000
    00161     const
    00162 #endif
    00163     char* buf = 0;
    00164     Py_ssize_t size = (*(self->ob_type->tp_as_buffer->bf_getcharbuffer))( self, 0, &buf );
    00165     if ( idx < 0 || idx >= size/int(sizeof(T)) ) {
    00166        PyErr_SetString( PyExc_IndexError, "buffer index out of range" );
    00167        return 0;
    00168     }
    00169     return toPython((T*)buf + idx);
    00170   }

template<class T>

static PyObject* GaudiPython::Helper::toArray | ( | T * | ptr,
|  | Py_ssize_t | size |
| ) |  |  | `[inline, static]`

Definition at line 174 of file Helpers.h.

    00174                                                       {
    00175    static PyTypeObject      type = PyBuffer_Type;
    00176    static PySequenceMethods meth = *(PyBuffer_Type.tp_as_sequence);
    00177 #if PY_VERSION_HEX < 0x02050000
    00178    meth.sq_item         = (intargfunc) &Array_item<T>;
    00179    meth.sq_length       = (inquiry) &Array_length<T>;
    00180 #else
    00181    meth.sq_item         = (ssizeargfunc) &Array_item<T>;
    00182    meth.sq_length       = (lenfunc) &Array_length<T>;
    00183 #endif
    00184    type.tp_as_sequence  = &meth;
    00185    PyObject* buf = PyBuffer_FromReadWriteMemory( ptr, size*sizeof(T) );
    00186    buf->ob_type = &type;
    00187    Py_INCREF( buf->ob_type );
    00188    return buf;
    00189   }

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

Definition at line 190 of file Helpers.h.

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

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

Definition at line 191 of file Helpers.h.

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

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

Definition at line 192 of file Helpers.h.

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

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

Definition at line 193 of file Helpers.h.

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

template<class T>

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

Definition at line 196 of file Helpers.h.

    00196                                          {
    00197     return &(*v.begin());
    00198   }

template<class T>

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

Definition at line 200 of file Helpers.h.

    00200                                  {
    00201     return (T*)a;
    00202   }

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r11/GaudiPython/GaudiPython/Helpers.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r11/GaudiPython/src/Lib/Helpers.cpp