TMethodCall.h

Go to the documentation of this file.
00001 // @(#)root/meta:$Id: TMethodCall.h 24077 2008-05-31 19:39:09Z brun $
00002 // Author: Fons Rademakers   13/06/96
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TMethodCall
00013 #define ROOT_TMethodCall
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TMethodCall                                                          //
00019 //                                                                      //
00020 // Method or function calling interface. Objects of this class contain  //
00021 // the (CINT) environment to call a global function or a method for an  //
00022 // object of a specific class with the desired arguments. This class is //
00023 // espicially useful when a method has to be called more times for      //
00024 // different objects and/or with different arguments. If a function or  //
00025 // method needs to be called only once one better uses                  //
00026 // TInterpreter::Execute().                                             //
00027 //                                                                      //
00028 //////////////////////////////////////////////////////////////////////////
00029 
00030 #ifndef ROOT_TDictionary
00031 #include "TDictionary.h"
00032 #endif
00033 
00034 class TClass;
00035 class TFunction;
00036 
00037 class TMethodCall : public TObject {
00038 
00039 public:
00040    enum EReturnType { kLong, kDouble, kString, kOther, kNone };
00041 
00042 private:
00043    CallFunc_t    *fFunc;      //CINT method invocation environment
00044    Long_t         fOffset;    //offset added to object pointer before method invocation
00045    TClass        *fClass;     //pointer to the class info
00046    TFunction     *fMetPtr;    //pointer to the method or function info
00047    TString        fMethod;    //method name
00048    TString        fParams;    //argument string
00049    TString        fProto;     //prototype string
00050    Bool_t         fDtorOnly;  //call only dtor and not delete when calling ~xxx
00051    EReturnType    fRetType;   //method return type
00052 
00053    void Execute(const char *,  const char *, int * /*error*/ = 0) { }    // versions of TObject
00054    void Execute(TMethod *, TObjArray *, int * /*error*/ = 0) { }
00055 
00056    void InitImplementation(const char *methodname, const char *params, const char *proto, TClass *cl, const ClassInfo_t *cinfo);
00057 
00058 public:
00059    TMethodCall();
00060    TMethodCall(TClass *cl, const char *method, const char *params);
00061    TMethodCall(const char *function, const char *params);
00062    TMethodCall(const TMethodCall &org);
00063    TMethodCall& operator=(const TMethodCall &rhs);
00064    ~TMethodCall();
00065 
00066    void           Init(TClass *cl, const char *method, const char *params);
00067    void           Init(const char *function, const char *params);
00068    void           InitWithPrototype(TClass *cl, const char *method, const char *proto);
00069    void           InitWithPrototype(const char *function, const char *proto);
00070    Bool_t         IsValid() const;
00071    TObject       *Clone(const char *newname="") const;
00072    void           CallDtorOnly(Bool_t set = kTRUE) { fDtorOnly = set; }
00073 
00074    TFunction     *GetMethod();
00075    const char    *GetMethodName() const { return fMethod.Data(); }
00076    const char    *GetParams() const { return fParams.Data(); }
00077    const char    *GetProto() const { return fProto.Data(); }
00078    EReturnType    ReturnType();
00079 
00080    void     SetParamPtrs(void *paramArr, Int_t nparam = -1);
00081    void     ResetParam();
00082    void     SetParam(Long_t l);
00083    void     SetParam(Double_t d);
00084    void     SetParam(Long64_t ll);
00085    void     SetParam(ULong64_t ull);
00086 
00087    void     Execute(void *object);
00088    void     Execute(void *object, const char *params);
00089    void     Execute(void *object, Long_t &retLong);
00090    void     Execute(void *object, const char *params, Long_t &retLong);
00091    void     Execute(void *object, Double_t &retDouble);
00092    void     Execute(void *object, const char *params, Double_t &retDouble);
00093 
00094    void     Execute(void *object, char **retText);
00095    void     Execute(void *object, const char *params, char **retText);
00096 
00097    void     Execute();
00098    void     Execute(const char *params);
00099    void     Execute(Long_t &retLong);
00100    void     Execute(const char *params, Long_t &retLong);
00101    void     Execute(Double_t &retDouble);
00102    void     Execute(const char *params, Double_t &retDouble);
00103 
00104    ClassDef(TMethodCall,0)  //Method calling interface
00105 };
00106 
00107 inline void TMethodCall::Execute()
00108    { Execute((void *)0); }
00109 inline void TMethodCall::Execute(const char *params)
00110    { Execute((void *)0, params); }
00111 inline void TMethodCall::Execute(Long_t &retLong)
00112    { Execute((void *)0, retLong); }
00113 inline void TMethodCall::Execute(const char *params, Long_t &retLong)
00114    { Execute((void *)0, params, retLong); }
00115 inline void TMethodCall::Execute(Double_t &retDouble)
00116    { Execute((void *)0, retDouble); }
00117 inline void TMethodCall::Execute(const char *params, Double_t &retDouble)
00118    { Execute((void *)0, params, retDouble); }
00119 
00120 #endif

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