TMonitor.h

Go to the documentation of this file.
00001 // @(#)root/net:$Id: TMonitor.h 31598 2009-12-07 15:21:47Z rdm $
00002 // Author: Fons Rademakers   09/01/97
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TMonitor
00013 #define ROOT_TMonitor
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TMonitor                                                             //
00019 //                                                                      //
00020 // This class monitors activity on a number of network sockets.         //
00021 // The actual monitoring is done by TSystem::DispatchOneEvent().        //
00022 // Typical usage: create a TMonitor object. Register a number of        //
00023 // TSocket objects and call TMonitor::Select(). Select() returns the    //
00024 // socket object which has data waiting. TSocket objects can be added,  //
00025 // removed, (temporary) enabled or disabled.                            //
00026 //                                                                      //
00027 //////////////////////////////////////////////////////////////////////////
00028 
00029 #ifndef ROOT_TObject
00030 #include "TObject.h"
00031 #endif
00032 #ifndef ROOT_TQObject
00033 #include "TQObject.h"
00034 #endif
00035 
00036 class TList;
00037 class TSocket;
00038 
00039 
00040 class TMonitor : public TObject, public TQObject {
00041 
00042 friend class TSocketHandler;
00043 friend class TTimeOutTimer;
00044 friend class TXSlave;
00045 friend class TXSocket;
00046 
00047 private:
00048    TList    *fActive;     //list of sockets to monitor
00049    TList    *fDeActive;   //list of (temporary) disabled sockets
00050    TSocket  *fReady;      //socket which is ready to be read or written
00051    Bool_t    fMainLoop;   //true if monitoring sockets within the main event loop
00052    Bool_t    fInterrupt;  //flags an interrupt to Select
00053 
00054    void  SetReady(TSocket *sock);
00055    void *GetSender() { return this; }  // used to get gTQSender
00056 
00057 public:
00058    enum EInterest { kRead = 1, kWrite = 2 };
00059 
00060    TMonitor(Bool_t mainloop = kTRUE);
00061    TMonitor(const TMonitor &m);
00062    virtual ~TMonitor();
00063 
00064    virtual void Add(TSocket *sock, Int_t interest = kRead);
00065    virtual void SetInterest(TSocket *sock, Int_t interest = kRead);
00066    virtual void Remove(TSocket *sock);
00067    virtual void RemoveAll();
00068 
00069    virtual void Activate(TSocket *sock);
00070    virtual void ActivateAll();
00071    virtual void DeActivate(TSocket *sock);
00072    virtual void DeActivateAll();
00073    virtual void Ready(TSocket *sock); // *SIGNAL*
00074 
00075    void     Interrupt() { fInterrupt = kTRUE; }
00076    void     ResetInterrupt() { fInterrupt = kFALSE; }
00077 
00078    TSocket *Select();
00079    TSocket *Select(Long_t timeout);
00080    Int_t    Select(TList *rdready, TList *wrready, Long_t timeout);
00081 
00082    Int_t  GetActive(Long_t timeout = -1) const;
00083    Int_t  GetDeActive() const;
00084    TList *GetListOfActives() const;
00085    TList *GetListOfDeActives() const;
00086 
00087    Bool_t IsActive(TSocket *s) const;
00088 
00089    ClassDef(TMonitor,0)  //Monitor activity on a set of TSocket objects
00090 };
00091 
00092 #endif

Generated on Tue Jul 5 14:27:18 2011 for ROOT_528-00b_version by  doxygen 1.5.1