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
TCppScope_t TCppType_t
Definition: cpp_cppyy.h:19
static bool RegisterPyObject(CPPInstance *pyobj, void *cppobj)
static MemHook_t unregisterHook
std::function< std::pair< bool, bool >Cppyy::TCppObject_t, Cppyy::TCppType_t)> MemHook_t
static bool RecursiveRemove(Cppyy::TCppObject_t cppobj, Cppyy::TCppType_t klass)
static bool UnregisterPyObject(CPPInstance *pyobj, PyObject *pyclass)
_object PyObject
Definition: PyMethodBase.h:41
#define h(i)
Definition: RSha256.hxx:106
static void SetRegisterHook(MemHook_t h)
static PyObject * RetrievePyObject(Cppyy::TCppObject_t cppobj, PyObject *pyclass)
void * TCppObject_t
Definition: cpp_cppyy.h:21
static MemHook_t registerHook
static void SetUnregisterHook(MemHook_t h)