ROOT  6.06/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 #ifndef ROOT_TList
31 #include "TList.h"
32 #endif
33 #ifndef ROOT_TQObject
34 #include "TQObject.h"
35 #endif
36 #ifndef ROOT_Varargs
37 #include "Varargs.h"
38 #endif
39 #ifndef ROOT_TInterpreter
40 #include "TInterpreter.h"
41 #endif
42 
43 class TQSlot;
44 
45 
46 class TQConnection : public TList, public TQObject {
47 
48 protected:
49  TQSlot *fSlot; // slot-method calling interface
50  void *fReceiver; // ptr to object to which slot is applied
51  TString fClassName; // class name of the receiver
52 
53  virtual void PrintCollectionHeader(Option_t* option) const;
54 
55  Bool_t CheckSlot(Int_t nargs) const;
56  void *GetSlotAddress() const;
57  CallFunc_t *LockSlot() const;
58  void UnLockSlot(TQSlot *) const;
59 
60  TQConnection &operator=(const TQConnection &) = delete;
61 
62 public:
63  TQConnection();
64  TQConnection(TClass* cl, void *receiver, const char *method_name);
65  TQConnection(const char *class_name, void *receiver,
66  const char *method_name);
67  TQConnection(const TQConnection &con);
68  virtual ~TQConnection();
69 
70  const char *GetName() const;
71  void *GetReceiver() const { return fReceiver; }
72  const char *GetClassName() const { return fClassName; }
73  void Destroyed(); // *SIGNAL*
74  void ExecuteMethod();
75 
76  void ExecuteMethod(Int_t nargs, va_list va) = delete;
77 
78  template <typename... T> inline void ExecuteMethod(const T&... params)
79  {
80  if (!CheckSlot(sizeof...(params))) return;
81 
82  CallFunc_t *func = LockSlot();
83 
84  void *address = GetSlotAddress();
85  TQSlot *s = fSlot;
86 
87  gInterpreter->CallFunc_SetArguments(func,params...);
88  gInterpreter->CallFunc_Exec(func, address);
89 
90  UnLockSlot(s);
91  }
92 
93  template <typename... T> inline void ExecuteMethod(Int_t /* nargs */, const T&... params)
94  {
95  ExecuteMethod(params...);
96  }
97 
98  //void ExecuteMethod(Int_t nargs, va_list va);
99  void ExecuteMethod(Long_t param);
100  void ExecuteMethod(Long64_t param);
101  void ExecuteMethod(Double_t param);
102  void ExecuteMethod(Long_t *params, Int_t nparam = -1);
103  void ExecuteMethod(const char *params);
104  void ls(Option_t *option="") const;
105 
106  ClassDef(TQConnection,0) // Internal class used in the object communication mechanism
107 };
108 
109 R__EXTERN char *gTQSlotParams; // used to pass string parameters
110 
111 #ifndef ROOT_TQObjectEmitVA
112 #include "TQObjectEmitVA.h"
113 #endif
114 
115 #endif
TString fClassName
Definition: TQConnection.h:51
long long Long64_t
Definition: RtypesCore.h:69
Bool_t CheckSlot(Int_t nargs) const
Return true if the underlying method is value and the number of argument is compatible.
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:53
Basic string class.
Definition: TString.h:137
void ExecuteMethod(const T &...params)
Definition: TQConnection.h:78
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
#define gInterpreter
Definition: TInterpreter.h:502
void ls(Option_t *option="") const
List TQConnection full method name and list all signals connected to this connection.
TQConnection()
Default constructor.
#define ClassDef(name, id)
Definition: Rtypes.h:254
void * GetSlotAddress() const
Return the object address to be passed to the function.
void Destroyed()
Signal Destroyed tells that connection is destroyed.
void UnLockSlot(TQSlot *) const
Unlock the interpreter and mark the slot as no longer executing.
A doubly linked list.
Definition: TList.h:47
virtual ~TQConnection()
TQConnection dtor.
TQConnection & operator=(const TQConnection &)=delete
R__EXTERN char * gTQSlotParams
Definition: TQConnection.h:109
void ExecuteMethod(Int_t, const T &...params)
Definition: TQConnection.h:93
TQConnection class is an internal class, used in the object communication mechanism.
Definition: TQConnection.h:46
const char * GetName() const
Returns name of connection (aka name of slot)
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
const char * GetClassName() const
Definition: TQConnection.h:72
void ExecuteMethod()
Apply slot-method to the fReceiver object without arguments.
long Long_t
Definition: RtypesCore.h:50
double Double_t
Definition: RtypesCore.h:55
double func(double *x, double *p)
Definition: stressTF1.cxx:213
virtual void PrintCollectionHeader(Option_t *option) const
Print TQConnection full method name and print all signals connected to this connection.
#define R__EXTERN
Definition: DllImport.h:27
TQSlot * fSlot
Definition: TQConnection.h:49
CallFunc_t * LockSlot() const
Lock the interpreter and mark the slot as executing.
void * fReceiver
Definition: TQConnection.h:50
void * GetReceiver() const
Definition: TQConnection.h:71