55 TQSlot(
TClass *cl,
const char *method,
const char *funcname);
56 TQSlot(
const char *class_name,
const char *funcname);
61 CallFunc_t *StartExecuting();
62 CallFunc_t *GetFunc()
const {
return fFunc; }
71 void ExecuteMethod(
void *
object,
Int_t nargs, va_list ap) =
delete;
72 void ExecuteMethod(
void *
object);
73 void ExecuteMethod(
void *
object,
Long_t param);
74 void ExecuteMethod(
void *
object,
Long64_t param);
75 void ExecuteMethod(
void *
object,
Double_t param);
76 void ExecuteMethod(
void *
object,
const char *params);
77 void ExecuteMethod(
void *
object,
Long_t *paramArr,
Int_t nparam = -1);
83 Bool_t IsExecuting()
const {
84 return fExecuting > 0;
101 TQSlot::TQSlot(
TClass *cl,
const char *method_name,
115 char *method =
new char[strlen(method_name) + 1];
116 if (method) strcpy(method, method_name);
124 if ((proto = strchr(method,
'('))) {
130 if ((tmp = strrchr(proto,
')'))) * tmp =
'\0';
131 if ((params = strchr(proto,
'='))) * params =
' ';
152 fMethod =
gROOT->GetGlobalFunction(funcname, params,
kFALSE);
155 fMethod =
gROOT->GetGlobalFunctionWithPrototype(funcname, proto,
kFALSE);
176 TQSlot::TQSlot(
const char *class_name,
const char *funcname) :
186 char *method =
new char[strlen(funcname) + 1];
187 if (method) strcpy(method, funcname);
195 if ((proto = strchr(method,
'('))) {
197 if ((tmp = strrchr(proto,
')'))) * tmp =
'\0';
198 if ((params = strchr(proto,
'='))) * params =
' ';
220 fMethod =
gROOT->GetGlobalFunction(method, params,
kTRUE);
226 fMethod =
gROOT->GetGlobalFunctionWithPrototype(method, proto,
kTRUE);
248 inline void TQSlot::ExecuteMethod(
void *
object)
250 ExecuteMethod(
object, (
Long_t*)
nullptr, 0);
261 Error(
"ExecuteMethod",
"method %s not found," 262 "\n(note: interpreted methods are not supported with varargs)",
267 if (nargs < fMethod->GetNargs() - fMethod->GetNargsOpt() ||
268 nargs > fMethod->GetNargs()) {
269 Error(
"ExecuteMethod",
"nargs (%d) not consistent with expected number of arguments ([%d-%d])",
270 nargs, fMethod->GetNargs() - fMethod->GetNargsOpt(),
271 fMethod->GetNargs());
281 CallFunc_t *TQSlot::StartExecuting() {
289 void TQSlot::EndExecuting() {
291 if (!TestBit(kNotDeleted) && !fExecuting)
299 inline void TQSlot::ExecuteMethod(
void *
object,
Long_t param)
301 ExecuteMethod(
object, ¶m, 1);
309 inline void TQSlot::ExecuteMethod(
void *
object,
Long64_t param)
312 ExecuteMethod(
object, arg, 1);
320 inline void TQSlot::ExecuteMethod(
void *
object,
Double_t param)
323 ExecuteMethod(
object, arg, 1);
330 inline void TQSlot::ExecuteMethod(
void *
object,
const char *param)
333 ExecuteMethod(
object, &arg, 1);
346 inline void TQSlot::ExecuteMethod(
void *
object,
Long_t *paramArr,
Int_t nparam)
351 if (
object) address = (
void *)((
Long_t)
object + fOffset);
355 if (!TestBit(kNotDeleted) && !fExecuting)
364 std::cout << IsA()->GetName() <<
"\t" <<
GetName() <<
"\t" 365 <<
"Number of Connections = " << References() << std::endl;
377 virtual ~TQSlotPool() {
378 fTable->
Clear(
"nodelete");
381 TQSlot *New(
const char *class_name,
const char *funcname);
382 TQSlot *New(
TClass *cl,
const char *method,
const char *func);
383 void Free(TQSlot *slot);
389 TQSlot *TQSlotPool::New(
const char *class_name,
const char *funcname)
395 TQSlot *slot = (TQSlot *)fTable->FindObject(name.
Data());
398 slot =
new TQSlot(class_name, funcname);
401 slot->AddReference();
408 TQSlot *TQSlotPool::New(
TClass *cl,
const char *method,
const char *func)
421 TQSlot *slot = (TQSlot *)fTable->FindObject(name.
Data());
424 slot =
new TQSlot(cl, method, func);
427 slot->AddReference();
434 void TQSlotPool::Free(TQSlot *slot)
436 slot->RemoveReference();
438 if (slot->References() <= 0) {
439 fTable->Remove(slot);
448 nparam = fSlot->GetMethodNargs();
452 gInterpreter->CallFunc_SetArgArray(fSlot->GetFunc(),
const_cast<Long_t*
>(params), nparam);
465 const char *funcname = 0;
469 Error(
"SetFCN",
"Not used anymore.");
478 fSlot = gSlotPool.New(cl, method_name, funcname);
490 fSlot = gSlotPool.New(class_name, funcname);
501 fSlot->AddReference();
516 while ((list = (
TList *)next())) {
518 if (list->
IsEmpty())
delete list;
523 gSlotPool.Free(
fSlot);
531 return fSlot->GetName();
549 std::cout <<
"\t" << IsA()->GetName() <<
"\t" <<
GetName() << std::endl;
560 std::cout << IsA()->GetName() <<
"\t" <<
fReceiver <<
"\t" <<
GetName() << std::endl;
573 if (s->References() <= 0)
delete s;
587 if (s->References() <= 0)
delete s;
601 if (s->References() <= 0)
delete s;
615 if (s->References() <= 0)
delete s;
629 if (s->References() <= 0)
delete s;
643 if (s->References() <= 0)
delete s;
651 return fSlot->CheckSlot(nargs);
667 return fSlot->StartExecuting();
675 if (s->References() <= 0)
delete s;
680 return fSlot->GetFunc();
virtual const char * GetName() const
Returns name of object.
std::string GetName(const std::string &scope_name)
virtual void CallFunc_SetFuncProto(CallFunc_t *, ClassInfo_t *, const char *, const char *, Long_t *, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const
virtual CallFunc_t * CallFunc_Factory() const
virtual void CallFunc_SetArgArray(CallFunc_t *, Long_t *, Int_t) const
R__EXTERN TVirtualMutex * gInterpreterMutex
Definitions for TRefCnt, base class for reference counted objects.
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
virtual void PrintCollectionHeader(Option_t *option) const override
Print TQConnection full method name and print all signals connected to this connection.
void UnLockSlot(TQSlot *) const
Unlock the interpreter and mark the slot as no longer executing.
V GetOffset(E val1, E val2, V iso)
THashTable implements a hash table to store TObject's.
void Clear(Option_t *option="")
Remove all objects from the table.
virtual ClassInfo_t * ClassInfo_Factory(Bool_t=kTRUE) const =0
ClassInfo_t * GetClassInfo() const
virtual void CallFunc_SetFunc(CallFunc_t *, ClassInfo_t *, const char *, const char *, bool, Long_t *) const
void Destroyed() override
Signal Destroyed tells that connection is destroyed.
static TQSlotPool gSlotPool
void Error(const char *location, const char *msgfmt,...)
virtual ~TQConnection()
TQConnection dtor.
Int_t GetNargs() const
Number of function arguments.
TQConnection class is an internal class, used in the object communication mechanism.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual void SetArg(Long_t param) override
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
The ROOT global object gROOT contains a list of all defined classes.
virtual void CallFunc_IgnoreExtraArgs(CallFunc_t *, bool) const
Bool_t CheckSlot(Int_t nargs) const
Return true if the underlying method is value and the number of argument is compatible.
void ExecuteMethod()
Apply slot-method to the fReceiver object without arguments.
virtual Bool_t IsEmpty() const
void Print(std::ostream &os, const OptionType &opt)
virtual void ClassInfo_Init(ClassInfo_t *, const char *) const
void * GetSlotAddress() const
Return the object address to be passed to the function.
CallFunc_t * LockSlot() const
Lock the interpreter and mark the slot as executing.
virtual void CallFunc_Delete(CallFunc_t *) const
TMethod * GetMethod(const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Find the best method (if there is one) matching the parameters.
static constexpr double s
#define R__LOCKGUARD(mutex)
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
const char * GetName() const override
Returns name of connection (aka name of slot)
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Mother of all ROOT objects.
Global functions class (global functions are obtained from CINT).
virtual void ClassInfo_Delete(ClassInfo_t *) const
void ls(Option_t *option="") const override
List TQConnection full method name and list all signals connected to this connection.
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
virtual void CallFunc_Exec(CallFunc_t *, void *) const
R__EXTERN TInterpreter * gCling
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
virtual CallFunc_t * GetSlotCallFunc() const override
const char * Data() const