Logo ROOT  
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; }
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
m
auto * m
Definition: textangle.C:8
TXSocket
Definition: TXSocket.h:59
TMonitor::ResetInterrupt
void ResetInterrupt()
Definition: TMonitor.h:72
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TMonitor::EInterest
EInterest
Definition: TMonitor.h:54
TMonitor::TTimeOutTimer
friend class TTimeOutTimer
Definition: TMonitor.h:39
TMonitor::GetListOfDeActives
TList * GetListOfDeActives() const
Returns a list with all de-active sockets.
Definition: TMonitor.cxx:515
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
Int_t
int Int_t
Definition: RtypesCore.h:45
TMonitor::Add
virtual void Add(TSocket *sock, Int_t interest=kRead)
Add socket to the monitor's active list.
Definition: TMonitor.cxx:168
TMonitor
Definition: TMonitor.h:36
TMonitor::RemoveAll
virtual void RemoveAll()
Remove all sockets from the monitor.
Definition: TMonitor.cxx:241
TMonitor::~TMonitor
virtual ~TMonitor()
Cleanup the monitor object. Does not delete sockets being monitored.
Definition: TMonitor.cxx:153
TMonitor::DeActivateAll
virtual void DeActivateAll()
De-activate all activated sockets.
Definition: TMonitor.cxx:302
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
bool
TXSlave
Definition: TXSlave.h:32
TMonitor::DeActivate
virtual void DeActivate(TSocket *sock)
De-activate a socket.
Definition: TMonitor.cxx:284
TQObject.h
TSocket
Definition: TSocket.h:41
TQObject
Definition: TQObject.h:48
TMonitor::fReady
TSocket * fReady
Definition: TMonitor.h:46
TMonitor::GetDeActive
Int_t GetDeActive() const
Return number of sockets in the de-active list.
Definition: TMonitor.cxx:473
TMonitor::TMonitor
TMonitor(Bool_t mainloop=kTRUE)
Create a monitor object.
Definition: TMonitor.cxx:109
TMonitor::Select
TSocket * Select()
Return pointer to socket for which an event is waiting.
Definition: TMonitor.cxx:322
TMonitor::GetListOfActives
TList * GetListOfActives() const
Returns a list with all active sockets.
Definition: TMonitor.cxx:498
TMonitor::fDeActive
TList * fDeActive
Definition: TMonitor.h:45
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TMonitor::fActive
TList * fActive
Definition: TMonitor.h:44
Long_t
long Long_t
Definition: RtypesCore.h:54
TMonitor::fMainLoop
Bool_t fMainLoop
Definition: TMonitor.h:47
TMonitor::SetInterest
virtual void SetInterest(TSocket *sock, Int_t interest=kRead)
Set interest mask for socket sock to interest.
Definition: TMonitor.cxx:180
TMonitor::Activate
virtual void Activate(TSocket *sock)
Activate a de-activated socket.
Definition: TMonitor.cxx:250
TMonitor::fInterrupt
Bool_t fInterrupt
Definition: TMonitor.h:48
TMonitor::kRead
@ kRead
Definition: TMonitor.h:54
TObject.h
TObject
Definition: TObject.h:37
TMonitor::Ready
virtual void Ready(TSocket *sock)
Emit signal when some socket is ready.
Definition: TMonitor.cxx:530
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TMonitor::Interrupt
void Interrupt()
Definition: TMonitor.h:71
TMonitor::GetActive
Int_t GetActive(Long_t timeout=-1) const
Return number of sockets in the active list.
Definition: TMonitor.cxx:438
TMonitor::IsActive
Bool_t IsActive(TSocket *s) const
Check if socket 's' is in the active list.
Definition: TMonitor.cxx:482
TMonitor::GetSender
void * GetSender()
Definition: TMonitor.h:51
TMonitor::ActivateAll
virtual void ActivateAll()
Activate all de-activated sockets.
Definition: TMonitor.cxx:268
TMonitor::Remove
virtual void Remove(TSocket *sock)
Remove a socket from the monitor.
Definition: TMonitor.cxx:214
TMonitor::kWrite
@ kWrite
Definition: TMonitor.h:54
TMonitor::TSocketHandler
friend class TSocketHandler
Definition: TMonitor.h:38
TMonitor::SetReady
void SetReady(TSocket *sock)
Called by TSocketHandler::Notify() to signal which socket is ready to be read or written.
Definition: TMonitor.cxx:423
TList
Definition: TList.h:44