Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RQ_OBJECT.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/base:$Id$
0002 // Author: Valeriy Onuchin & Fons Rademakers   15/10/2000
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_RQ_OBJECT
0013 #define ROOT_RQ_OBJECT
0014 
0015 #include <TQObject.h>
0016 #include <Varargs.h>
0017 
0018 
0019 //---- RQ_OBJECT macro -----------------------------------------------
0020 //
0021 // Macro is used to delegate TQObject methods to other classes
0022 // Example:
0023 //
0024 //    #include "RQ_OBJECT.h"
0025 //
0026 //    class A {
0027 //       RQ_OBJECT("A")
0028 //    private:
0029 //       Int_t fValue;
0030 //    public:
0031 //       A() : fValue(0) { }
0032 //       ~A() { }
0033 //
0034 //       void  SetValue(Int_t value)
0035 //       void  PrintValue() const { printf("value=%d\n", fValue); }
0036 //       Int_t GetValue() const { return fValue; }
0037 //    };
0038 //
0039 //    void A::SetValue(Int_t value)
0040 //    {
0041 //       // Sets new value
0042 //
0043 //       // to prevent infinite looping in the case
0044 //       // of cyclic connections
0045 //       if (value != fValue) {
0046 //          fValue = value;
0047 //          Emit("SetValue(Int_t)", fValue);
0048 //       }
0049 //    }
0050 //
0051 // Load this class into root session and try the following:
0052 //
0053 // a = new A();
0054 // b = new A();
0055 //
0056 // Here is one way to connect two of these objects together:
0057 //
0058 // a->Connect("SetValue(Int_t)", "A", b, "SetValue(Int_t)");
0059 //
0060 // Calling a->SetValue(79) will make a emit a signal, which b
0061 // will receive, i.e. b->SetValue(79) is invoked. b will in
0062 // turn emit the same signal, which nobody receives, since no
0063 // slot has been connected to it, so it disappears into hyperspace.
0064 //
0065 
0066 #define RQ_OBJECT1(sender_class)\
0067 private:\
0068 TQObjSender fQObject;\
0069 public:\
0070 TList *GetListOfSignals() const {return fQObject.GetListOfSignals();}\
0071 Bool_t Connect(const char *sig,const char *cl,void *rcvr,const char *slt)\
0072 {fQObject.SetSender(this);fQObject.SetSenderClassName(sender_class);return fQObject.Connect(sig,cl,rcvr,slt);}\
0073 Bool_t Disconnect(const char *sig=nullptr,void *rcvr=nullptr,const char *slt=nullptr){return fQObject.Disconnect(sig,rcvr,slt);}\
0074 void HighPriority(const char *signal_name,const char *slot_name=nullptr){fQObject.HighPriority(signal_name,slot_name);}\
0075 void LowPriority(const char *signal_name,const char *slot_name=nullptr){fQObject.LowPriority(signal_name,slot_name);}\
0076 template <typename... T> void EmitVA(const char *signal_name, Int_t nargs, const T&... params) \
0077 { fQObject.EmitVA(signal_name,nargs,params...); } \
0078 void Emit(const char *signal){EmitVA(signal, /*nargs*/0);} \
0079 template <typename T> void Emit(const char *signal, const T& arg) { EmitVA(signal, /*nargs*/ 1, arg); } \
0080 
0081 #define RQ_OBJECT2(sender_class)\
0082 void Destroyed(){Emit("Destroyed()");}\
0083 void ChangedBy(const char *method){Emit("ChangedBy(char*)",method);}\
0084 void Message(const char *msg){Emit("Message(char*)",msg);}\
0085 private:
0086 
0087 #define RQ_OBJECT(sender_class)\
0088    RQ_OBJECT1(sender_class)\
0089    RQ_OBJECT2(sender_class)
0090 
0091 #endif