MethodHolder.h

Go to the documentation of this file.
00001 // @(#)root/pyroot:$Id: MethodHolder.h 33356 2010-05-04 00:45:17Z wlav $
00002 // Author: Wim Lavrijsen, Apr 2004
00003 
00004 #ifndef PYROOT_TMETHODHOLDER_H
00005 #define PYROOT_TMETHODHOLDER_H
00006 
00007 // Bindings
00008 #include "Utility.h"
00009 #include "PyCallable.h"
00010 
00011 // ROOT
00012 #include "TClassRef.h"
00013 class TMethod;
00014 
00015 // Reflex
00016 #ifdef PYROOT_USE_REFLEX
00017 #include "Reflex/Scope.h"
00018 #include "Reflex/Member.h"
00019 #endif
00020 
00021 // CINT
00022 namespace Cint {
00023    class G__CallFunc;
00024    class G__ClassInfo;
00025 }
00026 using namespace Cint;
00027 
00028 // Standard
00029 #include <string>
00030 #include <vector>
00031 
00032 
00033 namespace PyROOT {
00034 
00035 /** Python side ROOT method
00036       @author  WLAV
00037       @date    05/06/2004
00038       @version 3.0
00039  */
00040 
00041    class TExecutor;
00042    class TConverter;
00043 
00044    template< class T, class M >
00045    class TMethodHolder : public PyCallable {
00046    public:
00047       TMethodHolder( const T& klass, const M& method );
00048       TMethodHolder( const TMethodHolder& );
00049       TMethodHolder& operator=( const TMethodHolder& );
00050       virtual ~TMethodHolder();
00051 
00052    public:
00053       virtual PyObject* GetSignature();
00054       virtual PyObject* GetPrototype();
00055       virtual Int_t GetPriority();
00056 
00057       virtual Int_t GetMaxArgs();
00058       virtual PyObject* GetArgSpec( Int_t iarg );
00059       virtual PyObject* GetArgDefault( Int_t iarg );
00060       virtual PyObject* GetScope();
00061 
00062       virtual PyCallable* Clone() { return new TMethodHolder( *this ); }
00063 
00064    public:
00065       virtual PyObject* operator()( ObjectProxy* self, PyObject* args, PyObject* kwds, Long_t = 0 );
00066 
00067       virtual Bool_t Initialize();
00068       virtual PyObject* FilterArgs( ObjectProxy*& self, PyObject* args, PyObject* kwds );
00069       virtual Bool_t SetMethodArgs( PyObject* args, Long_t user );
00070       virtual PyObject* Execute( void* self );
00071 
00072    protected:
00073       const M& GetMethod() { return fMethod; }
00074       const T& GetClass() { return fClass; }
00075       TExecutor* GetExecutor() { return fExecutor; }
00076       const std::string& GetSignatureString();
00077 
00078       virtual Bool_t InitExecutor_( TExecutor*& );
00079 
00080    private:
00081       void Copy_( const TMethodHolder& );
00082       void Destroy_() const;
00083 
00084       PyObject* CallFast( void* );
00085       PyObject* CallSafe( void* );
00086 
00087       Bool_t InitCallFunc_();
00088 
00089       void CreateSignature_();
00090       void SetPyError_( PyObject* msg );
00091 
00092    private:
00093    // representation
00094       M fMethod;
00095       T fClass;
00096       G__CallFunc* fMethodCall;
00097       TExecutor*   fExecutor;
00098 
00099       std::string fSignature;
00100 
00101    // call dispatch buffers
00102       std::vector< TConverter* > fConverters;
00103 
00104       std::vector< TParameter > fParameters;
00105       std::vector< void* >      fParamPtrs;
00106 
00107    // cached values
00108       Int_t        fArgsRequired;
00109       Long_t       fOffset;
00110 
00111    // admin
00112       Bool_t fIsInitialized;
00113    };
00114 
00115 } // namespace PyROOT
00116 
00117 #endif // !PYROOT_METHODHOLDER_H

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