Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TQConnection.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_TQConnection
0013 #define ROOT_TQConnection
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TQConnection class is an internal class, used in the object          //
0018 // communication mechanism.                                             //
0019 //                                                                      //
0020 // TQConnection:                                                        //
0021 //    -  is a list of signal_lists containing pointers                  //
0022 //       to this connection                                             //
0023 //    -  receiver is the object to which slot-method is applied         //
0024 //                                                                      //
0025 // This implementation is provided by                                   //
0026 // Valeriy Onuchin (onuchin@sirius.ihep.su).                            //
0027 //                                                                      //
0028 //////////////////////////////////////////////////////////////////////////
0029 
0030 #include "TInterpreter.h"
0031 #include "TQObject.h"
0032 #include "TVirtualQConnection.h"
0033 
0034 class TQSlot;
0035 
0036 
0037 class TQConnection : public TVirtualQConnection, public TQObject {
0038 protected:
0039    TQSlot  *fSlot = nullptr;       // slot-method calling interface
0040    void    *fReceiver = nullptr;   // ptr to object to which slot is applied
0041    TString  fClassName;  // class name of the receiver
0042 
0043    virtual void PrintCollectionHeader(Option_t* option) const override;
0044 
0045    Bool_t      CheckSlot(Int_t nargs) const;
0046    void       *GetSlotAddress() const;
0047    CallFunc_t *LockSlot() const;
0048    void        UnLockSlot(TQSlot *) const;
0049    CallFunc_t *GetSlotCallFunc() const override;
0050 
0051    TQConnection &operator=(const TQConnection &) = delete;
0052 
0053    void SetArg(Long_t param) override { SetArgImpl(param); }
0054    void SetArg(ULong_t param) override { SetArgImpl(param); }
0055    void SetArg(Float_t param) override { SetArgImpl(param); }
0056    void SetArg(Double_t param) override { SetArgImpl(param); }
0057    void SetArg(Long64_t param) override { SetArgImpl(param); }
0058    void SetArg(ULong64_t param) override { SetArgImpl(param); }
0059    void SetArg(const char * param) override { SetArgImpl(param); }
0060 
0061    void SetArg(const Longptr_t *params, Int_t nparam = -1) override;
0062 
0063    template <typename T> void SetArgImpl(T arg)
0064    {
0065       CallFunc_t *func = GetSlotCallFunc();
0066       gInterpreter->CallFunc_SetArg(func, arg);
0067    }
0068 
0069    void SendSignal() override
0070    {
0071       CallFunc_t *func = LockSlot();
0072 
0073       void *address = GetSlotAddress();
0074       TQSlot *s = fSlot;
0075 
0076       gInterpreter->CallFunc_Exec(func, address);
0077 
0078       UnLockSlot(s);
0079    };
0080 
0081 public:
0082    TQConnection() {}
0083    TQConnection(TClass* cl, void *receiver, const char *method_name);
0084    TQConnection(const char *class_name, void *receiver,
0085                 const char *method_name);
0086    TQConnection(const TQConnection &con);
0087    virtual ~TQConnection();
0088 
0089    const char *GetName() const override;
0090    void *GetReceiver() const { return fReceiver; }
0091    const char *GetClassName() const { return fClassName; }
0092    void Destroyed() override;         // *SIGNAL*
0093 
0094    void ExecuteMethod(Int_t nargs, va_list va) = delete;
0095    template <typename... T> inline void ExecuteMethod(const T&... params)
0096    {
0097       if (!CheckSlot(sizeof...(params))) return;
0098       SetArgs(params...);
0099       SendSignal();
0100    }
0101 
0102    template <typename... T> inline void ExecuteMethod(Int_t /* nargs */, const T&... params)
0103    {
0104       ExecuteMethod(params...);
0105    }
0106 
0107    // FIXME: Remove and fallback to the variadic template.
0108    // FIXME: Remove duplication of code in SendSignal and ExecuteMethod overloads.
0109    void ExecuteMethod();
0110    void ExecuteMethod(Long_t param);
0111    void ExecuteMethod(Long64_t param);
0112    void ExecuteMethod(Double_t param);
0113    void ExecuteMethod(Longptr_t *params, Int_t nparam = -1);
0114    void ExecuteMethod(const char *params);
0115    void ls(Option_t *option="") const override;
0116 
0117    ClassDefOverride(TQConnection,0) // Internal class used in the object communication mechanism
0118 };
0119 
0120 R__EXTERN char *gTQSlotParams; // used to pass string parameters
0121 
0122 #endif