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. More... | |
TMethodCall (const char *function, const char *params) | |
Create a global function invocation environment. More... | |
TMethodCall (const TFunction *func) | |
Create a global function invocation environment base on a TFunction object. More... | |
TMethodCall (const TMethodCall &org) | |
Copy ctor. More... | |
TMethodCall (TClass *cl, CallFunc_t *callfunc, Long_t offset=0) | |
Create a method invocation environment for a specific class, method described by the callfunc. More... | |
TMethodCall (TClass *cl, const char *method, const char *params) | |
Create a method invocation environment for a specific class, method and parameters. More... | |
~TMethodCall () | |
TMethodCall dtor. More... | |
void | CallDtorOnly (Bool_t set=kTRUE) |
TObject * | Clone (const char *newname="") const |
Return an exact copy of this object. More... | |
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. More... | |
void | Execute (void *object) |
Execute the method (with preset arguments) for the specified object. More... | |
void | Execute (void *object, char **retText) |
Execute the method (with preset arguments) for the specified object. More... | |
void | Execute (void *object, const char *params) |
Execute the method for the specified object and argument values. More... | |
void | Execute (void *object, const char *params, char **retText) |
Execute the method for the specified object and argument values. More... | |
void | Execute (void *object, const char *params, Double_t &retDouble) |
Execute the method for the specified object and argument values. More... | |
void | Execute (void *object, const char *params, Long_t &retLong) |
Execute the method for the specified object and argument values. More... | |
void | Execute (void *object, Double_t &retDouble) |
Execute the method (with preset arguments) for the specified object. More... | |
void | Execute (void *object, Long_t &retLong) |
Execute the method (with preset arguments) for the specified object. More... | |
CallFunc_t * | GetCallFunc () const |
TFunction * | GetMethod () |
Returns the TMethod describing the method to be executed. More... | |
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. More... | |
void | Init (const TFunction *func) |
Initialize the method invocation environment based on the TFunction object. More... | |
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. More... | |
void | Init (TClass *cl, const char *method, const char *params, Bool_t objectIsConst=kFALSE) |
Initialize the method invocation environment. More... | |
void | InitWithPrototype (const char *function, const char *proto, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) |
Initialize the function invocation environment. More... | |
void | InitWithPrototype (TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch) |
Initialize the method invocation environment. More... | |
Bool_t | IsValid () const |
Return true if the method call has been properly initialized and is usable. More... | |
TMethodCall & | operator= (const TMethodCall &rhs) |
Assignment operator. More... | |
void | ResetParam () |
Reset parameter list. To be used before the first call the SetParam(). More... | |
EReturnType | ReturnType () |
Returns the return type of the method. More... | |
void | SetParam (Double_t d) |
Add a double method parameter. More... | |
void | SetParam (Float_t f) |
Add a double method parameter. More... | |
void | SetParam (Long64_t ll) |
Add a long long method parameter. More... | |
void | SetParam (Long_t l) |
Add a long method parameter. More... | |
void | SetParam (ULong64_t ull) |
Add a unsigned long long method parameter. More... | |
void | SetParamPtrs (void *paramArr, Int_t nparam=-1) |
ParamArr is an array containing the function argument values. More... | |
template<typename... T> | |
void | SetParams (const T &... params) |
Public Member Functions inherited from TObject | |
TObject () | |
TObject constructor. More... | |
TObject (const TObject &object) | |
TObject copy ctor. More... | |
virtual | ~TObject () |
TObject destructor. More... | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. More... | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. More... | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. More... | |
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. More... | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. More... | |
virtual void | Clear (Option_t *="") |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. More... | |
virtual Int_t | Compare (const TObject *obj) const |
Compare abstract method. More... | |
virtual void | Copy (TObject &object) const |
Copy this to obj. More... | |
virtual void | Delete (Option_t *option="") |
Delete this object. More... | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. More... | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. More... | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. More... | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad) . More... | |
virtual void | Dump () const |
Dump contents of object on stdout. More... | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. More... | |
virtual void | Execute (const char *method, const char *params, Int_t *error=0) |
Execute method on this object with the given parameter string, e.g. More... | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
Execute method on this object with parameters stored in the TObjArray. More... | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). More... | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. More... | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. More... | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. More... | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. More... | |
virtual const char * | GetIconName () const |
Returns mime type name of object. More... | |
virtual const char * | GetName () const |
Returns name of object. More... | |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). More... | |
virtual Option_t * | GetOption () const |
virtual const char * | GetTitle () const |
Returns title of object. More... | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. More... | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. More... | |
virtual ULong_t | Hash () const |
Return hash value for this object. More... | |
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. More... | |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. More... | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". More... | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. More... | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. More... | |
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). More... | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More... | |
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. More... | |
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). More... | |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. More... | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. More... | |
void | operator delete (void *ptr) |
Operator delete. More... | |
void | operator delete[] (void *ptr) |
Operator delete []. More... | |
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. More... | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. More... | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. More... | |
virtual void | Print (Option_t *option="") const |
This method must be overridden when a class wants to print itself. More... | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. More... | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove this object from a list. More... | |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. More... | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". More... | |
void | SetBit (UInt_t f) |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. More... | |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. More... | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. More... | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. More... | |
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. More... | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. More... | |
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. More... | |
void | Execute (TMethod *, TObjArray *, int *=0) |
Execute method on this object with parameters stored in the TObjArray. More... | |
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. More... | |
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. More... | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. More... | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. More... | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. More... | |
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). More... | |
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.