Logo ROOT   6.08/07
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 #ifndef ROOT_TObject
30 #include "TObject.h"
31 #endif
32 #ifndef ROOT_TQObject
33 #include "TQObject.h"
34 #endif
35 
36 class TList;
37 class TSocket;
38 
39 
40 class TMonitor : public TObject, public TQObject {
41 
42 friend class TSocketHandler;
43 friend class TTimeOutTimer;
44 friend class TXSlave;
45 friend class TXSocket;
46 
47 private:
48  TList *fActive; //list of sockets to monitor
49  TList *fDeActive; //list of (temporary) disabled sockets
50  TSocket *fReady; //socket which is ready to be read or written
51  Bool_t fMainLoop; //true if monitoring sockets within the main event loop
52  Bool_t fInterrupt; //flags an interrupt to Select
53 
54  void SetReady(TSocket *sock);
55  void *GetSender() { return this; } // used to get gTQSender
56 
57 public:
58  enum EInterest { kRead = 1, kWrite = 2 };
59 
60  TMonitor(Bool_t mainloop = kTRUE);
61  TMonitor(const TMonitor &m);
62  virtual ~TMonitor();
63 
64  virtual void Add(TSocket *sock, Int_t interest = kRead);
65  virtual void SetInterest(TSocket *sock, Int_t interest = kRead);
66  virtual void Remove(TSocket *sock);
67  virtual void RemoveAll();
68 
69  virtual void Activate(TSocket *sock);
70  virtual void ActivateAll();
71  virtual void DeActivate(TSocket *sock);
72  virtual void DeActivateAll();
73  virtual void Ready(TSocket *sock); // *SIGNAL*
74 
75  void Interrupt() { fInterrupt = kTRUE; }
76  void ResetInterrupt() { fInterrupt = kFALSE; }
77 
78  TSocket *Select();
79  TSocket *Select(Long_t timeout);
80  Int_t Select(TList *rdready, TList *wrready, Long_t timeout);
81 
82  Int_t GetActive(Long_t timeout = -1) const;
83  Int_t GetDeActive() const;
84  TList *GetListOfActives() const;
85  TList *GetListOfDeActives() const;
86 
87  Bool_t IsActive(TSocket *s) const;
88 
89  ClassDef(TMonitor,0) //Monitor activity on a set of TSocket objects
90 };
91 
92 #endif
Bool_t fMainLoop
Definition: TMonitor.h:51
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:50
Int_t GetDeActive() const
Return number of sockets in the de-active list.
Definition: TMonitor.cxx:473
void Interrupt()
Definition: TMonitor.h:75
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:53
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
const Bool_t kFALSE
Definition: Rtypes.h:92
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:36
virtual void DeActivateAll()
De-activate all activated sockets.
Definition: TMonitor.cxx:302
Bool_t fInterrupt
Definition: TMonitor.h:52
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void DeActivate(TSocket *sock)
De-activate a socket.
Definition: TMonitor.cxx:284
friend class TTimeOutTimer
Definition: TMonitor.h:43
TSocket * Select()
Return pointer to socket for which an event is waiting.
Definition: TMonitor.cxx:322
A doubly linked list.
Definition: TList.h:47
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:73
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
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:49
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:55
friend class TSocketHandler
Definition: TMonitor.h:42
TMonitor(Bool_t mainloop=kTRUE)
Create a monitor object.
Definition: TMonitor.cxx:109
TList * fActive
Definition: TMonitor.h:48
virtual void ActivateAll()
Activate all de-activated sockets.
Definition: TMonitor.cxx:268
const Bool_t kTRUE
Definition: Rtypes.h:91
void ResetInterrupt()
Definition: TMonitor.h:76