Logo ROOT   6.08/07
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"
13 class TDataMember;
14 class TEnumConstant;
15 class TGlobal;
16 
17 // Standard
18 #include <string>
19 
20 
21 namespace PyROOT {
22 
23  class ObjectProxy;
24 
25  class PropertyProxy {
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 );
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 >
56  inline Bool_t PropertyProxy_CheckExact( T* object )
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 =
67  (PropertyProxy*)PropertyProxy_Type.tp_new( &PropertyProxy_Type, 0, 0 );
68  pyprop->Set( scope, idata );
69  return pyprop;
70  }
71 
73  Cppyy::TCppScope_t scope, const std::string& name, void* address )
74  {
75  // Create an initialize a new property descriptor, given the C++ datum.
76  PropertyProxy* pyprop =
77  (PropertyProxy*)PropertyProxy_Type.tp_new( &PropertyProxy_Type, 0, 0 );
78  pyprop->Set( scope, name, address );
79  return pyprop;
80  }
81 
82 } // namespace PyROOT
83 
84 #endif // !PYROOT_PROPERTYPROXY_H
TConverter * fConverter
Definition: PropertyProxy.h:37
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:33
double T(double x)
Definition: ChebyshevPol.h:34
PyTypeObject PropertyProxy_Type
bool Bool_t
Definition: RtypesCore.h:59
void * GetAddress(ObjectProxy *pyobj)
class attributes, global properties
PropertyProxy * PropertyProxy_NewConstant(Cppyy::TCppScope_t scope, const std::string &name, void *address)
Definition: PropertyProxy.h:72
Bool_t PropertyProxy_Check(T *object)
Definition: PropertyProxy.h:50
The TEnumConstant class implements the constants of the enum type.
Definition: TEnumConstant.h:33
Global variables class (global variables are obtained from CINT).
Definition: TGlobal.h:29
void Set(Cppyy::TCppScope_t scope, Cppyy::TCppIndex_t idata)
long Long_t
Definition: RtypesCore.h:50
PyObject_HEAD ptrdiff_t fOffset
Definition: PropertyProxy.h:35
#define R__EXTERN
Definition: DllImport.h:27
#define Py_TYPE(ob)
Definition: PyROOT.h:151
Long_t TCppIndex_t
Definition: Cppyy.h:17
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
Cppyy::TCppScope_t fEnclosingScope
Definition: PropertyProxy.h:38
ptrdiff_t TCppScope_t
Definition: Cppyy.h:12
std::string GetName()
Definition: PropertyProxy.h:30
char name[80]
Definition: TGX11.cxx:109