Logo ROOT   6.08/07
Reference Guide
TPython.h
Go to the documentation of this file.
1 // @(#)root/pyroot:$Id$
2 // Author: Wim Lavrijsen April 2004
3 
4 #ifndef ROOT_TPython
5 #define ROOT_TPython
6 
7 //////////////////////////////////////////////////////////////////////////////
8 // //
9 // TPython //
10 // //
11 // Access to the python interpreter and API onto PyROOT. //
12 // //
13 //////////////////////////////////////////////////////////////////////////////
14 
15 
16 // Bindings
17 #include "TPyReturn.h"
18 
19 // ROOT
20 #ifndef ROOT_TObject
21 #include "TObject.h"
22 #endif
23 
24 
25 class TPython {
26 
27 private:
28  static Bool_t Initialize();
29 
30 public:
31 // import a python module, making its classes available
32  static Bool_t Import( const char* name );
33 
34 // load a python script as if it were a macro
35  static void LoadMacro( const char* name );
36 
37 // execute a python stand-alone script, with argv CLI arguments
38  static void ExecScript( const char* name, int argc = 0, const char** argv = 0 );
39 
40 // execute a python statement (e.g. "import ROOT" )
41  static Bool_t Exec( const char* cmd );
42 
43 // evaluate a python expression (e.g. "1+1")
44  static const TPyReturn Eval( const char* expr );
45 
46 // bind a ROOT object with, at the python side, the name "label"
47  static Bool_t Bind( TObject* object, const char* label );
48 
49 // enter an interactive python session (exit with ^D)
50  static void Prompt();
51 
52 // type verifiers for ObjectProxy
53  static Bool_t ObjectProxy_Check( PyObject* pyobject );
54  static Bool_t ObjectProxy_CheckExact( PyObject* pyobject );
55 
56 // type verifiers for MethodProxy
57  static Bool_t MethodProxy_Check( PyObject* pyobject );
58  static Bool_t MethodProxy_CheckExact( PyObject* pyobject );
59 
60 // object proxy to void* conversion
61  static void* ObjectProxy_AsVoidPtr( PyObject* pyobject );
62 
63 // void* to object proxy conversion, returns a new reference
65  void* addr, const char* classname, Bool_t python_owns = kFALSE );
66 
67  virtual ~TPython() { }
68  ClassDef(TPython,0) //Access to the python interpreter
69 };
70 
71 #endif
static Bool_t Exec(const char *cmd)
Execute a python statement (e.g. "import ROOT").
Definition: TPython.cxx:353
static Bool_t MethodProxy_Check(PyObject *pyobject)
Test whether the type of the given pyobject is of MethodProxy type or any derived type...
Definition: TPython.cxx:501
static void LoadMacro(const char *name)
Execute the give python script as if it were a macro (effectively an execfile in main), and create Cling equivalents for any newly available python classes.
Definition: TPython.cxx:215
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
static Bool_t Initialize()
Definition: TPython.cxx:93
static Bool_t MethodProxy_CheckExact(PyObject *pyobject)
Test whether the type of the given pyobject is MethodProxy type.
Definition: TPython.cxx:514
static void Prompt()
Enter an interactive python session (exit with ^D).
Definition: TPython.cxx:460
#define ClassDef(name, id)
Definition: Rtypes.h:254
static const TPyReturn Eval(const char *expr)
Evaluate a python expression (e.g.
Definition: TPython.cxx:381
static PyObject * ObjectProxy_FromVoidPtr(void *addr, const char *classname, Bool_t python_owns=kFALSE)
Bind the addr to a python object of class defined by classname.
Definition: TPython.cxx:544
static Bool_t ObjectProxy_Check(PyObject *pyobject)
Test whether the type of the given pyobject is of ObjectProxy type or any derived type...
Definition: TPython.cxx:474
static Bool_t Import(const char *name)
Import the named python module and create Cling equivalents for its classes and methods.
Definition: TPython.cxx:150
static Bool_t ObjectProxy_CheckExact(PyObject *pyobject)
Test whether the type of the given pyobject is ObjectProxy type.
Definition: TPython.cxx:487
Mother of all ROOT objects.
Definition: TObject.h:37
static Bool_t Bind(TObject *object, const char *label)
Bind a ROOT object with, at the python side, the name "label".
Definition: TPython.cxx:434
virtual ~TPython()
Definition: TPython.h:67
static void * ObjectProxy_AsVoidPtr(PyObject *pyobject)
Extract the object pointer held by the ObjectProxy pyobject.
Definition: TPython.cxx:527
char name[80]
Definition: TGX11.cxx:109
static void ExecScript(const char *name, int argc=0, const char **argv=0)
Execute a python stand-alone script, with argv CLI arguments.
Definition: TPython.cxx:285
_object PyObject
Definition: TPyArg.h:22