Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPyArg.h
Go to the documentation of this file.
1// Author: Enric Tejedor CERN 08/2019
2// Original PyROOT code by Wim Lavrijsen, LBL
3//
4// /*************************************************************************
5// * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6// * All rights reserved. *
7// * *
8// * For the licensing terms see $ROOTSYS/LICENSE. *
9// * For the list of contributors see $ROOTSYS/README/CREDITS. *
10// *************************************************************************/
11
12#ifndef ROOT_TPyArg
13#define ROOT_TPyArg
14
15// ROOT
16#include "Rtypes.h"
17
18// Python
19struct _object;
20typedef _object PyObject;
21
22// Standard
23#include <vector>
24
25/// Morphing argument type from evaluating python expressions.
26class TPyArg {
27public:
28 // converting constructors
33 TPyArg(const char *);
34
35 TPyArg(const TPyArg &);
36 TPyArg &operator=(const TPyArg &);
37 virtual ~TPyArg();
38
39 // "extractor"
40 operator PyObject *() const;
41
42 // constructor and generic dispatch
43 static void CallConstructor(PyObject *&pyself, PyObject *pyclass, const std::vector<TPyArg> &args);
44 static void CallConstructor(PyObject *&pyself, PyObject *pyclass); // default ctor
45 static PyObject *CallMethod(PyObject *pymeth, const std::vector<TPyArg> &args);
46 static void CallDestructor(PyObject *&pyself, PyObject *pymeth, const std::vector<TPyArg> &args);
47 static void CallDestructor(PyObject *&pyself);
48
49 ClassDef(TPyArg, 1) // Python morphing argument type
50
52 mutable PyObject *fPyObject; //! converted C++ value as python object
53};
54
55#endif
long Long_t
Definition RtypesCore.h:54
#define ClassDef(name, id)
Definition Rtypes.h:342
Morphing argument type from evaluating python expressions.
Definition TPyArg.h:26
static PyObject * CallMethod(PyObject *pymeth, const std::vector< TPyArg > &args)
Definition TPyArg.cxx:62
static void CallDestructor(PyObject *&pyself, PyObject *pymeth, const std::vector< TPyArg > &args)
Definition TPyArg.cxx:76
PyObject * fPyObject
Definition TPyArg.h:52
TPyArg(PyObject *)
Definition TPyArg.cxx:92
static void CallConstructor(PyObject *&pyself, PyObject *pyclass)
TPyArg & operator=(const TPyArg &)
Assignment operator.
Definition TPyArg.cxx:155
virtual ~TPyArg()
Done with held PyObject.
Definition TPyArg.cxx:169
static void CallConstructor(PyObject *&pyself, PyObject *pyclass, const std::vector< TPyArg > &args)
Definition TPyArg.cxx:39
_object PyObject
Definition TPyArg.h:14