ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RQ_OBJECT.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_RQ_OBJECT
13 #define ROOT_RQ_OBJECT
14 
15 #include <TQObject.h>
16 #include <Varargs.h>
17 
18 
19 //---- RQ_OBJECT macro -----------------------------------------------
20 //
21 // Macro is used to delegate TQObject methods to other classes
22 // Example:
23 //
24 // #include "RQ_OBJECT.h"
25 //
26 // class A {
27 // RQ_OBJECT("A")
28 // private:
29 // Int_t fValue;
30 // public:
31 // A() : fValue(0) { }
32 // ~A() { }
33 //
34 // void SetValue(Int_t value)
35 // void PrintValue() const { printf("value=%d\n", fValue); }
36 // Int_t GetValue() const { return fValue; }
37 // };
38 //
39 // void A::SetValue(Int_t value)
40 // {
41 // // Sets new value
42 //
43 // // to prevent infinite looping in the case
44 // // of cyclic connections
45 // if (value != fValue) {
46 // fValue = value;
47 // Emit("SetValue(Int_t)", fValue);
48 // }
49 // }
50 //
51 // Load this class into root session and try the folllowing:
52 //
53 // a = new A();
54 // b = new A();
55 //
56 // Here is one way to connect two of these objects together:
57 //
58 // a->Connect("SetValue(Int_t)", "A", b, "SetValue(Int_t)");
59 //
60 // Calling a->SetValue(79) will make a emit a signal, which b
61 // will receive, i.e. b->SetValue(79) is invoked. b will in
62 // turn emit the same signal, which nobody receives, since no
63 // slot has been connected to it, so it disappears into hyperspace.
64 //
65 
66 #define RQ_OBJECT1(sender_class)\
67 private:\
68 TQObjSender fQObject;\
69 public:\
70 TList *GetListOfSignals() const {return fQObject.GetListOfSignals();}\
71 Bool_t Connect(const char *sig,const char *cl,void *rcvr,const char *slt)\
72 {fQObject.SetSender(this);fQObject.SetSenderClassName(sender_class);return fQObject.Connect(sig,cl,rcvr,slt);}\
73 Bool_t Disconnect(const char *sig=0,void *rcvr=0,const char *slt=0){return fQObject.Disconnect(sig,rcvr,slt);}\
74 void HighPriority(const char *signal_name,const char *slot_name=0){fQObject.HighPriority(signal_name,slot_name);}\
75 void LowPriority(const char *signal_name,const char *slot_name=0){fQObject.LowPriority(signal_name,slot_name);}\
76 template <typename... T> void EmitVA(const char *signal_name, Int_t nargs, const T&... params) \
77 { fQObject.EmitVA(signal_name,nargs,params...); } \
78 void Emit(const char *signal){fQObject.Emit(signal);}\
79 void Emit(const char *signal,const char *params){fQObject.Emit(signal,params);}\
80 void Emit(const char *signal,Long_t *paramArr){fQObject.Emit(signal,paramArr);}\
81 void Emit(const char *signal,Double_t param){fQObject.Emit(signal,param);}\
82 void Emit(const char *signal,Long_t param){fQObject.Emit(signal,param);}
83 
84 #define RQ_OBJECT2(sender_class)\
85 void Emit(const char *signal,Long64_t param){fQObject.Emit(signal,param);}\
86 void Emit(const char *signal,ULong64_t param){fQObject.Emit(signal,param);}\
87 void Emit(const char *signal,Bool_t param){Emit(signal,(Long_t)param);}\
88 void Emit(const char *signal,Char_t param){Emit(signal,(Long_t)param);}\
89 void Emit(const char *signal,UChar_t param){Emit(signal,(Long_t)param);}\
90 void Emit(const char *signal,Short_t param){Emit(signal,(Long_t)param);}\
91 void Emit(const char *signal,UShort_t param){Emit(signal,(Long_t)param);}\
92 void Emit(const char *signal,Int_t param){Emit(signal,(Long_t)param);}\
93 void Emit(const char *signal,UInt_t param){Emit(signal,(Long_t)param);}\
94 void Emit(const char *signal,ULong_t param){Emit(signal,(Long_t)param);}\
95 void Emit(const char *signal,Float_t param){Emit(signal,(Double_t)param);}\
96 void Destroyed(){Emit("Destroyed()");}\
97 void ChangedBy(const char *method){Emit("ChangedBy(char*)",method);}\
98 void Message(const char *msg){Emit("Message(char*)",msg);}\
99 private:
100 
101 #define RQ_OBJECT(sender_class)\
102  RQ_OBJECT1(sender_class)\
103  RQ_OBJECT2(sender_class)
104 
105 #endif