Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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
62  static PyObject* ObjectProxy_FromVoidPtr(
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