| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Static Public Member Functions | Static Private Member Functions | List of all members
GaudiPython::Helper Struct Reference

`#include <GaudiPython/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 StatusCode | registerObject (IDataProviderSvc *dpsvc, const std::string &path, DataObject *pObject)
static StatusCode | unregisterObject (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 More...
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 More...
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 (Gaudi::Details::PropertyBase &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 50 of file Helpers.h.

## Constructor & Destructor Documentation

## ◆ Helper()

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

Definition at line 54 of file Helpers.h.

54 {}

## Member Function Documentation

## ◆ algorithm()

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

Definition at line 60 of file Helpers.h.

60 {
61 return algmgr->algorithm( name, createIf ).get();
62 }
IAlgManager::algorithm
virtual SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76

## ◆ Array_item()

template<class T >

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

Definition at line 157 of file Helpers.h.

157 {
158 #if PY_VERSION_HEX < 0x02050000
159 const
160 #endif
161 char* buf = nullptr;
162 Py_ssize_t size = ( *( self->ob_type->tp_as_buffer->bf_getcharbuffer ) )( self, 0, &buf );
163 if ( idx < 0 || idx >= size / int( sizeof( T ) ) ) {
164 PyErr_SetString( PyExc_IndexError, "buffer index out of range" );
165 return nullptr;
166 }
167 return toPython( (T*)buf + idx );
168 }
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
GaudiPython::Helper::toPython
static PyObject * toPython(T *)
Definition: Helpers.h:146
Py_ssize_t
int Py_ssize_t
For compatibility with Python 2.4 and 2.5.
Definition: Helpers.h:34

## ◆ Array_length()

template<class T >

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

Definition at line 136 of file Helpers.h.

136 {
137 #if PY_VERSION_HEX < 0x02050000
138 const
139 #endif
140 char* buf = 0;
141 Py_ssize_t size = ( *( self->ob_type->tp_as_buffer->bf_getcharbuffer ) )( self, 0, &buf );
142 return size / sizeof( T );
143 }
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
Py_ssize_t
int Py_ssize_t
For compatibility with Python 2.4 and 2.5.
Definition: Helpers.h:34

## ◆ dataobject()

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

Definition at line 64 of file Helpers.h.

64 {
65 DataObject* o;
66 return dpsvc->retrieveObject( path, o ).isSuccess() ? o : nullptr;
67 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30

## ◆ findobject()

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 41 of file Helpers.cpp.

41 {
42 DataObject* o = nullptr;
43 if ( !dpsvc ) { return nullptr; } // RETURN
44 StatusCode sc = dpsvc->findObject( path, o ); // NB!
45 return sc.isSuccess() ? o : nullptr; // RETURN
46 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30

## ◆ getobject()

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 109 of file Helpers.cpp.

110 {
111 if ( !dpsvc ) { return nullptr; } // RETURN 0
112 // create the sentry:
113 Disabler sentry( dpsvc, disable );
114 //
115 DataObject* result = nullptr;
116 //
117 StatusCode sc = retrieve ? dpsvc->retrieveObject( path, result ) : dpsvc->findObject( path, result );
118 //
119 return sc.isSuccess() ? result : nullptr;
120 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30

## ◆ histo1D()

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

Definition at line 112 of file Helpers.h.

112 {
113 IHistogram1D* h;
114 return ( hsvc->findObject( path, h ).isSuccess() ) ? h : nullptr;
115 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
IHistogramSvc::findObject
virtual StatusCode findObject(const std::string &fullPath, AIDA::IHistogram1D *&h1dObj)=0

## ◆ histo2D()

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

Definition at line 116 of file Helpers.h.

116 {
117 IHistogram2D* h;
118 return ( hsvc->findObject( path, h ).isSuccess() ) ? h : nullptr;
119 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
IHistogramSvc::findObject
virtual StatusCode findObject(const std::string &fullPath, AIDA::IHistogram1D *&h1dObj)=0

## ◆ histo3D()

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

Definition at line 120 of file Helpers.h.

120 {
121 IHistogram3D* h;
122 return ( hsvc->findObject( path, h ).isSuccess() ) ? h : nullptr;
123 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
IHistogramSvc::findObject
virtual StatusCode findObject(const std::string &fullPath, AIDA::IHistogram1D *&h1dObj)=0

## ◆ loadDynamicLib()

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

Definition at line 108 of file Helpers.h.

108 {
109 void* h;
110 return System::loadDynamicLib( name, &h );
111 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
System::loadDynamicLib
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition: System.cpp:135

## ◆ profile1D()

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

Definition at line 124 of file Helpers.h.

124 {
125 IProfile1D* h = 0;
126 return ( hsvc && hsvc->findObject( path, h ).isSuccess() ) ? h : nullptr;
127 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
IHistogramSvc::findObject
virtual StatusCode findObject(const std::string &fullPath, AIDA::IHistogram1D *&h1dObj)=0

## ◆ profile2D()

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

Definition at line 128 of file Helpers.h.

128 {
129 IProfile2D* h = 0;
130 return ( hsvc && hsvc->findObject( path, h ).isSuccess() ) ? h : nullptr;
131 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
IHistogramSvc::findObject
virtual StatusCode findObject(const std::string &fullPath, AIDA::IHistogram1D *&h1dObj)=0

## ◆ registerObject()

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

Definition at line 69 of file Helpers.h.

69 {
70 return dpsvc->registerObject( path, pObject );
71 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
IDataProviderSvc::registerObject
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:62

## ◆ service()

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

Definition at line 56 of file Helpers.h.

56 {
57 return svcloc->service( name, createif ).get();
58 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76

## ◆ setPropertyFromString()

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

Definition at line 203 of file Helpers.h.

203 {
204 return p.fromString( s );
205 }
Gaudi::Details::PropertyBase::fromString
virtual StatusCode fromString(const std::string &value)=0
string -> value
gaudirun.s
string s
Definition: gaudirun.py:316

## ◆ toAddress() [1/2]

template<class T >

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

Definition at line 194 of file Helpers.h.

194 {
195 return v.data();
196 }
std::vector::data
T data(T... args)

## ◆ toAddress() [2/2]

template<class T >

static T* GaudiPython::Helper::toAddress | ( | void * | a | ) |
| inline static

Definition at line 198 of file Helpers.h.

198 {
199 return (T*)a;
200 }

## ◆ toArray()

template<class T >

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

Definition at line 172 of file Helpers.h.

172 {
173 static PyTypeObject type = PyBuffer_Type;
174 static PySequenceMethods meth = *( PyBuffer_Type.tp_as_sequence );
175 #if PY_VERSION_HEX < 0x02050000
176 meth.sq_item = (intargfunc)&Array_item<T>;
177 meth.sq_length = (inquiry)&Array_length<T>;
178 #else
179 meth.sq_item = (ssizeargfunc)&Array_item<T>;
180 meth.sq_length = (lenfunc)&Array_length<T>;
181 #endif
182 type.tp_as_sequence = &meth;
183 PyObject* buf = PyBuffer_FromReadWriteMemory( ptr, size * sizeof( T ) );
184 buf->ob_type = &type;
185 Py_INCREF( buf->ob_type );
186 return buf;
187 }
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ toDoubleArray()

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

Definition at line 191 of file Helpers.h.

191 { return toArray( (double*)ptr, size ); }
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
GaudiPython::Helper::toArray
static PyObject * toArray(T *ptr, Py_ssize_t size)
Definition: Helpers.h:172

## ◆ toFloatArray()

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

Definition at line 190 of file Helpers.h.

190 { return toArray( (float*)ptr, size ); }
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
GaudiPython::Helper::toArray
static PyObject * toArray(T *ptr, Py_ssize_t size)
Definition: Helpers.h:172

## ◆ toIntArray()

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

Definition at line 188 of file Helpers.h.

188 { return toArray( (int*)ptr, size ); }
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
GaudiPython::Helper::toArray
static PyObject * toArray(T *ptr, Py_ssize_t size)
Definition: Helpers.h:172

## ◆ tool()

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

Definition at line 103 of file Helpers.h.

104 {
105 IAlgTool* o;
106 return toolsvc->retrieve( type, name, IAlgTool::interfaceID(), o, p, cif ).isSuccess() ? o : nullptr;
107 }
IToolSvc::retrieve
virtual StatusCode retrieve(const std::string &type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent=0, bool createIf=true)=0
Retrieve tool with tool dependent part of the name automatically assigned.
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
gaudirun.type
type
Definition: gaudirun.py:142
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
IInterface::interfaceID
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition: IInterface.h:253

## ◆ toPython() [1/7]

template<class T >

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

Definition at line 146 of file Helpers.h.

146 {
147 return 0;
148 }

## ◆ toPython() [2/7]

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

Definition at line 149 of file Helpers.h.

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

## ◆ toPython() [3/7]

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

Definition at line 150 of file Helpers.h.

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

## ◆ toPython() [4/7]

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

Definition at line 151 of file Helpers.h.

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

## ◆ toPython() [5/7]

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

Definition at line 152 of file Helpers.h.

152 { return PyInt_FromLong( *o ); }

## ◆ toPython() [6/7]

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

Definition at line 153 of file Helpers.h.

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

## ◆ toPython() [7/7]

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

Definition at line 154 of file Helpers.h.

154 { return PyFloat_FromDouble( *o ); }

## ◆ toShortArray()

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

Definition at line 189 of file Helpers.h.

189 { return toArray( (short*)ptr, size ); }
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
GaudiPython::Helper::toArray
static PyObject * toArray(T *ptr, Py_ssize_t size)
Definition: Helpers.h:172

## ◆ unregisterObject()

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

Definition at line 73 of file Helpers.h.

73 {
74 return dpsvc->unregisterObject( path );
75 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
IDataProviderSvc::unregisterObject
virtual StatusCode unregisterObject(std::string_view fullPath)=0
Unregister object from the data store.

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

- GaudiPython/GaudiPython/Helpers.h
- GaudiPython/src/Lib/Helpers.cpp