| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Static Private Member Functions | List of all members
GaudiPython::Helper Struct Reference

`#include <Helpers.h>`

## 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 StatusCode | setPropertyFromString (Property &p, const std::string &s)

## Static Private Member Functions
template<class T >
static Py_ssize_t | Array_length (PyObject *self)
template<class T >
static PyObject * | toPython (T *)
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 47 of file Helpers.h.

## Constructor & Destructor Documentation

GaudiPython::Helper::Helper | ( |  | ) |
| inline

Definition at line 51 of file Helpers.h.

{}

## Member Function Documentation

static IAlgorithm* GaudiPython::Helper::algorithm | ( | IAlgManager * | algmgr,
|  | const std::string & | name,
|  | const bool | createIf = `false`
| ) |  |
| inline static

Definition at line 58 of file Helpers.h.

{
return algmgr->algorithm(name, createIf).get();
}
template<class T >

static PyObject* GaudiPython::Helper::Array_item | ( | PyObject * | self,
|  | Py_ssize_t | idx
| ) |  |
| inline static private

Definition at line 168 of file Helpers.h.

{
#if PY_VERSION_HEX < 0x02050000
const
#endif
char* buf = 0;
Py_ssize_t size = (*(self->ob_type->tp_as_buffer->bf_getcharbuffer))( self, 0, &buf );
if ( idx < 0 || idx >= size/int(sizeof(T)) ) {
PyErr_SetString( PyExc_IndexError, "buffer index out of range" );
return 0;
}
return toPython((T*)buf + idx);
}
template<class T >

static Py_ssize_t GaudiPython::Helper::Array_length | ( | PyObject * | self | ) |
| inline static private

Definition at line 150 of file Helpers.h.

{
#if PY_VERSION_HEX < 0x02050000
const
#endif
char* buf = 0;
Py_ssize_t size = (*(self->ob_type->tp_as_buffer->bf_getcharbuffer))( self, 0, &buf );
return size/sizeof(T);
}

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

Definition at line 65 of file Helpers.h.

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

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..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl

Date
  2009-10-09

Definition at line 42 of file Helpers.cpp.

{
DataObject* o = 0 ;
if ( 0 == dpsvc ) { return 0 ; } // RETURN
StatusCode sc = dpsvc -> findObject ( path , o ) ; // NB!
if ( sc.isFailure() ) { return 0 ; } // RETURN
return o ; // RETURN
}

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..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl

Date
  2009-10-09

Definition at line 134 of file Helpers.cpp.

{
if ( 0 == dpsvc ) { return 0 ; } // RETURN 0
// create the sentry:
Disabler sentry ( dpsvc , disable ) ;
//
DataObject * result = 0 ;
//
StatusCode sc =
retrieve ?
dpsvc -> retrieveObject ( path , result ) :
dpsvc -> findObject ( path , result ) ;
//
if ( sc.isFailure() ) { return 0 ; } // RETURN
//
return result ; // RETURN
}

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

Definition at line 113 of file Helpers.h.

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

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

Definition at line 118 of file Helpers.h.

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

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

Definition at line 123 of file Helpers.h.

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

static long GaudiPython::Helper::loadDynamicLib | ( | const std::string & | name | ) |
| inline static

Definition at line 109 of file Helpers.h.

{
void* h;
return System::loadDynamicLib(name, &h);
}

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

Definition at line 130 of file Helpers.h.

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

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

Definition at line 139 of file Helpers.h.

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

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

Definition at line 53 of file Helpers.h.

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

static StatusCode GaudiPython::Helper::setPropertyFromString | ( | Property & | p,
|  | const std::string & | s
| ) |  |
| inline static

Definition at line 214 of file Helpers.h.

{
return p.fromString(s);
}
template<class T >

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

Definition at line 205 of file Helpers.h.

{
return &(*v.begin());
}
template<class T >

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

Definition at line 209 of file Helpers.h.

{
return (T*)a;
}
template<class T >

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

Definition at line 183 of file Helpers.h.

{
static PyTypeObject type = PyBuffer_Type;
static PySequenceMethods meth = *(PyBuffer_Type.tp_as_sequence);
#if PY_VERSION_HEX < 0x02050000
meth.sq_item = (intargfunc) &Array_item<T>;
meth.sq_length = (inquiry) &Array_length<T>;
#else
meth.sq_item = (ssizeargfunc) &Array_item<T>;
meth.sq_length = (lenfunc) &Array_length<T>;
#endif
type.tp_as_sequence = &meth;
PyObject* buf = PyBuffer_FromReadWriteMemory( ptr, size*sizeof(T) );
buf->ob_type = &type;
Py_INCREF( buf->ob_type );
return buf;
}

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

Definition at line 202 of file Helpers.h.

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

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

Definition at line 201 of file Helpers.h.

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

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

Definition at line 199 of file Helpers.h.

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

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

Definition at line 104 of file Helpers.h.

{
IAlgTool* o;
if ( toolsvc->retrieve(type, name, IAlgTool::interfaceID(), o, p, cif).isSuccess() ) return o;
else return 0;
}
template<class T >

static PyObject* GaudiPython::Helper::toPython | ( | T * |  | ) |
| inline static private

Definition at line 159 of file Helpers.h.

{ return 0; }

static PyObject* GaudiPython::Helper::toPython | ( | int * | o | ) |
| inline static private

Definition at line 160 of file Helpers.h.

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

static PyObject* GaudiPython::Helper::toPython | ( | short * | o | ) |
| inline static private

Definition at line 161 of file Helpers.h.

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

static PyObject* GaudiPython::Helper::toPython | ( | char * | o | ) |
| inline static private

Definition at line 162 of file Helpers.h.

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

static PyObject* GaudiPython::Helper::toPython | ( | long * | o | ) |
| inline static private

Definition at line 163 of file Helpers.h.

{ return PyInt_FromLong(*o); }

static PyObject* GaudiPython::Helper::toPython | ( | float * | o | ) |
| inline static private

Definition at line 164 of file Helpers.h.

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

static PyObject* GaudiPython::Helper::toPython | ( | double * | o | ) |
| inline static private

Definition at line 165 of file Helpers.h.

{ return PyFloat_FromDouble(*o); }

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

Definition at line 200 of file Helpers.h.

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

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

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