Logo ROOT  
Reference Guide
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
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:43
unsigned long ULong_t
Definition: RtypesCore.h:53
long Long_t
Definition: RtypesCore.h:52
double Double_t
Definition: RtypesCore.h:57
long long Long64_t
Definition: RtypesCore.h:71
unsigned long long ULong64_t
Definition: RtypesCore.h:72
float Float_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:64
#define ClassDefOverride(name, id)
Definition: Rtypes.h:326
#define gInterpreter
Definition: TInterpreter.h:556
R__EXTERN char * gTQSlotParams
Definition: TQConnection.h:120
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.
Definition: TQConnection.h:37
virtual void SetArg(Float_t param) override
Definition: TQConnection.h:55
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
Definition: TQConnection.h:40
const char * GetClassName() const
Definition: TQConnection.h:91
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
Definition: TQConnection.h:58
void SetArgImpl(T arg)
Definition: TQConnection.h:63
void * GetReceiver() const
Definition: TQConnection.h:90
virtual void SetArg(Long_t param) override
Definition: TQConnection.h:53
TString fClassName
Definition: TQConnection.h:41
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)
Definition: TQConnection.h:102
virtual void SendSignal() override
Definition: TQConnection.h:69
TQSlot * fSlot
Definition: TQConnection.h:39
virtual void SetArg(ULong_t param) override
Definition: TQConnection.h:54
const char * GetName() const override
Returns name of connection (aka name of slot)
virtual ~TQConnection()
TQConnection dtor.
virtual void SetArg(Long64_t param) override
Definition: TQConnection.h:57
void ExecuteMethod(const T &... params)
Definition: TQConnection.h:95
void ExecuteMethod(Int_t nargs, va_list va)=delete
virtual void SetArg(const char *param) override
Definition: TQConnection.h:59
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
Definition: TQConnection.h:56
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:131
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.
double T(double x)
Definition: ChebyshevPol.h:34
static constexpr double s