1 #ifndef GAUDIPYTHON_HELPERS_H
2 #define GAUDIPYTHON_HELPERS_H
7 #include "GaudiKernel/IAlgManager.h"
8 #include "GaudiKernel/IAlgorithm.h"
9 #include "GaudiKernel/IAlgTool.h"
22 #if PY_VERSION_HEX < 0x02050000
54 return svcloc->
service(name, createif).get();
59 const std::string& name ,
60 const bool createIf =
false )
66 const std::string&
path )
84 const std::string& path ) ;
99 const std::string& path ,
100 const bool retrieve =
true ,
101 const bool disableDoD =
false ) ;
105 return toolsvc->
retrieve(type, name, IAlgTool::interfaceID(), o, p, cif).
isSuccess() ?
127 const std::string& path )
135 const std::string& path )
145 #if PY_VERSION_HEX < 0x02050000
149 Py_ssize_t size = (*(
self->ob_type->tp_as_buffer->bf_getcharbuffer))(
self, 0, &buf );
150 return size/
sizeof(T);
153 template <
class T>
static PyObject*
toPython(T* ) {
return 0; }
154 static PyObject*
toPython(
int* o) {
return PyInt_FromLong((
long)*o); }
155 static PyObject*
toPython(
short* o) {
return PyInt_FromLong((
long)*o); }
156 static PyObject*
toPython(
char* o) {
return PyInt_FromLong((
long)*o); }
157 static PyObject*
toPython(
long* o) {
return PyInt_FromLong(*o); }
158 static PyObject*
toPython(
float* o) {
return PyFloat_FromDouble((
double)*o); }
159 static PyObject*
toPython(
double* o) {
return PyFloat_FromDouble(*o); }
163 #if PY_VERSION_HEX < 0x02050000
167 Py_ssize_t size = (*(
self->ob_type->tp_as_buffer->bf_getcharbuffer))(
self, 0, &buf );
168 if ( idx < 0 || idx >= size/
int(
sizeof(T)) ) {
169 PyErr_SetString( PyExc_IndexError,
"buffer index out of range" );
178 static PyTypeObject type = PyBuffer_Type;
179 static PySequenceMethods meth = *(PyBuffer_Type.tp_as_sequence);
180 #if PY_VERSION_HEX < 0x02050000
181 meth.sq_item = (intargfunc) &Array_item<T>;
182 meth.sq_length = (inquiry) &Array_length<T>;
184 meth.sq_item = (ssizeargfunc) &Array_item<T>;
185 meth.sq_length = (lenfunc) &Array_length<T>;
187 type.tp_as_sequence = &meth;
188 PyObject* buf = PyBuffer_FromReadWriteMemory( ptr, size*
sizeof(T) );
189 buf->ob_type = &
type;
190 Py_INCREF( buf->ob_type );
199 static T*
toAddress( std::vector<T>& v ) {
221 template int* Helper::toAddress<int>(
void*);
222 template float* Helper::toAddress<float>(
void*);
223 template double* Helper::toAddress<double>(
void*);
227 #endif // !GAUDIPYTHON_HELPERS_H
virtual SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
static IAlgTool * tool(IToolSvc *toolsvc, const std::string &type, const std::string &name, IInterface *p, bool cif)
static PyObject * toDoubleArray(void *ptr, Py_ssize_t size)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
static PyObject * toIntArray(void *ptr, Py_ssize_t size)
static PyObject * toArray(T *ptr, Py_ssize_t size)
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 f...
static IProfile2D * profile2D(IHistogramSvc *hsvc, const std::string &path)
bool isSuccess() const
Test for a status code of SUCCESS.
static StatusCode setPropertyFromString(Property &p, const std::string &s)
static PyObject * toPython(T *)
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
static PyObject * Array_item(PyObject *self, Py_ssize_t idx)
Data provider interface definition.
static PyObject * toFloatArray(void *ptr, Py_ssize_t size)
TYPE * get() const
Get interface pointer.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
int Py_ssize_t
For compatibility with Python 2.4 and 2.5.
static IHistogram3D * histo3D(IHistogramSvc *hsvc, const std::string &path)
static long loadDynamicLib(const std::string &name)
General service interface definition.
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
static IAlgorithm * algorithm(IAlgManager *algmgr, const std::string &name, const bool createIf=false)
Definition of the IHistogramSvc interface class.
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
The IAlgorithm is the interface implemented by the Algorithm base class.
GaudiPython.h GaudiPython/GaudiPython.h.
static IHistogram2D * histo2D(IHistogramSvc *hsvc, const std::string &path)
Property base class allowing Property* collections to be "homogeneous".
static IService * service(ISvcLocator *svcloc, const std::string &name, bool createif=false)
static PyObject * toShortArray(void *ptr, Py_ssize_t size)
static DataObject * dataobject(IDataProviderSvc *dpsvc, const std::string &path)
virtual StatusCode findObject(const std::string &fullPath, AIDA::IHistogram1D *&h1dObj)=0
static Py_ssize_t Array_length(PyObject *self)
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
static T * toAddress(std::vector< T > &v)
static IProfile1D * profile1D(IHistogramSvc *hsvc, const std::string &path)
A DataObject is the base class of any identifiable object on any data store.
static IHistogram1D * histo1D(IHistogramSvc *hsvc, const std::string &path)
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
virtual StatusCode fromString(const std::string &value)=0
string -> value