Logo ROOT   6.10/09
Reference Guide
TMonitor.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Fons Rademakers 09/01/97
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_TMonitor
13 #define ROOT_TMonitor
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TMonitor //
19 // //
20 // This class monitors activity on a number of network sockets. //
21 // The actual monitoring is done by TSystem::DispatchOneEvent(). //
22 // Typical usage: create a TMonitor object. Register a number of //
23 // TSocket objects and call TMonitor::Select(). Select() returns the //
24 // socket object which has data waiting. TSocket objects can be added, //
25 // removed, (temporary) enabled or disabled. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 #include "TObject.h"
30 #include "TQObject.h"
31 
32 class TList;
33 class TSocket;
34 
35 
36 class TMonitor : public TObject, public TQObject {
37 
38 friend class TSocketHandler;
39 friend class TTimeOutTimer;
40 friend class TXSlave;
41 friend class TXSocket;
42 
43 private:
44  TList *fActive; //list of sockets to monitor
45  TList *fDeActive; //list of (temporary) disabled sockets
46  TSocket *fReady; //socket which is ready to be read or written
47  Bool_t fMainLoop; //true if monitoring sockets within the main event loop
48  Bool_t fInterrupt; //flags an interrupt to Select
49 
50  void SetReady(TSocket *sock);
51  void *GetSender() { return this; } // used to get gTQSender
52 
53 public:
54  enum EInterest { kRead = 1, kWrite = 2 };
55 
56  TMonitor(Bool_t mainloop = kTRUE);
57  TMonitor(const TMonitor &m);
58  virtual ~TMonitor();
59 
60  virtual void Add(TSocket *sock, Int_t interest = kRead);
61  virtual void SetInterest(TSocket *sock, Int_t interest = kRead);
62  virtual void Remove(TSocket *sock);
63  virtual void RemoveAll();
64 
65  virtual void Activate(TSocket *sock);
66  virtual void ActivateAll();
67  virtual void DeActivate(TSocket *sock);
68  virtual void DeActivateAll();
69  virtual void Ready(TSocket *sock); // *SIGNAL*
70 
71  void Interrupt() { fInterrupt = kTRUE; }
72  void ResetInterrupt() { fInterrupt = kFALSE; }
73 
74  TSocket *Select();
75  TSocket *Select(Long_t timeout);
76  Int_t Select(TList *rdready, TList *wrready, Long_t timeout);
77 
78  Int_t GetActive(Long_t timeout = -1) const;
79  Int_t GetDeActive() const;
80  TList *GetListOfActives() const;
81  TList *GetListOfDeActives() const;
82 
83  Bool_t IsActive(TSocket *s) const;
84 
85  ClassDef(TMonitor,0) //Monitor activity on a set of TSocket objects
86 };
87 
88 #endif
Bool_t fMainLoop
Definition: TMonitor.h:47
virtual void Remove(TSocket *sock)
Remove a socket from the monitor.
Definition: TMonitor.cxx:214
Int_t GetActive(Long_t timeout=-1) const
Return number of sockets in the active list.
Definition: TMonitor.cxx:438
TSocket * fReady
Definition: TMonitor.h:46
Int_t GetDeActive() const
Return number of sockets in the de-active list.
Definition: TMonitor.cxx:473
void Interrupt()
Definition: TMonitor.h:71
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:49
virtual void Add(TSocket *sock, Int_t interest=kRead)
Add socket to the monitor's active list.
Definition: TMonitor.cxx:168
Bool_t IsActive(TSocket *s) const
Check if socket 's' is in the active list.
Definition: TMonitor.cxx:482
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void RemoveAll()
Remove all sockets from the monitor.
Definition: TMonitor.cxx:241
virtual ~TMonitor()
Cleanup the monitor object. Does not delete sockets being monitored.
Definition: TMonitor.cxx:153
This is the version of TSlave for workers servers based on XProofD.
Definition: TXSlave.h:32
virtual void DeActivateAll()
De-activate all activated sockets.
Definition: TMonitor.cxx:302
Bool_t fInterrupt
Definition: TMonitor.h:48
#define ClassDef(name, id)
Definition: Rtypes.h:297
virtual void DeActivate(TSocket *sock)
De-activate a socket.
Definition: TMonitor.cxx:284
friend class TTimeOutTimer
Definition: TMonitor.h:39
TSocket * Select()
Return pointer to socket for which an event is waiting.
Definition: TMonitor.cxx:322
A doubly linked list.
Definition: TList.h:43
virtual void SetInterest(TSocket *sock, Int_t interest=kRead)
Set interest mask for socket sock to interest.
Definition: TMonitor.cxx:180
High level handler of connections to XProofD.
Definition: TXSocket.h:59
void SetReady(TSocket *sock)
Called by TSocketHandler::Notify() to signal which socket is ready to be read or written.
Definition: TMonitor.cxx:423
TList * GetListOfActives() const
Returns a list with all active sockets.
Definition: TMonitor.cxx:498
TMarker * m
Definition: textangle.C:8
virtual void Activate(TSocket *sock)
Activate a de-activated socket.
Definition: TMonitor.cxx:250
const Bool_t kFALSE
Definition: RtypesCore.h:92
long Long_t
Definition: RtypesCore.h:50
TList * GetListOfDeActives() const
Returns a list with all de-active sockets.
Definition: TMonitor.cxx:515
TList * fDeActive
Definition: TMonitor.h:45
virtual void Ready(TSocket *sock)
Emit signal when some socket is ready.
Definition: TMonitor.cxx:530
Mother of all ROOT objects.
Definition: TObject.h:37
void * GetSender()
Definition: TMonitor.h:51
friend class TSocketHandler
Definition: TMonitor.h:38
TMonitor(Bool_t mainloop=kTRUE)
Create a monitor object.
Definition: TMonitor.cxx:109
TList * fActive
Definition: TMonitor.h:44
virtual void ActivateAll()
Activate all de-activated sockets.
Definition: TMonitor.cxx:268
const Bool_t kTRUE
Definition: RtypesCore.h:91
void ResetInterrupt()
Definition: TMonitor.h:72