ROOT logo
// @(#)root/net:$Id$
// Author: Fons Rademakers   09/01/97

/*************************************************************************
 * 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_TMonitor
#define ROOT_TMonitor


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TMonitor                                                             //
//                                                                      //
// This class monitors activity on a number of network sockets.         //
// The actual monitoring is done by TSystem::DispatchOneEvent().        //
// Typical usage: create a TMonitor object. Register a number of        //
// TSocket objects and call TMonitor::Select(). Select() returns the    //
// socket object which has data waiting. TSocket objects can be added,  //
// removed, (temporary) enabled or disabled.                            //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TQObject
#include "TQObject.h"
#endif

class TList;
class TSocket;


class TMonitor : public TObject, public TQObject {

friend class TSocketHandler;
friend class TTimeOutTimer;
friend class TXSlave;
friend class TXSocket;

private:
   TList    *fActive;     //list of sockets to monitor
   TList    *fDeActive;   //list of (temporary) disabled sockets
   TSocket  *fReady;      //socket which is ready to be read or written
   Bool_t    fMainLoop;   //true if monitoring sockets within the main event loop
   Bool_t    fInterrupt;  //flags an interrupt to Select

   void  SetReady(TSocket *sock);
   void *GetSender() { return this; }  // used to get gTQSender

public:
   enum EInterest { kRead = 1, kWrite = 2 };

   TMonitor(Bool_t mainloop = kTRUE);
   TMonitor(const TMonitor &m);
   virtual ~TMonitor();

   virtual void Add(TSocket *sock, Int_t interest = kRead);
   virtual void SetInterest(TSocket *sock, Int_t interest = kRead);
   virtual void Remove(TSocket *sock);
   virtual void RemoveAll();

   virtual void Activate(TSocket *sock);
   virtual void ActivateAll();
   virtual void DeActivate(TSocket *sock);
   virtual void DeActivateAll();
   virtual void Ready(TSocket *sock); // *SIGNAL*

   void     Interrupt() { fInterrupt = kTRUE; }
   void     ResetInterrupt() { fInterrupt = kFALSE; }

   TSocket *Select();
   TSocket *Select(Long_t timeout);
   Int_t    Select(TList *rdready, TList *wrready, Long_t timeout);

   Int_t  GetActive(Long_t timeout = -1) const;
   Int_t  GetDeActive() const;
   TList *GetListOfActives() const;
   TList *GetListOfDeActives() const;

   Bool_t IsActive(TSocket *s) const;

   ClassDef(TMonitor,0)  //Monitor activity on a set of TSocket objects
};

#endif
 TMonitor.h:1
 TMonitor.h:2
 TMonitor.h:3
 TMonitor.h:4
 TMonitor.h:5
 TMonitor.h:6
 TMonitor.h:7
 TMonitor.h:8
 TMonitor.h:9
 TMonitor.h:10
 TMonitor.h:11
 TMonitor.h:12
 TMonitor.h:13
 TMonitor.h:14
 TMonitor.h:15
 TMonitor.h:16
 TMonitor.h:17
 TMonitor.h:18
 TMonitor.h:19
 TMonitor.h:20
 TMonitor.h:21
 TMonitor.h:22
 TMonitor.h:23
 TMonitor.h:24
 TMonitor.h:25
 TMonitor.h:26
 TMonitor.h:27
 TMonitor.h:28
 TMonitor.h:29
 TMonitor.h:30
 TMonitor.h:31
 TMonitor.h:32
 TMonitor.h:33
 TMonitor.h:34
 TMonitor.h:35
 TMonitor.h:36
 TMonitor.h:37
 TMonitor.h:38
 TMonitor.h:39
 TMonitor.h:40
 TMonitor.h:41
 TMonitor.h:42
 TMonitor.h:43
 TMonitor.h:44
 TMonitor.h:45
 TMonitor.h:46
 TMonitor.h:47
 TMonitor.h:48
 TMonitor.h:49
 TMonitor.h:50
 TMonitor.h:51
 TMonitor.h:52
 TMonitor.h:53
 TMonitor.h:54
 TMonitor.h:55
 TMonitor.h:56
 TMonitor.h:57
 TMonitor.h:58
 TMonitor.h:59
 TMonitor.h:60
 TMonitor.h:61
 TMonitor.h:62
 TMonitor.h:63
 TMonitor.h:64
 TMonitor.h:65
 TMonitor.h:66
 TMonitor.h:67
 TMonitor.h:68
 TMonitor.h:69
 TMonitor.h:70
 TMonitor.h:71
 TMonitor.h:72
 TMonitor.h:73
 TMonitor.h:74
 TMonitor.h:75
 TMonitor.h:76
 TMonitor.h:77
 TMonitor.h:78
 TMonitor.h:79
 TMonitor.h:80
 TMonitor.h:81
 TMonitor.h:82
 TMonitor.h:83
 TMonitor.h:84
 TMonitor.h:85
 TMonitor.h:86
 TMonitor.h:87
 TMonitor.h:88
 TMonitor.h:89
 TMonitor.h:90
 TMonitor.h:91
 TMonitor.h:92