PropertyProxy.h

Go to the documentation of this file.
00001 // @(#)root/pyroot:$Id: PropertyProxy.h 35563 2010-09-22 00:32:31Z wlav $
00002 // Author: Wim Lavrijsen, Jan 2005
00003 
00004 #ifndef PYROOT_PROPERTYPROXY_H
00005 #define PYROOT_PROPERTYPROXY_H
00006 
00007 // Bindings
00008 #include "Converters.h"
00009 
00010 // ROOT
00011 #include "DllImport.h"
00012 #include "TClassRef.h"
00013 class TDataMember;
00014 class TGlobal;
00015 
00016 // Reflex
00017 #ifdef PYROOT_USE_REFLEX
00018 #include "Reflex/Member.h"
00019 #endif
00020 
00021 // CINT
00022 #include "DataMbr.h"
00023 
00024 // Standard
00025 #include <string>
00026 
00027 
00028 namespace PyROOT {
00029 
00030 /** Proxy to ROOT data presented as python property
00031       @author  WLAV
00032       @date    02/12/2005
00033       @version 2.0
00034  */
00035 
00036    class ObjectProxy;
00037 
00038    class PropertyProxy {
00039    public:
00040       void Set( TDataMember* );
00041       void Set( TGlobal* );
00042 #ifdef PYROOT_USE_REFLEX
00043       void Set( const ROOT::Reflex::Member& );
00044 #endif
00045 
00046       std::string GetName() { return fName; }
00047       Long_t GetAddress( ObjectProxy* pyobj /* owner */ );
00048 
00049    public:               // public, as the python C-API works with C structs
00050       PyObject_HEAD
00051       Long_t       fOffset;
00052       Long_t       fProperty;
00053       TConverter*  fConverter;
00054       Int_t        fOwnerTagnum;   // TODO: wrap up ...
00055       std::string  fName;
00056       Int_t        fOwnerIsNamespace;
00057 
00058    private:              // private, as the python C-API will handle creation
00059       PropertyProxy() {}
00060    };
00061 
00062 
00063 //- property proxy type and type verification --------------------------------
00064    R__EXTERN PyTypeObject PropertyProxy_Type;
00065 
00066    template< typename T >
00067    inline Bool_t PropertyProxy_Check( T* object )
00068    {
00069       return object && PyObject_TypeCheck( object, &PropertyProxy_Type );
00070    }
00071 
00072    template< typename T >
00073    inline Bool_t PropertyProxy_CheckExact( T* object )
00074    {
00075       return object && Py_TYPE(object) == &PropertyProxy_Type;
00076    }
00077 
00078 //- creation -----------------------------------------------------------------
00079    template< class T >
00080    inline PropertyProxy* PropertyProxy_New( const T& dmi )
00081    {
00082       PropertyProxy* pyprop =
00083          (PropertyProxy*)PropertyProxy_Type.tp_new( &PropertyProxy_Type, 0, 0 );
00084       pyprop->Set( dmi );
00085       return pyprop;
00086    }
00087 
00088 } // namespace PyROOT
00089 
00090 #endif // !PYROOT_PROPERTYPROXY_H

Generated on Tue Jul 5 14:10:13 2011 for ROOT_528-00b_version by  doxygen 1.5.1