Logo ROOT   6.14/05
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 
14 namespace 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
42  static PyObject* ObjectEraseCallback( PyObject*, PyObject* pyref );
43 
44  private:
45  typedef std::map< TObject*, PyObject* > ObjectMap_t;
46  typedef std::map< PyObject*, ObjectMap_t::iterator > WeakRefMap_t;
47 
48  static ObjectMap_t* fgObjectTable;
49  static WeakRefMap_t* fgWeakRefTable;
50  };
51 
52 } // namespace PyROOT
53 
54 #endif // !PYROOT_TMEMORYREGULATOR_H
TCppScope_t TCppType_t
Definition: Cppyy.h:13
static PyObject * RetrieveObject(TObject *object, Cppyy::TCppType_t klass)
lookup <object>, return old proxy if tracked
std::map< TObject *, PyObject *> ObjectMap_t
virtual void RecursiveRemove(TObject *object)
Recursively remove this object from a list.
static Bool_t RegisterObject(ObjectProxy *pyobj, TObject *object)
start tracking <object> proxied by <pyobj>
static WeakRefMap_t * fgWeakRefTable
bool Bool_t
Definition: RtypesCore.h:59
~TMemoryRegulator()
cleanup weakref cache
static ObjectMap_t * fgObjectTable
static Bool_t UnregisterObject(TObject *object)
stop tracking <object>, without notification
static PyObject * ObjectEraseCallback(PyObject *, PyObject *pyref)
Mother of all ROOT objects.
Definition: TObject.h:37
std::map< PyObject *, ObjectMap_t::iterator > WeakRefMap_t
_object PyObject
Definition: TPyArg.h:20