00001 // @(#)root/pyroot:$Id: TPython.h 23159 2008-04-11 20:13:29Z wlav $ 00002 // Author: Wim Lavrijsen April 2004 00003 00004 #ifndef ROOT_TPython 00005 #define ROOT_TPython 00006 00007 ////////////////////////////////////////////////////////////////////////////// 00008 // // 00009 // TPython // 00010 // // 00011 // Access to the python interpreter and API onto PyROOT. // 00012 // // 00013 ////////////////////////////////////////////////////////////////////////////// 00014 00015 00016 // Bindings 00017 #include "TPyReturn.h" 00018 00019 // ROOT 00020 #ifndef ROOT_TObject 00021 #include "TObject.h" 00022 #endif 00023 00024 00025 class TPython { 00026 00027 private: 00028 static Bool_t Initialize(); 00029 00030 public: 00031 // load a python script as if it were a macro 00032 static void LoadMacro( const char* name ); 00033 00034 // execute a python stand-alone script, with argv CLI arguments 00035 static void ExecScript( const char* name, int argc = 0, const char** argv = 0 ); 00036 00037 // execute a python statement (e.g. "import ROOT" ) 00038 static Bool_t Exec( const char* cmd ); 00039 00040 // evaluate a python expression (e.g. "1+1") 00041 static const TPyReturn Eval( const char* expr ); 00042 00043 // bind a ROOT object with, at the python side, the name "label" 00044 static Bool_t Bind( TObject* object, const char* label ); 00045 00046 // enter an interactive python session (exit with ^D) 00047 static void Prompt(); 00048 00049 // type verifiers for ObjectProxy 00050 static Bool_t ObjectProxy_Check( PyObject* pyobject ); 00051 static Bool_t ObjectProxy_CheckExact( PyObject* pyobject ); 00052 00053 // object proxy to void* conversion 00054 static void* ObjectProxy_AsVoidPtr( PyObject* pyobject ); 00055 00056 // void* to object proxy conversion, returns a new reference 00057 static PyObject* ObjectProxy_FromVoidPtr( void* addr, const char* classname ); 00058 00059 virtual ~TPython() { } 00060 ClassDef(TPython,0) //Access to the python interpreter 00061 }; 00062 00063 #endif