Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMethodCall.h
Go to the documentation of this file.
1// @(#)root/meta:$Id$
2// Author: Fons Rademakers 13/06/96
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TMethodCall
13#define ROOT_TMethodCall
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TMethodCall //
19// //
20// Method or function calling interface. Objects of this class contain //
21// the (CINT) environment to call a global function or a method for an //
22// object of a specific class with the desired arguments. This class is //
23// espicially useful when a method has to be called more times for //
24// different objects and/or with different arguments. If a function or //
25// method needs to be called only once one better uses //
26// TInterpreter::Execute(). //
27// //
28//////////////////////////////////////////////////////////////////////////
29
30#include "TObject.h"
31
32#include "TInterpreter.h"
33
34class TClass;
35class TFunction;
36
37class TMethodCall : public TObject {
38
39public:
41
42 // For backward compatibility:
48 // Historical name.
50
51 // enum EReturnType { kLong, kDouble, kString, kOther, kNone };
52
53private:
54 CallFunc_t *fFunc; //CINT method invocation environment
55 Longptr_t fOffset; //offset added to object pointer before method invocation
56 TClass *fClass; //pointer to the class info
57 TFunction *fMetPtr; //pointer to the method or function info
58 TString fMethod; //method name
59 TString fParams; //argument string
60 TString fProto; //prototype string
61 Bool_t fDtorOnly; //call only dtor and not delete when calling ~xxx
62 EReturnType fRetType; //method return type
63
64 void Execute(const char *, const char *, int * /*error*/ = nullptr) override { } // versions of TObject
65 void Execute(TMethod *, TObjArray *, int * /*error*/ = nullptr) override { }
66
67 void InitImplementation(const char *methodname, const char *params, const char *proto, Bool_t objectIsConst, TClass *cl, const ClassInfo_t *cinfo, ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch);
68
69public:
71 TMethodCall(TClass *cl, CallFunc_t *callfunc, Longptr_t offset = 0);
72 TMethodCall(TClass *cl, const char *method, const char *params);
73 TMethodCall(const char *function, const char *params);
74 TMethodCall(const TFunction *func);
78
79 void Init(const TFunction *func);
80 void Init(TClass *cl, CallFunc_t *func, Longptr_t offset = 0);
81 void Init(TClass *cl, const char *method, const char *params, Bool_t objectIsConst = kFALSE);
82 void Init(const char *function, const char *params);
83 void InitWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst = kFALSE, ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch);
84 void InitWithPrototype(const char *function, const char *proto, ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch);
85 Bool_t IsValid() const;
86 TObject *Clone(const char *newname="") const override;
87 void CallDtorOnly(Bool_t set = kTRUE) { fDtorOnly = set; }
88
90 const char *GetMethodName() const { return fMethod.Data(); }
91 const char *GetParams() const { return fParams.Data(); }
92 const char *GetProto() const { return fProto.Data(); }
93 CallFunc_t *GetCallFunc() const { return fFunc; }
95
96 void SetParamPtrs(void *paramArr, Int_t nparam = -1);
97 void ResetParam();
98 void SetParam(Long_t l);
99 void SetParam(Float_t f);
100 void SetParam(Double_t d);
101 void SetParam(Long64_t ll);
102 void SetParam(ULong64_t ull);
103
104 template <typename... T> void SetParams(const T&... params) {
105 if (!fFunc) return;
106 gInterpreter->CallFunc_SetArguments(fFunc,params...);
107 }
108
109 void Execute(void *object);
110 void Execute(void *object, const char *params);
111 void Execute(void *object, Longptr_t &retLong);
112 void Execute(void *object, const char *params, Longptr_t &retLong);
113 void Execute(void *object, Double_t &retDouble);
114 void Execute(void *object, const char *params, Double_t &retDouble);
115
116 void Execute(void *object, char **retText);
117 void Execute(void *object, const char *params, char **retText);
118
119 void Execute();
120 void Execute(const char *params);
121 void Execute(Longptr_t &retLong);
122 void Execute(const char *params, Longptr_t &retLong);
123 void Execute(Double_t &retDouble);
124 void Execute(const char *params, Double_t &retDouble);
125
126 void Execute(void *objAddress, const void* args[], int nargs, void *ret = nullptr);
127
128 ClassDefOverride(TMethodCall,0) //Method calling interface
129};
130
132 { Execute((void *)0); }
133inline void TMethodCall::Execute(const char *params)
134 { Execute((void *)0, params); }
135inline void TMethodCall::Execute(Longptr_t &retLong)
136 { Execute((void *)0, retLong); }
137inline void TMethodCall::Execute(const char *params, Longptr_t &retLong)
138 { Execute((void *)0, params, retLong); }
139inline void TMethodCall::Execute(Double_t &retDouble)
140 { Execute((void *)0, retDouble); }
141inline void TMethodCall::Execute(const char *params, Double_t &retDouble)
142 { Execute((void *)0, params, retDouble); }
143
144#endif
#define d(i)
Definition RSha256.hxx:102
#define f(i)
Definition RSha256.hxx:104
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
long Long_t
Definition RtypesCore.h:54
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
unsigned long long ULong64_t
Definition RtypesCore.h:81
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char mode
#define gInterpreter
const char * proto
Definition civetweb.c:17502
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Global functions class (global functions are obtained from CINT).
Definition TFunction.h:30
Method or function calling interface.
Definition TMethodCall.h:37
EReturnType ReturnType()
Returns the return type of the method.
TMethodCall()
Default TMethodCall ctor.
void CallDtorOnly(Bool_t set=kTRUE)
Definition TMethodCall.h:87
TFunction * fMetPtr
Definition TMethodCall.h:57
TMethodCall & operator=(const TMethodCall &rhs)
Assignment operator.
~TMethodCall()
TMethodCall dtor.
Bool_t fDtorOnly
Definition TMethodCall.h:61
static const EReturnType kLong
Definition TMethodCall.h:43
TString fParams
Definition TMethodCall.h:59
const char * GetMethodName() const
Definition TMethodCall.h:90
EReturnType fRetType
Definition TMethodCall.h:62
static const EReturnType kNoReturnType
Definition TMethodCall.h:47
static const EReturnType kString
Definition TMethodCall.h:45
void Execute(TMethod *, TObjArray *, int *=nullptr) override
Execute method on this object with parameters stored in the TObjArray.
Definition TMethodCall.h:65
void ResetParam()
Reset parameter list. To be used before the first call the SetParam().
TObject * Clone(const char *newname="") const override
Return an exact copy of this object.
Longptr_t fOffset
Definition TMethodCall.h:55
static const EReturnType kOther
Definition TMethodCall.h:46
const char * GetParams() const
Definition TMethodCall.h:91
CallFunc_t * GetCallFunc() const
Definition TMethodCall.h:93
CallFunc_t * fFunc
Definition TMethodCall.h:54
TClass * fClass
Definition TMethodCall.h:56
TFunction * GetMethod()
Returns the TMethod describing the method to be executed.
const char * GetProto() const
Definition TMethodCall.h:92
static const EReturnType kNone
Definition TMethodCall.h:49
void Execute(const char *, const char *, int *=nullptr) override
Execute method on this object with the given parameter string, e.g.
Definition TMethodCall.h:64
void Init(const TFunction *func)
Initialize the method invocation environment based on the TFunction object.
void InitImplementation(const char *methodname, const char *params, const char *proto, Bool_t objectIsConst, TClass *cl, const ClassInfo_t *cinfo, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
This function implements Init and InitWithPrototype.
TInterpreter::EReturnType EReturnType
Definition TMethodCall.h:40
Bool_t IsValid() const
Return true if the method call has been properly initialized and is usable.
void SetParams(const T &... params)
TString fProto
Definition TMethodCall.h:60
void InitWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Initialize the method invocation environment.
static const EReturnType kDouble
Definition TMethodCall.h:44
void Execute()
void SetParam(Long_t l)
Add a long method parameter.
void SetParamPtrs(void *paramArr, Int_t nparam=-1)
ParamArr is an array containing the function argument values.
TString fMethod
Definition TMethodCall.h:58
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:380
EFunctionMatchMode
@ kConversionMatch
TLine l
Definition textangle.C:4
#define org(otri, vertexptr)
Definition triangle.c:1038