Logo ROOT   6.16/01
Reference Guide
TMemoryRegulator.h
Go to the documentation of this file.
1// @(#)root/pyroot:$Id$
2// Author: Wim Lavrijsen, Apr 2004
3
4#ifndef PYROOT_TMEMORYREGULATOR_H
5#define PYROOT_TMEMORYREGULATOR_H
6
7// ROOT
8#include "TObject.h"
9
10// Standard
11#include <map>
12
13
14namespace PyROOT {
15
16/** Communicate object destruction across ROOT/CINT/PyROOT/
17 @author WLAV
18 @date 11/23/2004
19 @version 2.2
20 */
21
22 class ObjectProxy;
23
24 class TMemoryRegulator : public TObject {
25 public:
28
29 // callback for ROOT/CINT
30 virtual void RecursiveRemove( TObject* object );
31
32 // add a python object to the table of managed objects
33 static Bool_t RegisterObject( ObjectProxy* pyobj, TObject* object );
34
35 // remove a python object from the table of managed objects, w/o notification
36 static Bool_t UnregisterObject( TObject* object );
37
38 // new reference to python object corresponding to object, or 0 on failure
39 static PyObject* RetrieveObject( TObject* object, Cppyy::TCppType_t klass );
40
41 // callback when weak refs to managed objects are destroyed
43
44 private:
45 typedef std::map< TObject*, PyObject* > ObjectMap_t;
46 typedef std::map< PyObject*, ObjectMap_t::iterator > WeakRefMap_t;
47
50 };
51
52} // namespace PyROOT
53
54#endif // !PYROOT_TMEMORYREGULATOR_H
bool Bool_t
Definition: RtypesCore.h:59
_object PyObject
Definition: TPyArg.h:20
static Bool_t UnregisterObject(TObject *object)
stop tracking <object>, without notification
static Bool_t RegisterObject(ObjectProxy *pyobj, TObject *object)
start tracking <object> proxied by <pyobj>
virtual void RecursiveRemove(TObject *object)
Recursively remove this object from a list.
~TMemoryRegulator()
cleanup weakref cache
static ObjectMap_t * fgObjectTable
static PyObject * ObjectEraseCallback(PyObject *, PyObject *pyref)
std::map< PyObject *, ObjectMap_t::iterator > WeakRefMap_t
static PyObject * RetrieveObject(TObject *object, Cppyy::TCppType_t klass)
lookup <object>, return old proxy if tracked
static WeakRefMap_t * fgWeakRefTable
std::map< TObject *, PyObject * > ObjectMap_t
Mother of all ROOT objects.
Definition: TObject.h:37
TCppScope_t TCppType_t
Definition: Cppyy.h:16