#include "Varargs.h"
#include "TQObject.h"
#include "TQConnection.h"
#include "THashList.h"
#include "TPRegexp.h"
#include "TROOT.h"
#include "TClass.h"
#include "TSystem.h"
#include "TMethod.h"
#include "TBaseClass.h"
#include "TDataType.h"
#include "TInterpreter.h"
#include "TQClass.h"
#include "TError.h"
#include "Riostream.h"
#include "RQ_OBJECT.h"
#include "TVirtualMutex.h"
#include "Varargs.h"
#include "TInterpreter.h"
#include "RConfigure.h"
void *gTQSender;
Bool_t TQObject::fgAllSignalsBlocked = kFALSE;
ClassImpQ(TQObject)
ClassImpQ(TQObjSender)
ClassImpQ(TQClass)
namespace
{
TString CompressName(const char *method_name)
{
static TPMERegexp *constRe = 0, *wspaceRe = 0;
static TVirtualMutex *lock = 0;
R__LOCKGUARD2(lock);
if (constRe == 0) {
constRe = new TPMERegexp("(?<=\\(|\\s|,|&|\\*)const(?=\\s|,|\\)|&|\\*)", "go");
wspaceRe = new TPMERegexp("\\s+", "go");
}
TString res(method_name);
if (res.IsNull())
return res;
constRe ->Substitute(res, "");
wspaceRe->Substitute(res, "");
TStringToken methargs(res, "\\(|\\)", kTRUE);
methargs.NextToken();
res = methargs;
res += "(";
methargs.NextToken();
TStringToken arg(methargs, ",");
while (arg.NextToken())
{
Int_t pri = arg.Length() - 1;
Char_t prc = 0;
if (arg[pri] == '*' || arg[pri] == '&') {
prc = arg[pri];
arg.Remove(pri);
}
TDataType *dt = gROOT->GetType(arg.Data());
if (dt) {
res += dt->GetFullTypeName();
} else {
res += arg;
}
if (prc) res += prc;
if (!arg.AtEnd()) res += ",";
}
res += ")";
return res;
}
TMethod *GetMethodWithPrototype(TClass *cl, const char *method,
const char *proto, Int_t &nargs)
{
nargs = 0;
if (!gInterpreter) return 0;
R__LOCKGUARD2(gCINTMutex);
Long_t faddr = 0;
if (!cl->IsLoaded()) {
void *clinfo = cl->GetClassInfo();
nargs = gCint->ClassInfo_GetMethodNArg(clinfo,method, proto);
if (nargs >= 0) return (TMethod *) -1;
nargs = 0;
return 0;
} else {
faddr = (Long_t)gInterpreter->GetInterfaceMethodWithPrototype(cl, method,
proto);
if (!faddr) return 0;
}
TMethod *m;
TIter next_method(cl->GetListOfMethods());
while ((m = (TMethod *) next_method())) {
if (faddr == (Long_t)m->InterfaceMethod()) {
nargs = m->GetNargs();
return m;
}
}
TIter next_base(cl->GetListOfBases());
TBaseClass *base;
while ((base = (TBaseClass *)next_base())) {
TClass *c;
if ((c = base->GetClassPointer())) {
if ((m = GetMethodWithPrototype(c, method, proto, nargs))) return m;
}
}
return 0;
}
static TMethod *GetMethod(TClass *cl, const char *method, const char *params)
{
if (!gInterpreter) return 0;
R__LOCKGUARD2(gCINTMutex);
Long_t faddr = 0;
if (!cl->IsLoaded()) {
CallFunc_t *func = gCint->CallFunc_Factory();
long offset;
void *cinfo = cl->GetClassInfo();
gCint->CallFunc_SetFunc(func, cinfo, method, params, &offset);
Bool_t valid = gCint->CallFunc_IsValid(func);
gCint->CallFunc_Delete(func);
if (valid)
return (TMethod *) -1;
return 0;
} else {
faddr = (Long_t)gCint->GetInterfaceMethod(cl, method, params);
if (!faddr) return 0;
}
TMethod *m;
TIter next_method(cl->GetListOfMethods());
while ((m = (TMethod *) next_method())) {
if (faddr == (Long_t)m->InterfaceMethod()) return m;
}
TIter next_base(cl->GetListOfBases());
TBaseClass *base;
while ((base = (TBaseClass *)next_base())) {
TClass *c;
if ((c = base->GetClassPointer())) {
if ((m = GetMethod(c,method,params))) return m;
}
}
return 0;
}
}
Int_t TQObject::CheckConnectArgs(TQObject *sender,
TClass *sender_class, const char *signal,
TClass *receiver_class, const char *slot)
{
char *signal_method = new char[strlen(signal)+1];
if (signal_method) strcpy(signal_method, signal);
char *signal_proto;
char *tmp;
if ((signal_proto = strchr(signal_method,'('))) {
*signal_proto++ = '\0';
if ((tmp = strrchr(signal_proto,')'))) *tmp = '\0';
}
if (!signal_proto) signal_proto = (char*)"";
if (sender && sender_class == TQObjSender::Class()) {
sender_class = TClass::GetClass(sender->GetSenderClassName());
if (!sender_class) {
::Error("TQObject::CheckConnectArgs", "for signal/slot consistency\n"
"checking need to specify class name as argument to "
"RQ_OBJECT macro");
delete [] signal_method;
return -1;
}
}
Int_t nargs;
TMethod *signalMethod = GetMethodWithPrototype(sender_class,
signal_method,
signal_proto,
nargs);
if (!signalMethod) {
::Error("TQObject::CheckConnectArgs", "signal %s::%s(%s) does not exist",
sender_class->GetName(), signal_method, signal_proto);
delete [] signal_method;
return -1;
}
Int_t nsigargs = nargs;
#if defined(CHECK_COMMENT_STRING)
const char *comment = 0;
if (signalMethod != (TMethod *) -1)
comment = signalMethod->GetCommentString();
if (!comment || !strlen(comment) || strstr(comment,"*SIGNAL")){
::Error("TQObject::CheckConnectArgs",
"signal %s::%s(%s), to declare signal use comment //*SIGNAL*",
sender_class->GetName(), signal_method, signal_proto);
delete [] signal_method;
return -1;
}
#endif
delete [] signal_method;
char *slot_method = new char[strlen(slot)+1];
if (slot_method) strcpy(slot_method, slot);
char *slot_proto;
char *slot_params = 0;
if ((slot_proto = strchr(slot_method,'('))) {
*slot_proto++ = '\0';
if ((tmp = strrchr(slot_proto,')'))) *tmp = '\0';
}
if (!slot_proto) slot_proto = (char*)"";
if ((slot_params = strchr(slot_proto,'='))) *slot_params = ' ';
TFunction *slotMethod = 0;
if (!receiver_class) {
slotMethod = (TFunction*)gROOT->GetListOfGlobalFunctions(kTRUE)->
FindObject(slot_method);
} else {
slotMethod = !slot_params ?
GetMethodWithPrototype(receiver_class,
slot_method,
slot_proto,
nargs) :
GetMethod(receiver_class,
slot_method, slot_params);
}
if (!slotMethod) {
if (!slot_params) {
::Error("TQObject::CheckConnectArgs", "slot %s(%s) does not exist",
receiver_class ? Form("%s::%s", receiver_class->GetName(),
slot_method) : slot_method, slot_proto);
} else {
::Error("TQObject::CheckConnectArgs", "slot %s(%s) does not exist",
receiver_class ? Form("%s::%s", receiver_class->GetName(),
slot_method) : slot_method, slot_params);
}
delete [] slot_method;
return -1;
}
#if defined(CHECK_ARGS_NUMBER)
if (slotMethod != (TMethod *) -1 && slotMethod->GetNargsOpt() >= 0 &&
nsigargs < (slotMethod->GetNargs() - slotMethod->GetNargsOpt())) {
::Error("TQObject::CheckConnectArgs",
"inconsistency in numbers of arguments");
delete [] slot_method;
return -1;
}
#endif
delete [] slot_method;
return nsigargs;
}
class TQConnectionList : public TList {
private:
Int_t fSignalArgs;
public:
TQConnectionList(const char *name, Int_t nsigargs) : TList()
{ fName = name; fSignalArgs = nsigargs; }
virtual ~TQConnectionList();
Bool_t Disconnect(void *receiver=0, const char *slot_name=0);
Int_t GetNargs() const { return fSignalArgs; }
void ls(Option_t *option = "") const;
};
TQConnectionList::~TQConnectionList()
{
TIter next(this);
TQConnection *connection;
while ((connection = (TQConnection*)next())) {
connection->Remove(this);
if (connection->IsEmpty()) delete connection;
}
Clear("nodelete");
}
Bool_t TQConnectionList::Disconnect(void *receiver, const char *slot_name)
{
TQConnection *connection = 0;
Bool_t return_value = kFALSE;
TObjLink *lnk = FirstLink();
TObjLink *savlnk;
while (lnk) {
connection = (TQConnection*)lnk->GetObject();
const char *name = connection->GetName();
void *obj = connection->GetReceiver();
if (!slot_name || !strlen(slot_name)
|| !strcmp(name,slot_name)) {
if (!receiver || (receiver == obj)) {
return_value = kTRUE;
savlnk = lnk->Next();
Remove(lnk);
lnk = savlnk;
connection->Remove(this);
if (connection->IsEmpty()) SafeDelete(connection);
continue;
}
}
lnk = lnk->Next();
}
return return_value;
}
void TQConnectionList::ls(Option_t *option) const
{
cout << "TQConnectionList:" << "\t" << GetName() << endl;
((TQConnectionList*)this)->R__FOR_EACH(TQConnection,Print)(option);
}
TQObject::TQObject()
{
fListOfSignals = 0;
fListOfConnections = 0;
fSignalsBlocked = kFALSE;
}
TQObject::~TQObject()
{
if (!gROOT) return;
Destroyed();
if (fListOfSignals) {
fListOfSignals->Delete();
SafeDelete(fListOfSignals);
}
if (fListOfConnections) {
TIter next_connection(fListOfConnections);
TQConnection *connection;
while ((connection = (TQConnection*)next_connection())) {
TIter next_list(connection);
TQConnectionList *list;
while ((list = (TQConnectionList*)next_list())) {
list->Remove(connection);
if (list->IsEmpty()) SafeDelete(list);
}
}
SafeDelete(fListOfConnections);
}
}
TList *TQObject::GetListOfClassSignals() const
{
TQClass *qcl = 0;
qcl = dynamic_cast<TQClass*>(IsA());
return qcl ? qcl->fListOfSignals : 0;
}
void TQObject::CollectClassSignalLists(TList& list, TClass* cls)
{
TQClass *qcl = dynamic_cast<TQClass*>(cls);
if (qcl)
{
if (qcl->fListOfSignals)
list.Add(qcl->fListOfSignals);
TIter next_base_class(cls->GetListOfBases());
TBaseClass *base;
while ((base = (TBaseClass*) next_base_class()))
{
CollectClassSignalLists(list, base->GetClassPointer());
}
}
}
void TQObject::HighPriority(const char *signal_name, const char *slot_name)
{
TQConnectionList *clist = (TQConnectionList*)
fListOfSignals->FindObject(signal_name);
if (!clist) return;
if (!slot_name) {
fListOfSignals->Remove(clist);
fListOfSignals->AddFirst(clist);
return;
} else {
TQConnection *con = (TQConnection*) clist->FindObject(slot_name);
if (!con) return;
clist->Remove(con);
clist->AddFirst(con);
}
}
void TQObject::LowPriority(const char *signal_name, const char *slot_name)
{
TQConnectionList *clist = (TQConnectionList*)
fListOfSignals->FindObject(signal_name);
if (!clist) return;
if (!slot_name) {
fListOfSignals->Remove(clist);
fListOfSignals->AddLast(clist);
return;
} else {
TQConnection *con = (TQConnection*) clist->FindObject(slot_name);
if (!con) return;
clist->Remove(con);
clist->AddLast(con);
}
}
Bool_t TQObject::HasConnection(const char *signal_name) const
{
if (!fListOfSignals)
return kFALSE;
TString signal = CompressName(signal_name);
return (fListOfSignals->FindObject(signal) != 0);
}
Int_t TQObject::NumberOfSignals() const
{
if (fListOfSignals)
return fListOfSignals->GetSize();
return 0;
}
Int_t TQObject::NumberOfConnections() const
{
if (fListOfConnections)
return fListOfConnections->GetSize();
return 0;
}
void TQObject::Emit(const char *signal_name)
{
if (fSignalsBlocked || fgAllSignalsBlocked) return;
TList classSigLists;
CollectClassSignalLists(classSigLists, IsA());
if (classSigLists.IsEmpty() && !fListOfSignals)
return;
TString signal = CompressName(signal_name);
register TQConnection *connection = 0;
TList *sigList;
TIter nextSigList(&classSigLists);
while ((sigList = (TList*) nextSigList()))
{
TIter nextcl((TQConnectionList*) sigList->FindObject(signal));
while ((connection = (TQConnection*)nextcl())) {
gTQSender = GetSender();
connection->ExecuteMethod();
}
}
if (!fListOfSignals)
return;
TIter next((TQConnectionList*) fListOfSignals->FindObject(signal));
while (fListOfSignals && (connection = (TQConnection*)next())) {
gTQSender = GetSender();
connection->ExecuteMethod();
}
}
void TQObject::EmitVA(const char *signal_name, Int_t va_(nargs), ...)
{
va_list ap;
va_start(ap, va_(nargs));
EmitVA(signal_name, va_(nargs), ap);
va_end(ap);
}
void TQObject::EmitVA(const char *signal_name, Int_t nargs, va_list ap)
{
if (fSignalsBlocked || fgAllSignalsBlocked) return;
TList classSigLists;
CollectClassSignalLists(classSigLists, IsA());
if (classSigLists.IsEmpty() && !fListOfSignals)
return;
TString signal = CompressName(signal_name);
register TQConnection *connection = 0;
TList *sigList;
TIter nextSigList(&classSigLists);
while ((sigList = (TList*) nextSigList()))
{
TIter nextcl((TQConnectionList*) sigList->FindObject(signal));
while ((connection = (TQConnection*)nextcl())) {
gTQSender = GetSender();
connection->ExecuteMethod(nargs, ap);
}
}
if (!fListOfSignals)
return;
TIter next((TQConnectionList*) fListOfSignals->FindObject(signal));
while (fListOfSignals && (connection = (TQConnection*)next())) {
gTQSender = GetSender();
connection->ExecuteMethod(nargs, ap);
}
}
void TQObject::Emit(const char *signal_name, Long_t param)
{
if (fSignalsBlocked || fgAllSignalsBlocked) return;
TList classSigLists;
CollectClassSignalLists(classSigLists, IsA());
if (classSigLists.IsEmpty() && !fListOfSignals)
return;
TString signal = CompressName(signal_name);
register TQConnection *connection = 0;
TList *sigList;
TIter nextSigList(&classSigLists);
while ((sigList = (TList*) nextSigList()))
{
TIter nextcl((TQConnectionList*) sigList->FindObject(signal));
while ((connection = (TQConnection*)nextcl())) {
gTQSender = GetSender();
connection->ExecuteMethod(param);
}
}
if (!fListOfSignals)
return;
TIter next((TQConnectionList*) fListOfSignals->FindObject(signal));
while (fListOfSignals && (connection = (TQConnection*)next())) {
gTQSender = GetSender();
connection->ExecuteMethod(param);
}
}
void TQObject::Emit(const char *signal_name, Long64_t param)
{
if (fSignalsBlocked || fgAllSignalsBlocked) return;
TList classSigLists;
CollectClassSignalLists(classSigLists, IsA());
if (classSigLists.IsEmpty() && !fListOfSignals)
return;
TString signal = CompressName(signal_name);
register TQConnection *connection = 0;
TList *sigList;
TIter nextSigList(&classSigLists);
while ((sigList = (TList*) nextSigList()))
{
TIter nextcl((TQConnectionList*) sigList->FindObject(signal));
while ((connection = (TQConnection*)nextcl())) {
gTQSender = GetSender();
connection->ExecuteMethod(param);
}
}
if (!fListOfSignals)
return;
TIter next((TQConnectionList*) fListOfSignals->FindObject(signal));
while (fListOfSignals && (connection = (TQConnection*)next())) {
gTQSender = GetSender();
connection->ExecuteMethod(param);
}
}
void TQObject::Emit(const char *signal_name, Double_t param)
{
if (fSignalsBlocked || fgAllSignalsBlocked) return;
TList classSigLists;
CollectClassSignalLists(classSigLists, IsA());
if (classSigLists.IsEmpty() && !fListOfSignals)
return;
TString signal = CompressName(signal_name);
register TQConnection *connection = 0;
TList *sigList;
TIter nextSigList(&classSigLists);
while ((sigList = (TList*) nextSigList()))
{
TIter nextcl((TQConnectionList*) sigList->FindObject(signal));
while ((connection = (TQConnection*)nextcl())) {
gTQSender = GetSender();
connection->ExecuteMethod(param);
}
}
if (!fListOfSignals)
return;
TIter next((TQConnectionList*) fListOfSignals->FindObject(signal));
while (fListOfSignals && (connection = (TQConnection*)next())) {
gTQSender = GetSender();
connection->ExecuteMethod(param);
}
}
void TQObject::Emit(const char *signal_name, const char *params)
{
if (fSignalsBlocked || fgAllSignalsBlocked) return;
TList classSigLists;
CollectClassSignalLists(classSigLists, IsA());
if (classSigLists.IsEmpty() && !fListOfSignals)
return;
TString signal = CompressName(signal_name);
register TQConnection *connection = 0;
TList *sigList;
TIter nextSigList(&classSigLists);
while ((sigList = (TList*) nextSigList()))
{
TIter nextcl((TQConnectionList*) sigList->FindObject(signal));
while ((connection = (TQConnection*)nextcl())) {
gTQSender = GetSender();
connection->ExecuteMethod(params);
}
}
if (!fListOfSignals)
return;
TIter next((TQConnectionList*) fListOfSignals->FindObject(signal));
while (fListOfSignals && (connection = (TQConnection*)next())) {
gTQSender = GetSender();
connection->ExecuteMethod(params);
}
}
void TQObject::Emit(const char *signal_name, Long_t *paramArr)
{
if (fSignalsBlocked || fgAllSignalsBlocked) return;
TList classSigLists;
CollectClassSignalLists(classSigLists, IsA());
if (classSigLists.IsEmpty() && !fListOfSignals)
return;
TString signal = CompressName(signal_name);
register TQConnectionList *clist = 0;
register TQConnection *connection = 0;
TList *sigList;
TIter nextSigList(&classSigLists);
while ((sigList = (TList*) nextSigList()))
{
clist = (TQConnectionList*) sigList->FindObject(signal);
TIter nextcl(clist);
while ((connection = (TQConnection*)nextcl())) {
gTQSender = GetSender();
connection->ExecuteMethod(paramArr, clist->GetNargs());
}
}
if (!fListOfSignals)
return;
clist = (TQConnectionList*) fListOfSignals->FindObject(signal);
TIter next(clist);
while (fListOfSignals && (connection = (TQConnection*)next())) {
gTQSender = GetSender();
connection->ExecuteMethod(paramArr, clist->GetNargs());
}
}
Bool_t TQObject::ConnectToClass(TQObject *sender,
const char *signal,
TClass *cl,
void *receiver,
const char *slot)
{
if (!sender->IsA()->InheritsFrom(TQObject::Class()))
return kFALSE;
TString signal_name = CompressName(signal);
TString slot_name = CompressName(slot);
Int_t nsigargs;
if ((nsigargs = CheckConnectArgs(sender, sender->IsA(), signal_name, cl, slot_name)) == -1)
return kFALSE;
if (!sender->fListOfSignals)
sender->fListOfSignals = new THashList();
TQConnectionList *clist = (TQConnectionList*)
sender->fListOfSignals->FindObject(signal_name);
if (!clist) {
clist = new TQConnectionList(signal_name, nsigargs);
sender->fListOfSignals->Add(clist);
}
TIter next(clist);
TQConnection *connection = 0;
while ((connection = (TQConnection*)next())) {
if (!strcmp(slot_name,connection->GetName()) &&
(receiver == connection->GetReceiver())) break;
}
if (!connection)
connection = new TQConnection(cl, receiver, slot_name);
if (!clist->FindObject(connection)) {
clist->Add(connection);
if (!connection->FindObject(clist)) connection->Add(clist);
sender->Connected(signal_name);
}
return kTRUE;
}
Bool_t TQObject::ConnectToClass(const char *class_name,
const char *signal,
TClass *cl,
void *receiver,
const char *slot)
{
TClass *sender = TClass::GetClass(class_name);
if (!sender || !sender->IsA()->InheritsFrom(TQObject::Class()))
return kFALSE;
TList *slist = ((TQClass*)sender)->fListOfSignals;
TString signal_name = CompressName(signal);
TString slot_name = CompressName(slot);
Int_t nsigargs;
if ((nsigargs = CheckConnectArgs(0, sender, signal_name, cl, slot_name)) == -1)
return kFALSE;
if (!slist)
((TQClass*)sender)->fListOfSignals = slist = new THashList();
TQConnectionList *clist = (TQConnectionList*) slist->FindObject(signal_name);
if (!clist) {
clist = new TQConnectionList(signal_name, nsigargs);
slist->Add(clist);
}
TQConnection *connection = 0;
TIter next(clist);
while ((connection = (TQConnection*)next())) {
if (!strcmp(slot_name,connection->GetName()) &&
(receiver == connection->GetReceiver())) break;
}
if (!connection)
connection = new TQConnection(cl, receiver, slot_name);
if (!clist->FindObject(connection)) {
clist->Add(connection);
if (!connection->FindObject(clist)) connection->Add(clist);
((TQClass*)sender)->Connected(signal_name);
}
return kTRUE;
}
Bool_t TQObject::Connect(TQObject *sender,
const char *signal,
const char *cl,
void *receiver,
const char *slot)
{
if (cl) {
TClass *rcv_cl = TClass::GetClass(cl);
if (rcv_cl) return ConnectToClass(sender, signal, rcv_cl, receiver, slot);
}
if (!sender->IsA()->InheritsFrom(TQObject::Class()))
return kFALSE;
TString signal_name = CompressName(signal);
TString slot_name = CompressName(slot);
Int_t nsigargs;
if ((nsigargs = CheckConnectArgs(sender, sender->IsA(), signal_name, 0, slot_name)) == -1)
return kFALSE;
if (!sender->fListOfSignals) sender->fListOfSignals = new THashList();
TQConnectionList *clist = (TQConnectionList*)
sender->fListOfSignals->FindObject(signal_name);
if (!clist) {
clist = new TQConnectionList(signal_name, nsigargs);
sender->fListOfSignals->Add(clist);
}
TQConnection *connection = 0;
TIter next(clist);
while ((connection = (TQConnection*)next())) {
if (!strcmp(slot_name,connection->GetName()) &&
(receiver == connection->GetReceiver())) break;
}
if (!connection)
connection = new TQConnection(cl, receiver, slot_name);
if (!clist->FindObject(connection)) {
clist->Add(connection);
if (!connection->FindObject(clist)) connection->Add(clist);
sender->Connected(signal_name);
}
return kTRUE;
}
Bool_t TQObject::Connect(const char *class_name,
const char *signal,
const char *cl,
void *receiver,
const char *slot)
{
if (cl) {
TClass *rcv_cl = TClass::GetClass(cl);
if (rcv_cl) return ConnectToClass(class_name, signal, rcv_cl, receiver,
slot);
}
TClass *sender = TClass::GetClass(class_name);
if (!sender || !sender->IsA()->InheritsFrom(TQObject::Class()))
return kFALSE;
TList *slist = ((TQClass*)sender)->fListOfSignals;
TString signal_name = CompressName(signal);
TString slot_name = CompressName(slot);
Int_t nsigargs;
if ((nsigargs = CheckConnectArgs(0, sender, signal_name, 0, slot_name)) == -1)
return kFALSE;
if (!slist) {
slist = ((TQClass*)sender)->fListOfSignals = new THashList();
}
TQConnectionList *clist = (TQConnectionList*)
slist->FindObject(signal_name);
if (!clist) {
clist = new TQConnectionList(signal_name, nsigargs);
slist->Add(clist);
}
TQConnection *connection = 0;
TIter next(clist);
while ((connection = (TQConnection*)next())) {
if (!strcmp(slot_name,connection->GetName()) &&
(receiver == connection->GetReceiver())) break;
}
if (!connection)
connection = new TQConnection(cl, receiver, slot_name);
if (!clist->FindObject(connection)) {
clist->Add(connection);
if (!connection->FindObject(clist)) connection->Add(clist);
((TQClass*)sender)->Connected(signal_name);
}
return kTRUE;
}
Bool_t TQObject::Connect(const char *signal,
const char *receiver_class,
void *receiver,
const char *slot)
{
TString signal_name = CompressName(signal);
TString slot_name = CompressName(slot);
TClass *cl = 0;
if (receiver_class)
cl = TClass::GetClass(receiver_class);
Int_t nsigargs;
if ((nsigargs = CheckConnectArgs(this, IsA(), signal_name, cl, slot_name)) == -1)
return kFALSE;
if (!fListOfSignals) fListOfSignals = new THashList();
TQConnectionList *clist = (TQConnectionList*)
fListOfSignals->FindObject(signal_name);
if (!clist) {
clist = new TQConnectionList(signal_name, nsigargs);
fListOfSignals->Add(clist);
}
TIter next(clist);
TQConnection *connection = 0;
while ((connection = (TQConnection*)next())) {
if (!strcmp(slot_name,connection->GetName()) &&
(receiver == connection->GetReceiver())) break;
}
if (!connection)
connection = new TQConnection(receiver_class, receiver, slot_name);
if (!clist->FindObject(connection)) {
clist->Add(connection);
if (!connection->FindObject(clist)) connection->Add(clist);
Connected(signal_name);
}
return kTRUE;
}
Bool_t TQObject::Disconnect(TQObject *sender,
const char *signal,
void *receiver,
const char *slot)
{
Bool_t return_value = kFALSE;
Bool_t next_return = kFALSE;
if (!sender->GetListOfSignals()) return kFALSE;
TString signal_name = CompressName(signal);
TString slot_name = CompressName(slot);
TQConnectionList *slist = 0;
TIter next_signal(sender->GetListOfSignals());
while ((slist = (TQConnectionList*)next_signal())) {
if (!signal_name) {
next_return = slist->Disconnect(receiver,slot_name);
return_value = return_value || next_return;
if (slist->IsEmpty()) {
sender->GetListOfSignals()->Remove(slist);
SafeDelete(slist);
}
} else if (signal && !strcmp(signal_name,slist->GetName())) {
next_return = slist->Disconnect(receiver,slot_name);
return_value = return_value || next_return;
if (slist->IsEmpty()) {
sender->GetListOfSignals()->Remove(slist);
SafeDelete(slist);
break;
}
}
}
if (sender->GetListOfSignals() && sender->GetListOfSignals()->IsEmpty()) {
SafeDelete(sender->fListOfSignals);
}
return return_value;
}
Bool_t TQObject::Disconnect(const char *class_name,
const char *signal,
void *receiver,
const char *slot)
{
TClass *sender = TClass::GetClass(class_name);
if (!sender->IsA()->InheritsFrom(TQObject::Class()))
return kFALSE;
TQClass *qcl = (TQClass*)sender;
return Disconnect(qcl, signal, receiver, slot);
}
Bool_t TQObject::Disconnect(const char *signal,
void *receiver,
const char *slot)
{
return Disconnect(this, signal, receiver, slot);
}
void TQObject::Streamer(TBuffer &R__b)
{
if (R__b.IsReading()) {
} else {
}
}
Bool_t TQObject::AreAllSignalsBlocked()
{
return fgAllSignalsBlocked;
}
Bool_t TQObject::BlockAllSignals(Bool_t b)
{
Bool_t ret = fgAllSignalsBlocked;
fgAllSignalsBlocked = b;
return ret;
}
void TQObject::LoadRQ_OBJECT()
{
gCint->LoadText(RQ_OBJECT_STRING1);
gCint->LoadText(RQ_OBJECT_STRING2);
gCint->LoadText(RQ_OBJECT_STRING);
}
Bool_t ConnectCINT(TQObject *sender, const char *signal, const char *slot)
{
TString str = "ProcessLine(=";
str += '"';
str += slot;
str += '"';
str += ")";
return TQObject::Connect(sender, signal, "TInterpreter",
gInterpreter, str.Data());
}
Last change: Tue Dec 2 17:26:54 2008
Last generated: 2008-12-02 17:26
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.