Method or function calling interface.
Objects of this class contain the (CINT) environment to call a global function or a method for an object of a specific class with the desired arguments. This class is especially useful when a method has to be called more times for different objects and/or with different arguments. If a function or method needs to be called only once one better uses TInterpreter::Execute().
Definition at line 37 of file TMethodCall.h.
Public Types | |
using | EReturnType = TInterpreter::EReturnType |
Public Types inherited from TObject | |
enum | { kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 , kBitMask = 0x00ffffff } |
enum | { kSingleKey = BIT(0) , kOverwrite = BIT(1) , kWriteDelete = BIT(2) } |
enum | EDeprecatedStatusBits { kObjInCanvas = BIT(3) } |
enum | EStatusBits { kCanDelete = BIT(0) , kMustCleanup = BIT(3) , kIsReferenced = BIT(4) , kHasUUID = BIT(5) , kCannotPick = BIT(6) , kNoContextMenu = BIT(8) , kInvalidObject = BIT(13) } |
Public Member Functions | |
TMethodCall () | |
Default TMethodCall ctor. | |
TMethodCall (const char *function, const char *params) | |
Create a global function invocation environment. | |
TMethodCall (const TFunction *func) | |
Create a global function invocation environment base on a TFunction object. | |
TMethodCall (const TMethodCall &org) | |
Copy ctor. | |
TMethodCall (TClass *cl, CallFunc_t *callfunc, Long_t offset=0) | |
Create a method invocation environment for a specific class, method described by the callfunc. | |
TMethodCall (TClass *cl, const char *method, const char *params) | |
Create a method invocation environment for a specific class, method and parameters. | |
~TMethodCall () | |
TMethodCall dtor. | |
void | CallDtorOnly (Bool_t set=kTRUE) |
TObject * | Clone (const char *newname="") const |
Return an exact copy of this object. | |
void | Execute () |
void | Execute (const char *params) |
void | Execute (const char *params, Double_t &retDouble) |
void | Execute (const char *params, Long_t &retLong) |
void | Execute (Double_t &retDouble) |
void | Execute (Long_t &retLong) |
void | Execute (void *objAddress, const void *args[], int nargs, void *ret=0) |
Invoke the method. | |
void | Execute (void *object) |
Execute the method (with preset arguments) for the specified object. | |
void | Execute (void *object, char **retText) |
Execute the method (with preset arguments) for the specified object. | |
void | Execute (void *object, const char *params) |
Execute the method for the specified object and argument values. | |
void | Execute (void *object, const char *params, char **retText) |
Execute the method for the specified object and argument values. | |
void | Execute (void *object, const char *params, Double_t &retDouble) |
Execute the method for the specified object and argument values. | |
void | Execute (void *object, const char *params, Long_t &retLong) |
Execute the method for the specified object and argument values. | |
void | Execute (void *object, Double_t &retDouble) |
Execute the method (with preset arguments) for the specified object. | |
void | Execute (void *object, Long_t &retLong) |
Execute the method (with preset arguments) for the specified object. | |
CallFunc_t * | GetCallFunc () const |
TFunction * | GetMethod () |
Returns the TMethod describing the method to be executed. | |
const char * | GetMethodName () const |
const char * | GetParams () const |
const char * | GetProto () const |
void | Init (const char *function, const char *params) |
Initialize the function invocation environment. | |
void | Init (const TFunction *func) |
Initialize the method invocation environment based on the TFunction object. | |
void | Init (TClass *cl, CallFunc_t *func, Long_t offset=0) |
Initialize the method invocation environment based on the CallFunc object and the TClass describing the function context. | |
void | Init (TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE) |
Initialize the method invocation environment. | |
void | InitWithPrototype (const char *function, const char *proto, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) |
Initialize the function invocation environment. | |
void | InitWithPrototype (TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) |
Initialize the method invocation environment. | |
Bool_t | IsValid () const |
Return true if the method call has been properly initialized and is usable. | |
TMethodCall & | operator= (const TMethodCall &rhs) |
Assignment operator. | |
void | ResetParam () |
Reset parameter list. To be used before the first call the SetParam(). | |
EReturnType | ReturnType () |
Returns the return type of the method. | |
void | SetParam (Double_t d) |
Add a double method parameter. | |
void | SetParam (Float_t f) |
Add a double method parameter. | |
void | SetParam (Long64_t ll) |
Add a long long method parameter. | |
void | SetParam (Long_t l) |
Add a long method parameter. | |
void | SetParam (ULong64_t ull) |
Add a unsigned long long method parameter. | |
void | SetParamPtrs (void *paramArr, Int_t nparam=-1) |
ParamArr is an array containing the function argument values. | |
template<typename... T> | |
void | SetParams (const T &... params) |
Public Member Functions inherited from TObject | |
TObject () | |
TObject constructor. | |
TObject (const TObject &object) | |
TObject copy ctor. | |
virtual | ~TObject () |
TObject destructor. | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. | |
ULong_t | CheckedHash () |
Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object. | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. | |
virtual void | Clear (Option_t *="") |
virtual Int_t | Compare (const TObject *obj) const |
Compare abstract method. | |
virtual void | Copy (TObject &object) const |
Copy this to obj. | |
virtual void | Delete (Option_t *option="") |
Delete this object. | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad) . | |
virtual void | Dump () const |
Dump contents of object on stdout. | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. | |
virtual const char * | GetIconName () const |
Returns mime type name of object. | |
virtual const char * | GetName () const |
Returns name of object. | |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). | |
virtual Option_t * | GetOption () const |
virtual const char * | GetTitle () const |
Returns title of object. | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. | |
virtual ULong_t | Hash () const |
Return hash value for this object. | |
Bool_t | HasInconsistentHash () const |
Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e. | |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. | |
void | InvertBit (UInt_t f) |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). | |
R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
virtual Bool_t | IsSortable () const |
R__ALWAYS_INLINE Bool_t | IsZombie () const |
virtual void | ls (Option_t *option="") const |
The ls function lists the contents of a class on stdout. | |
void | MayNotUse (const char *method) const |
Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). | |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. | |
void | operator delete (void *ptr) |
Operator delete. | |
void | operator delete[] (void *ptr) |
Operator delete []. | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (const TObject &rhs) |
TObject assignment operator. | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. | |
virtual void | Print (Option_t *option="") const |
This method must be overridden when a class wants to print itself. | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove this object from a list. | |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". | |
void | SetBit (UInt_t f) |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. | |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. | |
R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
virtual void | UseCurrentStyle () |
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. | |
Static Public Attributes | |
static const EReturnType | kDouble = TInterpreter::EReturnType::kDouble |
static const EReturnType | kLong = TInterpreter::EReturnType::kLong |
static const EReturnType | kNone = TInterpreter::EReturnType::kNoReturnType |
static const EReturnType | kNoReturnType = TInterpreter::EReturnType::kNoReturnType |
static const EReturnType | kOther = TInterpreter::EReturnType::kOther |
static const EReturnType | kString = TInterpreter::EReturnType::kString |
Private Member Functions | |
void | Execute (const char *, const char *, int *=0) |
Execute method on this object with the given parameter string, e.g. | |
void | Execute (TMethod *, TObjArray *, int *=0) |
Execute method on this object with parameters stored in the TObjArray. | |
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. | |
Private Attributes | |
TClass * | fClass |
Bool_t | fDtorOnly |
CallFunc_t * | fFunc |
TString | fMethod |
TFunction * | fMetPtr |
Long_t | fOffset |
TString | fParams |
TString | fProto |
EReturnType | fRetType |
Additional Inherited Members | |
Static Public Member Functions inherited from TObject | |
static Long_t | GetDtorOnly () |
Return destructor only flag. | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. | |
Protected Types inherited from TObject | |
enum | { kOnlyPrepStep = BIT(3) } |
Protected Member Functions inherited from TObject | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). | |
void | MakeZombie () |
#include <TMethodCall.h>
Definition at line 40 of file TMethodCall.h.
TMethodCall::TMethodCall | ( | ) |
Default TMethodCall ctor.
Use Init() to initialize the method call environment.
Definition at line 37 of file TMethodCall.cxx.
Create a method invocation environment for a specific class, method described by the callfunc.
Definition at line 46 of file TMethodCall.cxx.
TMethodCall::TMethodCall | ( | TClass * | cl, |
const char * | method, | ||
const char * | params | ||
) |
Create a method invocation environment for a specific class, method and parameters.
The parameter string has the form: "\"aap\", 3, 4.35". To execute the method call TMethodCall::Execute(object,...). This two step method is much more efficient than calling for every invocation TInterpreter::Execute(...).
Definition at line 59 of file TMethodCall.cxx.
TMethodCall::TMethodCall | ( | const char * | function, |
const char * | params | ||
) |
Create a global function invocation environment.
The parameter string has the form: "\"aap\", 3, 4,35". To execute the function call TMethodCall::Execute(...). This two step method is much more efficient than calling for every invocation TInterpreter::Execute(...).
Definition at line 72 of file TMethodCall.cxx.
TMethodCall::TMethodCall | ( | const TFunction * | func | ) |
Create a global function invocation environment base on a TFunction object.
To execute the function call TMethodCall::Execute(...). This two step method is much more efficient than calling for every invocation TInterpreter::Execute(...).
Definition at line 84 of file TMethodCall.cxx.
TMethodCall::TMethodCall | ( | const TMethodCall & | org | ) |
Copy ctor.
Definition at line 92 of file TMethodCall.cxx.
TMethodCall::~TMethodCall | ( | ) |
TMethodCall dtor.
Definition at line 127 of file TMethodCall.cxx.
Definition at line 87 of file TMethodCall.h.
|
virtual |
Return an exact copy of this object.
Reimplemented from TObject.
Definition at line 136 of file TMethodCall.cxx.
|
inline |
Definition at line 131 of file TMethodCall.h.
|
inlineprivatevirtual |
Execute method on this object with the given parameter string, e.g.
"3.14,1,\"text\"".
Reimplemented from TObject.
Definition at line 64 of file TMethodCall.h.
|
inline |
Definition at line 133 of file TMethodCall.h.
Definition at line 141 of file TMethodCall.h.
Definition at line 137 of file TMethodCall.h.
Definition at line 139 of file TMethodCall.h.
Definition at line 135 of file TMethodCall.h.
|
inlineprivatevirtual |
Execute method on this object with parameters stored in the TObjArray.
The TObjArray should contain an argv vector like:
Reimplemented from TObject.
Definition at line 65 of file TMethodCall.h.
Invoke the method.
[in] | objAddress | Address of the object to execute the method (nullptr if it is a free function) |
[in] | args | Array of pointer to the address of the argument to pass to the function as is. No conversion is done, the argument must be of the expected type. |
[in] | nargs | Number of arguments passed (must be less than actua size of args |
[out] | ret | Address of value (or object) to use for the return value. |
Definition at line 549 of file TMethodCall.cxx.
Execute the method (with preset arguments) for the specified object.
Definition at line 418 of file TMethodCall.cxx.
Execute the method (with preset arguments) for the specified object.
Definition at line 511 of file TMethodCall.cxx.
Execute the method for the specified object and argument values.
Definition at line 433 of file TMethodCall.cxx.
Execute the method for the specified object and argument values.
Definition at line 525 of file TMethodCall.cxx.
Execute the method for the specified object and argument values.
Definition at line 495 of file TMethodCall.cxx.
Execute the method for the specified object and argument values.
Definition at line 464 of file TMethodCall.cxx.
Execute the method (with preset arguments) for the specified object.
Definition at line 481 of file TMethodCall.cxx.
Execute the method (with preset arguments) for the specified object.
Definition at line 450 of file TMethodCall.cxx.
|
inline |
Definition at line 93 of file TMethodCall.h.
TFunction * TMethodCall::GetMethod | ( | ) |
Returns the TMethod describing the method to be executed.
This takes all overriding and overloading into account (call TClass::GetMethod()). Since finding the method is expensive the result is cached.
Definition at line 383 of file TMethodCall.cxx.
|
inline |
Definition at line 90 of file TMethodCall.h.
|
inline |
Definition at line 91 of file TMethodCall.h.
|
inline |
Definition at line 92 of file TMethodCall.h.
void TMethodCall::Init | ( | const char * | function, |
const char * | params | ||
) |
Initialize the function invocation environment.
Necessary input information: the function name and the parameter string of the form "\"aap\", 3, 4.35".
To execute the method call TMethodCall::Execute(...). This two step method is much more efficient than calling for every invocation TInterpreter::Execute(...).
Definition at line 278 of file TMethodCall.cxx.
Initialize the method invocation environment based on the TFunction object.
Definition at line 223 of file TMethodCall.cxx.
Initialize the method invocation environment based on the CallFunc object and the TClass describing the function context.
Definition at line 182 of file TMethodCall.cxx.
void TMethodCall::Init | ( | TClass * | cl, |
const char * | method, | ||
const char * | params, | ||
Bool_t | objectIsConst = kFALSE |
||
) |
Initialize the method invocation environment.
Necessary input information: the class, method name and the parameter string of the form "\"aap\", 3, 4.35".
To execute the method call TMethodCall::Execute(object,...). This two step method is much more efficient than calling for every invocation TInterpreter::Execute(...).
Definition at line 257 of file TMethodCall.cxx.
|
private |
This function implements Init and InitWithPrototype.
'methodname' should NOT have any scope information in it. The scope information should be passed via the TClass or CINT ClassInfo.
Definition at line 293 of file TMethodCall.cxx.
void TMethodCall::InitWithPrototype | ( | const char * | function, |
const char * | proto, | ||
ROOT::EFunctionMatchMode | mode = ROOT::kConversionMatch |
||
) |
Initialize the function invocation environment.
Necessary input information: the function name and the prototype string of the form: "char*,int,float".
To execute the method call TMethodCall::Execute(...). This two step method is much more efficient than calling for every invocation TInterpreter::Execute(...).
Definition at line 360 of file TMethodCall.cxx.
void TMethodCall::InitWithPrototype | ( | TClass * | cl, |
const char * | method, | ||
const char * | proto, | ||
Bool_t | objectIsConst = kFALSE , |
||
ROOT::EFunctionMatchMode | mode = ROOT::kConversionMatch |
||
) |
Initialize the method invocation environment.
Necessary input information: the class, method name and the prototype string of the form: "char*,int,float".
To execute the method call TMethodCall::Execute(object,...). This two step method is much more efficient than calling for every invocation TInterpreter::Execute(...).
Definition at line 339 of file TMethodCall.cxx.
Bool_t TMethodCall::IsValid | ( | ) | const |
Return true if the method call has been properly initialized and is usable.
Definition at line 373 of file TMethodCall.cxx.
TMethodCall & TMethodCall::operator= | ( | const TMethodCall & | rhs | ) |
Assignment operator.
Definition at line 104 of file TMethodCall.cxx.
void TMethodCall::ResetParam | ( | ) |
Reset parameter list. To be used before the first call the SetParam().
Definition at line 594 of file TMethodCall.cxx.
TMethodCall::EReturnType TMethodCall::ReturnType | ( | ) |
Returns the return type of the method.
Either (unsigned) long, int, short and char, or float and double or anything else. Since finding the return type is expensive the result is cached.
Definition at line 562 of file TMethodCall.cxx.
Add a double method parameter.
Definition at line 621 of file TMethodCall.cxx.
Add a double method parameter.
Definition at line 612 of file TMethodCall.cxx.
Add a long long method parameter.
Definition at line 630 of file TMethodCall.cxx.
Add a long method parameter.
Definition at line 603 of file TMethodCall.cxx.
Add a unsigned long long method parameter.
Definition at line 639 of file TMethodCall.cxx.
ParamArr is an array containing the function argument values.
If nparam = -1 then paramArr must contain values for all function arguments, otherwise Nargs-NargsOpt <= nparam <= Nargs, where Nargs is the number of all arguments and NargsOpt is the number of default arguments.
Definition at line 585 of file TMethodCall.cxx.
|
inline |
Definition at line 104 of file TMethodCall.h.
|
private |
Definition at line 56 of file TMethodCall.h.
|
private |
Definition at line 61 of file TMethodCall.h.
|
private |
Definition at line 54 of file TMethodCall.h.
|
private |
Definition at line 58 of file TMethodCall.h.
|
private |
Definition at line 57 of file TMethodCall.h.
|
private |
Definition at line 55 of file TMethodCall.h.
|
private |
Definition at line 59 of file TMethodCall.h.
|
private |
Definition at line 60 of file TMethodCall.h.
|
private |
Definition at line 62 of file TMethodCall.h.
|
static |
Definition at line 44 of file TMethodCall.h.
|
static |
Definition at line 43 of file TMethodCall.h.
|
static |
Definition at line 49 of file TMethodCall.h.
|
static |
Definition at line 47 of file TMethodCall.h.
|
static |
Definition at line 46 of file TMethodCall.h.
|
static |
Definition at line 45 of file TMethodCall.h.