Logo ROOT   6.18/05
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
20struct _object;
21typedef _object PyObject;
22
23// Standard
24#include <vector>
25
26
27class TPyArg {
28public:
29// converting constructors
30 TPyArg( PyObject* );
31 TPyArg( Int_t );
32 TPyArg( Long_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
52private:
53 mutable PyObject* fPyObject; //! converted C++ value as python object
54};
55
56#endif
int Int_t
Definition: RtypesCore.h:41
long Long_t
Definition: RtypesCore.h:50
double Double_t
Definition: RtypesCore.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:326
_object PyObject
Definition: TPyArg.h:20
Definition: TPyArg.h:27
static PyObject * CallMethod(PyObject *pymeth, const std::vector< TPyArg > &args)
Definition: TPyArg.cxx:42
PyObject * fPyObject
Definition: TPyArg.h:53
static void CallDestructor(PyObject *&pyself, PyObject *pymeth, const std::vector< TPyArg > &args)
Definition: TPyArg.cxx:54
TPyArg(PyObject *)
Definition: TPyArg.cxx:66
static void CallConstructor(PyObject *&pyself, PyObject *pyclass)
TPyArg & operator=(const TPyArg &)
Assignment operator.
Definition: TPyArg.cxx:117
virtual ~TPyArg()
Done with held PyObject.
Definition: TPyArg.cxx:129
static void CallConstructor(PyObject *&pyself, PyObject *pyclass, const std::vector< TPyArg > &args)
Definition: TPyArg.cxx:23