Logo ROOT   6.10/09
Reference Guide
TPyArg.h
Go to the documentation of this file.
1 // @(#)root/pyroot:$Id$
2 // Author: Wim Lavrijsen Aug 2013
3 
4 #ifndef ROOT_TPyArg
5 #define ROOT_TPyArg
6 
7 //////////////////////////////////////////////////////////////////////////////
8 // //
9 // TPyArg //
10 // //
11 // Morphing argument type from evaluating python expressions. //
12 // //
13 //////////////////////////////////////////////////////////////////////////////
14 
15 
16 // ROOT
17 #include "Rtypes.h"
18 
19 // Python
20 struct _object;
21 typedef _object PyObject;
22 
23 // Standard
24 #include <vector>
25 
26 
27 class TPyArg {
28 public:
29 // converting constructors
30  TPyArg( PyObject* );
31  TPyArg( Int_t );
32  TPyArg( Long_t );
33  TPyArg( Double_t );
34  TPyArg( const char* );
35 
36  TPyArg( const TPyArg& );
37  TPyArg& operator=( const TPyArg& );
38  virtual ~TPyArg();
39 
40 // "extractor"
41  operator PyObject*() const;
42 
43 // constructor and generic dispatch
44  static void CallConstructor( PyObject*& pyself, PyObject* pyclass, const std::vector<TPyArg>& args );
45  static void CallConstructor( PyObject*& pyself, PyObject* pyclass ); // default ctor
46  static PyObject* CallMethod( PyObject* pymeth, const std::vector<TPyArg>& args );
47  static void CallDestructor( PyObject*& pyself, PyObject* pymeth, const std::vector<TPyArg>& args );
48  static void CallDestructor( PyObject*& pyself );
49 
50  ClassDef(TPyArg,1) //Python morphing argument type
51 
52 private:
53  mutable PyObject* fPyObject; //! converted C++ value as python object
54 };
55 
56 #endif
TPyArg & operator=(const TPyArg &)
Assignment operator.
Definition: TPyArg.cxx:117
TPyArg(PyObject *)
Definition: TPyArg.cxx:66
int Int_t
Definition: RtypesCore.h:41
static PyObject * CallMethod(PyObject *pymeth, const std::vector< TPyArg > &args)
Definition: TPyArg.cxx:42
#define ClassDef(name, id)
Definition: Rtypes.h:297
Definition: TPyArg.h:27
static void CallConstructor(PyObject *&pyself, PyObject *pyclass, const std::vector< TPyArg > &args)
Definition: TPyArg.cxx:23
static void CallDestructor(PyObject *&pyself, PyObject *pymeth, const std::vector< TPyArg > &args)
Definition: TPyArg.cxx:54
virtual ~TPyArg()
Done with held PyObject.
Definition: TPyArg.cxx:129
long Long_t
Definition: RtypesCore.h:50
PyObject * fPyObject
Definition: TPyArg.h:53
double Double_t
Definition: RtypesCore.h:55
_object PyObject
Definition: TPyArg.h:20