Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TQConnection.h
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Valeriy Onuchin & Fons Rademakers 15/10/2000
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TQConnection
13#define ROOT_TQConnection
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TQConnection class is an internal class, used in the object //
18// communication mechanism. //
19// //
20// TQConnection: //
21// - is a list of signal_lists containing pointers //
22// to this connection //
23// - receiver is the object to which slot-method is applied //
24// //
25// This implementation is provided by //
26// Valeriy Onuchin (onuchin@sirius.ihep.su). //
27// //
28//////////////////////////////////////////////////////////////////////////
29
30#include "TInterpreter.h"
31#include "TQObject.h"
32#include "TVirtualQConnection.h"
33
34class TQSlot;
35
36
38protected:
39 TQSlot *fSlot = 0; // slot-method calling interface
40 void *fReceiver = 0; // ptr to object to which slot is applied
41 TString fClassName; // class name of the receiver
42
43 virtual void PrintCollectionHeader(Option_t* option) const override;
44
45 Bool_t CheckSlot(Int_t nargs) const;
46 void *GetSlotAddress() const;
47 CallFunc_t *LockSlot() const;
48 void UnLockSlot(TQSlot *) const;
49 virtual CallFunc_t *GetSlotCallFunc() const override;
50
52
53 virtual void SetArg(Long_t param) override { SetArgImpl(param); }
54 virtual void SetArg(ULong_t param) override { SetArgImpl(param); }
55 virtual void SetArg(Float_t param) override { SetArgImpl(param); }
56 virtual void SetArg(Double_t param) override { SetArgImpl(param); }
57 virtual void SetArg(Long64_t param) override { SetArgImpl(param); }
58 virtual void SetArg(ULong64_t param) override { SetArgImpl(param); }
59 virtual void SetArg(const char * param) override { SetArgImpl(param); }
60
61 virtual void SetArg(const Long_t *params, Int_t nparam = -1) override;
62
63 template <typename T> void SetArgImpl(T arg)
64 {
65 CallFunc_t *func = GetSlotCallFunc();
66 gInterpreter->CallFunc_SetArg(func, arg);
67 }
68
69 virtual void SendSignal() override
70 {
71 CallFunc_t *func = LockSlot();
72
73 void *address = GetSlotAddress();
74 TQSlot *s = fSlot;
75
76 gInterpreter->CallFunc_Exec(func, address);
77
78 UnLockSlot(s);
79 };
80
81public:
83 TQConnection(TClass* cl, void *receiver, const char *method_name);
84 TQConnection(const char *class_name, void *receiver,
85 const char *method_name);
86 TQConnection(const TQConnection &con);
87 virtual ~TQConnection();
88
89 const char *GetName() const override;
90 void *GetReceiver() const { return fReceiver; }
91 const char *GetClassName() const { return fClassName; }
92 void Destroyed() override; // *SIGNAL*
93
94 void ExecuteMethod(Int_t nargs, va_list va) = delete;
95 template <typename... T> inline void ExecuteMethod(const T&... params)
96 {
97 if (!CheckSlot(sizeof...(params))) return;
98 SetArgs(params...);
99 SendSignal();
100 }
101
102 template <typename... T> inline void ExecuteMethod(Int_t /* nargs */, const T&... params)
103 {
104 ExecuteMethod(params...);
105 }
106
107 // FIXME: Remove and fallback to the variadic template.
108 // FIXME: Remove duplication of code in SendSignal and ExecuteMethod overloads.
109 void ExecuteMethod();
110 void ExecuteMethod(Long_t param);
111 void ExecuteMethod(Long64_t param);
112 void ExecuteMethod(Double_t param);
113 void ExecuteMethod(Long_t *params, Int_t nparam = -1);
114 void ExecuteMethod(const char *params);
115 void ls(Option_t *option="") const override;
116
117 ClassDefOverride(TQConnection,0) // Internal class used in the object communication mechanism
118};
119
120R__EXTERN char *gTQSlotParams; // used to pass string parameters
121
122#endif
#define R__EXTERN
Definition DllImport.h:27
int Int_t
Definition RtypesCore.h:45
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:73
unsigned long long ULong64_t
Definition RtypesCore.h:74
float Float_t
Definition RtypesCore.h:57
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:329
#define gInterpreter
R__EXTERN char * gTQSlotParams
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
TQConnection class is an internal class, used in the object communication mechanism.
virtual void SetArg(Float_t param) override
void * GetSlotAddress() const
Return the object address to be passed to the function.
virtual CallFunc_t * GetSlotCallFunc() const override
void ExecuteMethod()
Apply slot-method to the fReceiver object without arguments.
void UnLockSlot(TQSlot *) const
Unlock the interpreter and mark the slot as no longer executing.
void * fReceiver
const char * GetClassName() const
virtual void PrintCollectionHeader(Option_t *option) const override
Print TQConnection full method name and print all signals connected to this connection.
CallFunc_t * LockSlot() const
Lock the interpreter and mark the slot as executing.
void Destroyed() override
Signal Destroyed tells that connection is destroyed.
virtual void SetArg(ULong64_t param) override
void SetArgImpl(T arg)
void * GetReceiver() const
virtual void SetArg(Long_t param) override
TString fClassName
Bool_t CheckSlot(Int_t nargs) const
Return true if the underlying method is value and the number of argument is compatible.
TQConnection & operator=(const TQConnection &)=delete
void ExecuteMethod(Int_t, const T &... params)
virtual void SendSignal() override
TQSlot * fSlot
virtual void SetArg(ULong_t param) override
const char * GetName() const override
Returns name of connection (aka name of slot)
virtual ~TQConnection()
TQConnection dtor.
virtual void SetArg(Long64_t param) override
void ExecuteMethod(const T &... params)
void ExecuteMethod(Int_t nargs, va_list va)=delete
virtual void SetArg(const char *param) override
void ls(Option_t *option="") const override
List TQConnection full method name and list all signals connected to this connection.
virtual void SetArg(Double_t param) override
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition TQObject.h:48
Basic string class.
Definition TString.h:136
Mediates the link between the signal and the slot.
void SetArgs(const T &... args)
Unpacks the template parameter type and sets arguments of integral and array (scalar) type.