Logo ROOT   6.10/09
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 
34 class TQSlot;
35 
36 
37 class TQConnection : public TVirtualQConnection, public TQObject {
38 protected:
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 
51  TQConnection &operator=(const TQConnection &) = delete;
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 
81 public:
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 
120 R__EXTERN char *gTQSlotParams; // used to pass string parameters
121 
122 #endif
TString fClassName
Definition: TQConnection.h:41
long long Long64_t
Definition: RtypesCore.h:69
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
double T(double x)
Definition: ChebyshevPol.h:34
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:49
virtual void PrintCollectionHeader(Option_t *option) const override
Print TQConnection full method name and print all signals connected to this connection.
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
#define gInterpreter
Definition: TInterpreter.h:499
void UnLockSlot(TQSlot *) const
Unlock the interpreter and mark the slot as no longer executing.
virtual void SetArg(Double_t param) override
Definition: TQConnection.h:56
void * GetReceiver() const
Definition: TQConnection.h:90
void SetArgs(const T &... args)
Unpacks the template parameter type and sets arguments of integral and array (scalar) type...
void Destroyed() override
Signal Destroyed tells that connection is destroyed.
virtual void SetArg(Long64_t param) override
Definition: TQConnection.h:57
void SetArgImpl(T arg)
Definition: TQConnection.h:63
virtual ~TQConnection()
TQConnection dtor.
TQConnection & operator=(const TQConnection &)=delete
void ExecuteMethod(Int_t, const T &... params)
Definition: TQConnection.h:102
R__EXTERN char * gTQSlotParams
Definition: TQConnection.h:120
TQConnection class is an internal class, used in the object communication mechanism.
Definition: TQConnection.h:37
virtual void SetArg(Long_t param) override
Definition: TQConnection.h:53
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
void ExecuteMethod()
Apply slot-method to the fReceiver object without arguments.
Bool_t CheckSlot(Int_t nargs) const
Return true if the underlying method is value and the number of argument is compatible.
long Long_t
Definition: RtypesCore.h:50
void ExecuteMethod(const T &... params)
Definition: TQConnection.h:95
double Double_t
Definition: RtypesCore.h:55
virtual void SetArg(Float_t param) override
Definition: TQConnection.h:55
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.
unsigned long long ULong64_t
Definition: RtypesCore.h:70
unsigned long ULong_t
Definition: RtypesCore.h:51
double func(double *x, double *p)
Definition: stressTF1.cxx:213
const char * GetName() const override
Returns name of connection (aka name of slot)
#define R__EXTERN
Definition: DllImport.h:27
virtual void SendSignal() override
Definition: TQConnection.h:69
void ls(Option_t *option="") const override
List TQConnection full method name and list all signals connected to this connection.
virtual void SetArg(ULong64_t param) override
Definition: TQConnection.h:58
#define ClassDefOverride(name, id)
Definition: Rtypes.h:301
TQSlot * fSlot
Definition: TQConnection.h:39
Mediates the link between the signal and the slot.
void * fReceiver
Definition: TQConnection.h:40
const char * GetClassName() const
Definition: TQConnection.h:91
virtual void SetArg(const char *param) override
Definition: TQConnection.h:59
virtual void SetArg(ULong_t param) override
Definition: TQConnection.h:54
virtual CallFunc_t * GetSlotCallFunc() const override