55 TQSlot(
TClass *cl,
const char *method,
const char *funcname);
56 TQSlot(
const char *class_name,
const char *funcname);
61 CallFunc_t *StartExecuting();
68 void ExecuteMethod(
void *
object,
Int_t nargs, va_list ap) =
delete;
69 void ExecuteMethod(
void *
object);
70 void ExecuteMethod(
void *
object,
Long_t param);
71 void ExecuteMethod(
void *
object,
Long64_t param);
72 void ExecuteMethod(
void *
object,
Double_t param);
73 void ExecuteMethod(
void *
object,
const char *params);
74 void ExecuteMethod(
void *
object,
Long_t *paramArr,
Int_t nparam = -1);
80 Bool_t IsExecuting()
const {
81 return fExecuting > 0;
98 TQSlot::TQSlot(
TClass *cl,
const char *method_name,
112 char *method =
new char[strlen(method_name) + 1];
113 if (method) strcpy(method, method_name);
121 if ((proto = strchr(method,
'('))) {
127 if ((tmp = strrchr(proto,
')'))) * tmp =
'\0';
128 if ((params = strchr(proto,
'='))) * params =
' ';
149 fMethod =
gROOT->GetGlobalFunction(funcname, params,
kFALSE);
152 fMethod =
gROOT->GetGlobalFunctionWithPrototype(funcname, proto,
kFALSE);
173 TQSlot::TQSlot(
const char *class_name,
const char *funcname) :
183 char *method =
new char[strlen(funcname) + 1];
184 if (method) strcpy(method, funcname);
192 if ((proto = strchr(method,
'('))) {
194 if ((tmp = strrchr(proto,
')'))) * tmp =
'\0';
195 if ((params = strchr(proto,
'='))) * params =
' ';
217 fMethod =
gROOT->GetGlobalFunction(method, params,
kTRUE);
223 fMethod =
gROOT->GetGlobalFunctionWithPrototype(method, proto,
kTRUE);
245 inline void TQSlot::ExecuteMethod(
void *
object)
247 ExecuteMethod(
object, (
Long_t*)
nullptr, 0);
258 Error(
"ExecuteMethod",
"method %s not found," 259 "\n(note: interpreted methods are not supported with varargs)",
264 if (nargs < fMethod->GetNargs() - fMethod->GetNargsOpt() ||
265 nargs > fMethod->GetNargs()) {
266 Error(
"ExecuteMethod",
"nargs (%d) not consistent with expected number of arguments ([%d-%d])",
267 nargs, fMethod->GetNargs() - fMethod->GetNargsOpt(),
268 fMethod->GetNargs());
278 CallFunc_t *TQSlot::StartExecuting() {
286 void TQSlot::EndExecuting() {
288 if (!TestBit(kNotDeleted) && !fExecuting)
296 inline void TQSlot::ExecuteMethod(
void *
object,
Long_t param)
298 ExecuteMethod(
object, ¶m, 1);
306 inline void TQSlot::ExecuteMethod(
void *
object,
Long64_t param)
309 ExecuteMethod(
object, arg, 1);
317 inline void TQSlot::ExecuteMethod(
void *
object,
Double_t param)
320 ExecuteMethod(
object, arg, 1);
327 inline void TQSlot::ExecuteMethod(
void *
object,
const char *param)
330 ExecuteMethod(
object, &arg, 1);
343 inline void TQSlot::ExecuteMethod(
void *
object,
Long_t *paramArr,
Int_t nparam)
348 if (
object) address = (
void *)((
Long_t)
object + fOffset);
352 if (!TestBit(kNotDeleted) && !fExecuting)
361 std::cout << IsA()->GetName() <<
"\t" <<
GetName() <<
"\t" 362 <<
"Number of Connections = " << References() << std::endl;
374 virtual ~TQSlotPool() {
375 fTable->
Clear(
"nodelete");
378 TQSlot *New(
const char *class_name,
const char *funcname);
379 TQSlot *New(
TClass *cl,
const char *method,
const char *
func);
380 void Free(TQSlot *slot);
386 TQSlot *TQSlotPool::New(
const char *class_name,
const char *funcname)
392 TQSlot *slot = (TQSlot *)fTable->FindObject(name.
Data());
395 slot =
new TQSlot(class_name, funcname);
398 slot->AddReference();
405 TQSlot *TQSlotPool::New(
TClass *cl,
const char *method,
const char *
func)
418 TQSlot *slot = (TQSlot *)fTable->FindObject(name.
Data());
421 slot =
new TQSlot(cl, method, func);
424 slot->AddReference();
431 void TQSlotPool::Free(TQSlot *slot)
433 slot->RemoveReference();
435 if (slot->References() <= 0) {
436 fTable->Remove(slot);
463 const char *funcname = 0;
467 Error(
"SetFCN",
"Not used anymore.");
476 fSlot = gSlotPool.New(cl, method_name, funcname);
488 fSlot = gSlotPool.New(class_name, funcname);
499 fSlot->AddReference();
514 while ((list = (
TList *)next())) {
516 if (list->
IsEmpty())
delete list;
521 gSlotPool.Free(
fSlot);
529 return fSlot->GetName();
547 std::cout <<
"\t" << IsA()->GetName() <<
"\t" <<
GetName() << std::endl;
558 std::cout << IsA()->GetName() <<
"\t" <<
fReceiver <<
"\t" <<
GetName() << std::endl;
571 if (s->References() <= 0)
delete s;
585 if (s->References() <= 0)
delete s;
599 if (s->References() <= 0)
delete s;
613 if (s->References() <= 0)
delete s;
627 if (s->References() <= 0)
delete s;
641 if (s->References() <= 0)
delete s;
649 return fSlot->CheckSlot(nargs);
665 return fSlot->StartExecuting();
673 if (s->References() <= 0)
delete s;
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...
void UnLockSlot(TQSlot *) const
Unlock the interpreter and mark the slot as no longer executing.
V GetOffset(E val1, E val2, V iso)
TQConnection()
Default constructor.
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
static TQSlotPool gSlotPool
void Error(const char *location, const char *msgfmt,...)
void Destroyed()
Signal Destroyed tells that connection is destroyed.
void Emit(const char *signal)
Acitvate signal without args.
virtual ~TQConnection()
TQConnection dtor.
TQConnection class is an internal class, used in the object communication mechanism.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
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.
#define R__LOCKGUARD2(mutex)
virtual Bool_t IsEmpty() const
void Print(std::ostream &os, const OptionType &opt)
virtual void ClassInfo_Init(ClassInfo_t *, const char *) const
virtual void PrintCollectionHeader(Option_t *option) const
Print TQConnection full method name and print all signals connected to this connection.
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
double func(double *x, double *p)
TMethod * GetMethod(const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Find the best method (if there is one) matching the parameters.
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.
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
List TQConnection full method name and list all signals connected to this connection.
const char * GetName() const
Returns name of connection (aka name of slot)
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.
const char * Data() const