// @(#)root/base:$Id$
// Author: Valeriy Onuchin & Fons Rademakers   15/10/2000

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TQConnection
#define ROOT_TQConnection

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TQConnection class is an internal class, used in the object          //
// communication mechanism.                                             //
//                                                                      //
// TQConnection:                                                        //
//    -  is a list of signal_lists containing pointers                  //
//       to this connection                                             //
//    -  receiver is the object to which slot-method is applied         //
//                                                                      //
// This implementation is provided by                                   //
// Valeriy Onuchin (onuchin@sirius.ihep.su).                            //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TList
#include "TList.h"
#endif
#ifndef ROOT_TQObject
#include "TQObject.h"
#endif
#ifndef ROOT_Varargs
#include "Varargs.h"
#endif
#ifndef ROOT_TInterpreter
#include "TInterpreter.h"
#endif

class TQSlot;


class TQConnection : public TList, public TQObject {

protected:
   TQSlot  *fSlot;       // slot-method calling interface
   void    *fReceiver;   // ptr to object to which slot is applied
   TString  fClassName;  // class name of the receiver

   virtual void PrintCollectionHeader(Option_t* option) const;

   Bool_t      CheckSlot(Int_t nargs) const;
   void       *GetSlotAddress() const;
   CallFunc_t *LockSlot() const;
   void        UnLockSlot(TQSlot *) const;

   TQConnection &operator=(const TQConnection &) = delete;

public:
   TQConnection();
   TQConnection(TClass* cl, void *receiver, const char *method_name);
   TQConnection(const char *class_name, void *receiver,
                const char *method_name);
   TQConnection(const TQConnection &con);
   virtual ~TQConnection();

   const char *GetName() const;
   void *GetReceiver() const { return fReceiver; }
   const char *GetClassName() const { return fClassName; }
   void Destroyed();         // *SIGNAL*
   void ExecuteMethod();

   void ExecuteMethod(Int_t nargs, va_list va) = delete;

   template <typename... T> inline void ExecuteMethod(const T&... params)
   {
      if (!CheckSlot(sizeof...(params))) return;

      CallFunc_t *func = LockSlot();

      void *address = GetSlotAddress();
      TQSlot *s = fSlot;

      gInterpreter->CallFunc_SetArguments(func,params...);
      gInterpreter->CallFunc_Exec(func, address);

      UnLockSlot(s);
   }

   template <typename... T> inline void ExecuteMethod(Int_t /* nargs */, const T&... params)
   {
      ExecuteMethod(params...);
   }

   //void ExecuteMethod(Int_t nargs, va_list va);
   void ExecuteMethod(Long_t param);
   void ExecuteMethod(Long64_t param);
   void ExecuteMethod(Double_t param);
   void ExecuteMethod(Long_t *params, Int_t nparam = -1);
   void ExecuteMethod(const char *params);
   void ls(Option_t *option="") const;

   ClassDef(TQConnection,0) // Internal class used in the object communication mechanism
};

R__EXTERN char *gTQSlotParams; // used to pass string parameters

#ifndef ROOT_TQObjectEmitVA
#include "TQObjectEmitVA.h"
#endif

#endif
 TQConnection.h:1
 TQConnection.h:2
 TQConnection.h:3
 TQConnection.h:4
 TQConnection.h:5
 TQConnection.h:6
 TQConnection.h:7
 TQConnection.h:8
 TQConnection.h:9
 TQConnection.h:10
 TQConnection.h:11
 TQConnection.h:12
 TQConnection.h:13
 TQConnection.h:14
 TQConnection.h:15
 TQConnection.h:16
 TQConnection.h:17
 TQConnection.h:18
 TQConnection.h:19
 TQConnection.h:20
 TQConnection.h:21
 TQConnection.h:22
 TQConnection.h:23
 TQConnection.h:24
 TQConnection.h:25
 TQConnection.h:26
 TQConnection.h:27
 TQConnection.h:28
 TQConnection.h:29
 TQConnection.h:30
 TQConnection.h:31
 TQConnection.h:32
 TQConnection.h:33
 TQConnection.h:34
 TQConnection.h:35
 TQConnection.h:36
 TQConnection.h:37
 TQConnection.h:38
 TQConnection.h:39
 TQConnection.h:40
 TQConnection.h:41
 TQConnection.h:42
 TQConnection.h:43
 TQConnection.h:44
 TQConnection.h:45
 TQConnection.h:46
 TQConnection.h:47
 TQConnection.h:48
 TQConnection.h:49
 TQConnection.h:50
 TQConnection.h:51
 TQConnection.h:52
 TQConnection.h:53
 TQConnection.h:54
 TQConnection.h:55
 TQConnection.h:56
 TQConnection.h:57
 TQConnection.h:58
 TQConnection.h:59
 TQConnection.h:60
 TQConnection.h:61
 TQConnection.h:62
 TQConnection.h:63
 TQConnection.h:64
 TQConnection.h:65
 TQConnection.h:66
 TQConnection.h:67
 TQConnection.h:68
 TQConnection.h:69
 TQConnection.h:70
 TQConnection.h:71
 TQConnection.h:72
 TQConnection.h:73
 TQConnection.h:74
 TQConnection.h:75
 TQConnection.h:76
 TQConnection.h:77
 TQConnection.h:78
 TQConnection.h:79
 TQConnection.h:80
 TQConnection.h:81
 TQConnection.h:82
 TQConnection.h:83
 TQConnection.h:84
 TQConnection.h:85
 TQConnection.h:86
 TQConnection.h:87
 TQConnection.h:88
 TQConnection.h:89
 TQConnection.h:90
 TQConnection.h:91
 TQConnection.h:92
 TQConnection.h:93
 TQConnection.h:94
 TQConnection.h:95
 TQConnection.h:96
 TQConnection.h:97
 TQConnection.h:98
 TQConnection.h:99
 TQConnection.h:100
 TQConnection.h:101
 TQConnection.h:102
 TQConnection.h:103
 TQConnection.h:104
 TQConnection.h:105
 TQConnection.h:106
 TQConnection.h:107
 TQConnection.h:108
 TQConnection.h:109
 TQConnection.h:110
 TQConnection.h:111
 TQConnection.h:112
 TQConnection.h:113
 TQConnection.h:114
 TQConnection.h:115