Logo ROOT   6.10/09
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 #include "TObject.h"
21 
22 
23 class TPython {
24 
25 private:
26  static Bool_t Initialize();
27 
28 public:
29 // import a python module, making its classes available
30  static Bool_t Import( const char* name );
31 
32 // load a python script as if it were a macro
33  static void LoadMacro( const char* name );
34 
35 // execute a python stand-alone script, with argv CLI arguments
36  static void ExecScript( const char* name, int argc = 0, const char** argv = 0 );
37 
38 // execute a python statement (e.g. "import ROOT" )
39  static Bool_t Exec( const char* cmd );
40 
41 // evaluate a python expression (e.g. "1+1")
42  static const TPyReturn Eval( const char* expr );
43 
44 // bind a ROOT object with, at the python side, the name "label"
45  static Bool_t Bind( TObject* object, const char* label );
46 
47 // enter an interactive python session (exit with ^D)
48  static void Prompt();
49 
50 // type verifiers for ObjectProxy
51  static Bool_t ObjectProxy_Check( PyObject* pyobject );
52  static Bool_t ObjectProxy_CheckExact( PyObject* pyobject );
53 
54 // type verifiers for MethodProxy
55  static Bool_t MethodProxy_Check( PyObject* pyobject );
56  static Bool_t MethodProxy_CheckExact( PyObject* pyobject );
57 
58 // object proxy to void* conversion
59  static void* ObjectProxy_AsVoidPtr( PyObject* pyobject );
60 
61 // void* to object proxy conversion, returns a new reference
63  void* addr, const char* classname, Bool_t python_owns = kFALSE );
64 
65  virtual ~TPython() { }
66  ClassDef(TPython,0) //Access to the python interpreter
67 };
68 
69 #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
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:297
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
const Bool_t kFALSE
Definition: RtypesCore.h:92
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:65
static void * ObjectProxy_AsVoidPtr(PyObject *pyobject)
Extract the object pointer held by the ObjectProxy pyobject.
Definition: TPython.cxx:527
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:20