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 
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
TQConnection::GetSlotCallFunc
virtual CallFunc_t * GetSlotCallFunc() const override
Definition: TQConnection.cxx:678
TQConnection::TQConnection
TQConnection()
Definition: TQConnection.h:82
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
gInterpreter
#define gInterpreter
Definition: TInterpreter.h:558
TQConnection::SetArgImpl
void SetArgImpl(T arg)
Definition: TQConnection.h:63
Float_t
float Float_t
Definition: RtypesCore.h:57
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
Int_t
int Int_t
Definition: RtypesCore.h:45
TQConnection::SetArg
virtual void SetArg(const char *param) override
Definition: TQConnection.h:59
TQConnection::operator=
TQConnection & operator=(const TQConnection &)=delete
TQConnection
Definition: TQConnection.h:37
TVirtualQConnection::SetArgs
void SetArgs(const T &... args)
Unpacks the template parameter type and sets arguments of integral and array (scalar) type.
Definition: TVirtualQConnection.h:75
TString
Definition: TString.h:136
ClassDefOverride
#define ClassDefOverride(name, id)
Definition: Rtypes.h:329
TQConnection::ExecuteMethod
void ExecuteMethod(Int_t, const T &... params)
Definition: TQConnection.h:102
TQConnection::fClassName
TString fClassName
Definition: TQConnection.h:41
TQConnection::~TQConnection
virtual ~TQConnection()
TQConnection dtor.
Definition: TQConnection.cxx:510
bool
TQConnection::PrintCollectionHeader
virtual void PrintCollectionHeader(Option_t *option) const override
Print TQConnection full method name and print all signals connected to this connection.
Definition: TQConnection.cxx:556
TQConnection::SetArg
virtual void SetArg(Long64_t param) override
Definition: TQConnection.h:57
TQConnection::CheckSlot
Bool_t CheckSlot(Int_t nargs) const
Return true if the underlying method is value and the number of argument is compatible.
Definition: TQConnection.cxx:649
TVirtualQConnection.h
TQObject.h
TQConnection::SetArg
virtual void SetArg(Float_t param) override
Definition: TQConnection.h:55
TQObject
Definition: TQObject.h:48
TQConnection::GetName
const char * GetName() const override
Returns name of connection (aka name of slot)
Definition: TQConnection.cxx:528
TQConnection::LockSlot
CallFunc_t * LockSlot() const
Lock the interpreter and mark the slot as executing.
Definition: TQConnection.cxx:664
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TQConnection::GetReceiver
void * GetReceiver() const
Definition: TQConnection.h:90
TQConnection::ExecuteMethod
void ExecuteMethod(const T &... params)
Definition: TQConnection.h:95
TQConnection::GetSlotAddress
void * GetSlotAddress() const
Return the object address to be passed to the function.
Definition: TQConnection.cxx:656
TQConnection::SetArg
virtual void SetArg(ULong64_t param) override
Definition: TQConnection.h:58
Long_t
long Long_t
Definition: RtypesCore.h:54
TQConnection::ls
void ls(Option_t *option="") const override
List TQConnection full method name and list all signals connected to this connection.
Definition: TQConnection.cxx:546
TQConnection::SetArg
virtual void SetArg(Double_t param) override
Definition: TQConnection.h:56
TQConnection::Destroyed
void Destroyed() override
Signal Destroyed tells that connection is destroyed.
Definition: TQConnection.cxx:536
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TQConnection::SendSignal
virtual void SendSignal() override
Definition: TQConnection.h:69
TQConnection::fSlot
TQSlot * fSlot
Definition: TQConnection.h:39
TQConnection::SetArg
virtual void SetArg(ULong_t param) override
Definition: TQConnection.h:54
ULong64_t
unsigned long long ULong64_t
Definition: RtypesCore.h:74
Double_t
double Double_t
Definition: RtypesCore.h:59
TQConnection::fReceiver
void * fReceiver
Definition: TQConnection.h:40
TInterpreter.h
TClass
Definition: TClass.h:80
TQConnection::ExecuteMethod
void ExecuteMethod()
Apply slot-method to the fReceiver object without arguments.
Definition: TQConnection.cxx:565
TQConnection::SetArg
virtual void SetArg(Long_t param) override
Definition: TQConnection.h:53
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:52
TVirtualQConnection
Mediates the link between the signal and the slot.
Definition: TVirtualQConnection.h:23
TQConnection::GetClassName
const char * GetClassName() const
Definition: TQConnection.h:91
R__EXTERN
#define R__EXTERN
Definition: DllImport.h:27
TQConnection::UnLockSlot
void UnLockSlot(TQSlot *) const
Unlock the interpreter and mark the slot as no longer executing.
Definition: TQConnection.cxx:672
gTQSlotParams
R__EXTERN char * gTQSlotParams
Definition: TQConnection.h:120
int