Skip to content
Snippets Groups Projects
Commit fae5d4d3 authored by Will Buttinger's avatar Will Buttinger Committed by Graeme Stewart
Browse files

'refactored code so can call binding methods from c++ with a given...

'refactored code so can call binding methods from c++ with a given StoreGateSvc (for use in POOLRootAccess)' (StoreGateBindings-00-16-18)

	* StoreGatePyExt: refactored the methods to add calls with a specific StoreGate. This is for use in POOLRootAccess
	* StoreGateBindings/StoreGatePyExt.h: added this
	* Tagging StoreGateBindings-00-06-18


Former-commit-id: 17edc8d3
parent 137fd1c7
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef STOREGATEBINDINGS_STOREGATEPYEXT_H
#define STOREGATEBINDINGS_STOREGATEPYEXT_H
///These methods provide a Python Extension for StoreGate
///Client is POOLRootAccess package, for example
///You must "#include "Python.h" before including this header
///this will give you the correct PyObject
class StoreGateSvc;
struct _object;
typedef _object PyObject;
namespace AthenaInternal {
///retrieve object of specified type from storegate
PyObject*
retrieveObjectFromStore( StoreGateSvc* store,
PyObject* tp, PyObject* pykey );
///typeless retrieve ... slower than above, and potential to return unexpected type if objects of different type but same key
PyObject*
py_sg_getitem (StoreGateSvc* self,
PyObject* pykey);
///check if object of specified type is in storegate
PyObject*
py_sg_contains (StoreGateSvc* store,
PyObject* tp, PyObject* pykey);
///record object to storegate
PyObject*
recordObjectToStore( StoreGateSvc* store,
PyObject* obj,
PyObject* pykey,
bool allowMods = true,
bool resetOnly = true,
bool noHist = false);
}//AthenaInternal namespace
#endif
......@@ -4,6 +4,8 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "StoreGateBindings/StoreGatePyExt.h"
#include "Python.h"
#include "StoreGateBindingsDict.h"
......@@ -51,13 +53,20 @@ namespace {
PyObject*
AthenaInternal::retrieveObjectFromStore( PyObject* self,
PyObject* tp, PyObject* pykey )
{
StoreGateSvc* store = (StoreGateSvc*)ObjectProxy_ASVOIDPTR(self);
return retrieveObjectFromStore(store,tp,pykey);
}
PyObject*
AthenaInternal::retrieveObjectFromStore( StoreGateSvc* store,
PyObject* tp, PyObject* pykey )
{
void* res = 0;
PyObject* objProxy = NULL;
static SG::PyProxyMgr& s_mgr = SG::PyProxyMgr::instance();
StoreGateSvc* store = (StoreGateSvc*)ObjectProxy_ASVOIDPTR(self);
// unlikely to happen, but checking is cheap
if ( ! store ) {
......@@ -304,10 +313,18 @@ AthenaInternal::retrieveObjectFromStore( PyObject* self,
PyObject*
AthenaInternal::py_sg_contains (PyObject* self,
PyObject* tp, PyObject* pykey)
{
StoreGateSvc* store = (StoreGateSvc*)ObjectProxy_ASVOIDPTR(self);
return py_sg_contains(store,tp,pykey);
}
PyObject*
AthenaInternal::py_sg_contains (StoreGateSvc* store,
PyObject* tp, PyObject* pykey)
{
static SG::PyProxyMgr& s_mgr = SG::PyProxyMgr::instance();
StoreGateSvc* store = (StoreGateSvc*)ObjectProxy_ASVOIDPTR(self);
// unlikely to happen, but checking is cheap
if ( ! store ) {
......@@ -373,13 +390,22 @@ AthenaInternal::py_sg_contains (PyObject* self,
return o;
}
PyObject*
AthenaInternal::py_sg_getitem (PyObject* self,
PyObject* pykey)
{
StoreGateSvc* store = (StoreGateSvc*)ObjectProxy_ASVOIDPTR(self);
return py_sg_getitem(store,pykey);
}
PyObject*
AthenaInternal::py_sg_getitem (StoreGateSvc* store,
PyObject* pykey)
{
static SG::PyProxyMgr& s_mgr = SG::PyProxyMgr::instance();
StoreGateSvc* store = (StoreGateSvc*)ObjectProxy_ASVOIDPTR(self);
// unlikely to happen, but checking is cheap
if ( ! store ) {
......@@ -403,7 +429,7 @@ AthenaInternal::py_sg_getitem (PyObject* self,
return 0;
}
return AthenaInternal::retrieveObjectFromStore (self,
return AthenaInternal::retrieveObjectFromStore (store,
s_mgr.pytp(clid),
pykey);
}
......@@ -421,10 +447,22 @@ AthenaInternal::recordObjectToStore( PyObject* self,
bool allowMods /*= true*/,
bool resetOnly /*= true*/,
bool noHist /*= false*/)
{
StoreGateSvc* store = (StoreGateSvc*)ObjectProxy_ASVOIDPTR(self);
return recordObjectToStore(store,obj,pykey,allowMods,resetOnly,noHist);
}
PyObject*
AthenaInternal::recordObjectToStore( StoreGateSvc* store,
PyObject* obj,
PyObject* pykey,
bool allowMods /*= true*/,
bool resetOnly /*= true*/,
bool noHist /*= false*/)
{
static SG::PyProxyMgr& s_mgr = SG::PyProxyMgr::instance();
StoreGateSvc* store = (StoreGateSvc*)ObjectProxy_ASVOIDPTR(self);
// unlikely to happen, but checking is cheap
if ( ! store ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment