43 class TQSlot : public TObject, public TRefCnt {
53 TQSlot(
TClass *cl,
const char *method,
const char *funcname);
54 TQSlot(
const char *class_name,
const char *funcname);
59 CallFunc_t *StartExecuting();
62 const char *GetName()
const {
66 void ExecuteMethod(
void *
object,
Int_t nargs, va_list ap) =
delete;
67 void ExecuteMethod(
void *
object);
68 void ExecuteMethod(
void *
object,
Long_t param);
69 void ExecuteMethod(
void *
object,
Long64_t param);
70 void ExecuteMethod(
void *
object,
Double_t param);
71 void ExecuteMethod(
void *
object,
const char *params);
72 void ExecuteMethod(
void *
object,
Long_t *paramArr,
Int_t nparam = -1);
78 Bool_t IsExecuting()
const {
79 return fExecuting > 0;
96 TQSlot::TQSlot(
TClass *cl,
const char *method_name,
97 const char *funcname) : TObject(), TRefCnt()
110 char *method =
new char[strlen(method_name) + 1];
111 if (method) strcpy(method, method_name);
119 if ((proto = strchr(method,
'('))) {
125 if ((tmp = strrchr(proto,
')'))) * tmp =
'\0';
126 if ((params = strchr(proto,
'='))) * params =
' ';
147 fMethod =
gROOT->GetGlobalFunction(funcname, params,
kFALSE);
150 fMethod =
gROOT->GetGlobalFunctionWithPrototype(funcname, proto,
kFALSE);
171 TQSlot::TQSlot(
const char *class_name,
const char *funcname) :
181 char *method =
new char[strlen(funcname) + 1];
182 if (method) strcpy(method, funcname);
190 if ((proto = strchr(method,
'('))) {
192 if ((tmp = strrchr(proto,
')'))) * tmp =
'\0';
193 if ((params = strchr(proto,
'='))) * params =
' ';
215 fMethod =
gROOT->GetGlobalFunction(method, params,
kTRUE);
221 fMethod =
gROOT->GetGlobalFunctionWithPrototype(method, proto,
kTRUE);
243 inline void TQSlot::ExecuteMethod(
void *
object)
245 ExecuteMethod(
object, (
Long_t*)
nullptr, 0);
256 Error(
"ExecuteMethod",
"method %s not found,"
257 "\n(note: interpreted methods are not supported with varargs)",
262 if (nargs < fMethod->GetNargs() - fMethod->
GetNargsOpt() ||
264 Error(
"ExecuteMethod",
"nargs (%d) not consistent with expected number of arguments ([%d-%d])",
276 CallFunc_t *TQSlot::StartExecuting() {
284 void TQSlot::EndExecuting() {
286 if (!TestBit(kNotDeleted) && !fExecuting)
294 inline void TQSlot::ExecuteMethod(
void *
object,
Long_t param)
296 ExecuteMethod(
object, ¶m, 1);
304 inline void TQSlot::ExecuteMethod(
void *
object,
Long64_t param)
307 ExecuteMethod(
object, arg, 1);
315 inline void TQSlot::ExecuteMethod(
void *
object,
Double_t param)
318 ExecuteMethod(
object, arg, 1);
325 inline void TQSlot::ExecuteMethod(
void *
object,
const char *param)
328 ExecuteMethod(
object, &arg, 1);
341 inline void TQSlot::ExecuteMethod(
void *
object,
Long_t *paramArr,
Int_t nparam)
346 if (
object) address = (
void *)((
Long_t)
object + fOffset);
350 if (!TestBit(kNotDeleted) && !fExecuting)
359 std::cout <<
IsA()->
GetName() <<
"\t" << GetName() <<
"\t"
360 <<
"Number of Connections = " << References() << std::endl;
372 virtual ~TQSlotPool() {
373 fTable->
Clear(
"nodelete");
376 TQSlot *New(
const char *class_name,
const char *funcname);
377 TQSlot *New(
TClass *cl,
const char *method,
const char *func);
378 void Free(TQSlot *slot);
384 TQSlot *TQSlotPool::New(
const char *class_name,
const char *funcname)
393 slot =
new TQSlot(class_name, funcname);
396 slot->AddReference();
403 TQSlot *TQSlotPool::New(
TClass *cl,
const char *method,
const char *func)
419 slot =
new TQSlot(cl, method, func);
422 slot->AddReference();
429 void TQSlotPool::Free(TQSlot *slot)
431 slot->RemoveReference();
433 if (slot->References() <= 0) {
461 const char *funcname = 0;
467 Warning(
"TQConnection",
"%s cannot be compiled", method_name);
471 fSlot = gSlotPool.New(cl, method_name, funcname);
483 fSlot = gSlotPool.New(class_name, funcname);
494 fSlot->AddReference();
511 if (list->
IsEmpty())
delete list;
516 gSlotPool.Free(
fSlot);
524 return fSlot->GetName();
566 if (s->References() <= 0)
delete s;
580 if (s->References() <= 0)
delete s;
594 if (s->References() <= 0)
delete s;
608 if (s->References() <= 0)
delete s;
622 if (s->References() <= 0)
delete s;
636 if (s->References() <= 0)
delete s;
644 return fSlot->CheckSlot(nargs);
660 return fSlot->StartExecuting();
668 if (s->References() <= 0)
delete s;
virtual void CallFunc_SetFuncProto(CallFunc_t *, ClassInfo_t *, const char *, const char *, Long_t *, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const
virtual void ClassInfo_Delete(ClassInfo_t *) const
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Bool_t CheckSlot(Int_t nargs) const
Return true if the underlying method is value and the number of argument is compatible.
R__EXTERN TVirtualMutex * gInterpreterMutex
virtual void CallFunc_SetArgArray(CallFunc_t *, Long_t *, Int_t) const
Int_t GetNargs() const
Number of function arguments.
virtual void CallFunc_Exec(CallFunc_t *, void *) const
virtual void CallFunc_Delete(CallFunc_t *) const
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
ClassImpQ(TQConnection) char *gTQSlotParams
virtual void CallFunc_IgnoreExtraArgs(CallFunc_t *, bool) const
V GetOffset(E val1, E val2, V iso)
void ls(Option_t *option="") const
List TQConnection full method name and list all signals connected to this connection.
TQConnection()
Default constructor.
const char * Data() const
THashTable implements a hash table to store TObject's.
virtual void ClassInfo_Init(ClassInfo_t *, const char *) const
void * GetSlotAddress() const
Return the object address to be passed to the function.
virtual Bool_t IsEmpty() const
void Clear(Option_t *option="")
Remove all objects from the table.
UChar_t mod R__LOCKGUARD2(gSrvAuthenticateMutex)
virtual ClassInfo_t * ClassInfo_Factory(Bool_t=kTRUE) const =0
TClass * fClass
pointer to the foreign object
static TQSlotPool gSlotPool
void Error(const char *location, const char *msgfmt,...)
void Destroyed()
Signal Destroyed tells that connection is destroyed.
void UnLockSlot(TQSlot *) const
Unlock the interpreter and mark the slot as no longer executing.
void Emit(const char *signal)
Acitvate signal without args.
Int_t GetNargsOpt() const
Number of function optional (default) arguments.
virtual ~TQConnection()
TQConnection dtor.
TQConnection class is an internal class, used in the object communication mechanism.
ClassInfo_t * GetClassInfo() const
virtual TObject * Remove(TObject *obj)
Remove object from the list.
const char * GetName() const
Returns name of connection (aka name of slot)
virtual const char * GetName() const
Returns name of object.
The ROOT global object gROOT contains a list of all defined classes.
void ExecuteMethod()
Apply slot-method to the fReceiver object without arguments.
virtual CallFunc_t * CallFunc_Factory() const
void Print(std::ostream &os, const OptionType &opt)
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.
void Add(TObject *obj)
Add object to the hash table.
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.
virtual void PrintCollectionHeader(Option_t *option) const
Print TQConnection full method name and print all signals connected to this connection.
Global functions class (global functions are obtained from CINT).
TObject * FindObject(const char *name) const
Find object using its name.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
virtual const char * Getp2f2funcname(void *) const
R__EXTERN TInterpreter * gCling
CallFunc_t * LockSlot() const
Lock the interpreter and mark the slot as executing.
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 void CallFunc_SetFunc(CallFunc_t *, ClassInfo_t *, const char *, const char *, bool, Long_t *) const
TObject * Remove(TObject *obj)
Remove object from the hashtable.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.