Logo ROOT  
Reference Guide
PropertyProxy.h
Go to the documentation of this file.
1// @(#)root/pyroot:$Id$
2// Author: Wim Lavrijsen, Jan 2005
3
4#ifndef PYROOT_PROPERTYPROXY_H
5#define PYROOT_PROPERTYPROXY_H
6
7// Bindings
8#include "Converters.h"
9
10// ROOT
11#include "DllImport.h"
12#include "TClassRef.h"
13class TDataMember;
14class TEnumConstant;
15class TGlobal;
16
17// Standard
18#include <string>
19
20
21namespace PyROOT {
22
23 class ObjectProxy;
24
26 public:
27 void Set( Cppyy::TCppScope_t scope, Cppyy::TCppIndex_t idata );
28 void Set( Cppyy::TCppScope_t scope, const std::string& name, void* address, TEnum* en );
29
30 std::string GetName() { return fName; }
31 void* GetAddress( ObjectProxy* pyobj /* owner */ );
32
33 public: // public, as the python C-API works with C structs
34 PyObject_HEAD
35 ptrdiff_t fOffset;
39 std::string fName;
40
41 private: // private, as the python C-API will handle creation
43 };
44
45
46//- property proxy type and type verification --------------------------------
47 R__EXTERN PyTypeObject PropertyProxy_Type;
48
49 template< typename T >
50 inline Bool_t PropertyProxy_Check( T* object )
51 {
52 return object && PyObject_TypeCheck( object, &PropertyProxy_Type );
53 }
54
55 template< typename T >
57 {
58 return object && Py_TYPE(object) == &PropertyProxy_Type;
59 }
60
61//- creation -----------------------------------------------------------------
64 {
65 // Create an initialize a new property descriptor, given the C++ datum.
66 PropertyProxy* pyprop =
68 pyprop->Set( scope, idata );
69 return pyprop;
70 }
71
73 Cppyy::TCppScope_t scope, const std::string& name, void* address, TEnum* en )
74 {
75 // Create an initialize a new property descriptor, given the C++ datum.
76 PropertyProxy* pyprop =
78 pyprop->Set( scope, name, address, en );
79 return pyprop;
80 }
81
82} // namespace PyROOT
83
84#endif // !PYROOT_PROPERTYPROXY_H
#define R__EXTERN
Definition: DllImport.h:27
#define Py_TYPE(ob)
Definition: PyROOT.h:166
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
char name[80]
Definition: TGX11.cxx:109
TConverter * fConverter
Definition: PropertyProxy.h:37
std::string GetName()
Definition: PropertyProxy.h:30
PyObject_HEAD ptrdiff_t fOffset
Definition: PropertyProxy.h:35
void Set(Cppyy::TCppScope_t scope, Cppyy::TCppIndex_t idata)
Cppyy::TCppScope_t fEnclosingScope
Definition: PropertyProxy.h:38
void * GetAddress(ObjectProxy *pyobj)
class attributes, global properties
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:31
The TEnumConstant class implements the constants of the enum type.
Definition: TEnumConstant.h:29
The TEnum class implements the enum type.
Definition: TEnum.h:33
Global variables class (global variables are obtained from CINT).
Definition: TGlobal.h:28
ptrdiff_t TCppScope_t
Definition: Cppyy.h:15
Long_t TCppIndex_t
Definition: Cppyy.h:21
PropertyProxy * PropertyProxy_NewConstant(Cppyy::TCppScope_t scope, const std::string &name, void *address, TEnum *en)
Definition: PropertyProxy.h:72
PropertyProxy * PropertyProxy_New(Cppyy::TCppScope_t scope, Cppyy::TCppIndex_t idata)
Definition: PropertyProxy.h:62
Bool_t PropertyProxy_CheckExact(T *object)
Definition: PropertyProxy.h:56
Bool_t PropertyProxy_Check(T *object)
Definition: PropertyProxy.h:50
PyTypeObject PropertyProxy_Type
double T(double x)
Definition: ChebyshevPol.h:34