Logo ROOT  
Reference Guide
MemoryRegulator.h
Go to the documentation of this file.
1 #ifndef CPYCPPYY_MEMORYREGULATOR_H
2 #define CPYCPPYY_MEMORYREGULATOR_H
3 
4 #include <functional>
5 #include <utility>
6 
7 namespace CPyCppyy {
8 
9 class CPPInstance;
10 
11 typedef std::function<std::pair<bool, bool>(Cppyy::TCppObject_t, Cppyy::TCppType_t)> MemHook_t;
12 
14 private:
16 
17 public:
19 
20 // callback from C++-side frameworks
21  static bool RecursiveRemove(Cppyy::TCppObject_t cppobj, Cppyy::TCppType_t klass);
22 
23 // called when a new python proxy object is created
24  static bool RegisterPyObject(CPPInstance* pyobj, void* cppobj);
25 
26 // called when a the python proxy object is about to be garbage collected or when it is
27 // about to delete the proxied C++ object, if owned
28  static bool UnregisterPyObject(CPPInstance* pyobj, PyObject* pyclass);
29 
30 // new reference to python object matching cppobj, or 0 on failure
31  static PyObject* RetrievePyObject(Cppyy::TCppObject_t cppobj, PyObject* pyclass);
32 
33 // set hooks for custom memory regulation
36 };
37 
38 } // namespace CPyCppyy
39 
40 #endif // !CPYCPPYY_MEMORYREGULATOR_H
CPyCppyy
Definition: TPython.cxx:99
CPyCppyy::MemoryRegulator::SetUnregisterHook
static void SetUnregisterHook(MemHook_t h)
Definition: MemoryRegulator.h:35
CPyCppyy::MemoryRegulator
Definition: MemoryRegulator.h:13
CPyCppyy::MemoryRegulator::MemoryRegulator
MemoryRegulator()
Definition: MemoryRegulator.cxx:91
PyObject
_object PyObject
Definition: PyMethodBase.h:41
CPyCppyy::MemoryRegulator::RetrievePyObject
static PyObject * RetrievePyObject(Cppyy::TCppObject_t cppobj, PyObject *pyclass)
Definition: MemoryRegulator.cxx:229
CPyCppyy::CPPInstance
Definition: CPPInstance.h:26
CPyCppyy::MemoryRegulator::SetRegisterHook
static void SetRegisterHook(MemHook_t h)
Definition: MemoryRegulator.h:34
CPyCppyy::MemHook_t
std::function< std::pair< bool, bool >Cppyy::TCppObject_t, Cppyy::TCppType_t)> MemHook_t
Definition: MemoryRegulator.h:9
CPyCppyy::MemoryRegulator::registerHook
static MemHook_t registerHook
Definition: MemoryRegulator.h:15
CPyCppyy::MemoryRegulator::unregisterHook
static MemHook_t unregisterHook
Definition: MemoryRegulator.h:15
CPyCppyy::MemoryRegulator::RecursiveRemove
static bool RecursiveRemove(Cppyy::TCppObject_t cppobj, Cppyy::TCppType_t klass)
Definition: MemoryRegulator.cxx:99
h
#define h(i)
Definition: RSha256.hxx:106
Cppyy::TCppType_t
TCppScope_t TCppType_t
Definition: cpp_cppyy.h:19
Cppyy::TCppObject_t
void * TCppObject_t
Definition: cpp_cppyy.h:21
CPyCppyy::MemoryRegulator::UnregisterPyObject
static bool UnregisterPyObject(CPPInstance *pyobj, PyObject *pyclass)
Definition: MemoryRegulator.cxx:200
CPyCppyy::MemoryRegulator::RegisterPyObject
static bool RegisterPyObject(CPPInstance *pyobj, void *cppobj)
Definition: MemoryRegulator.cxx:173