library: libCore #include "TMonitor.h"

# TMonitor

class description - source file - inheritance tree (.pdf)

## class TMonitor : public TObject, public TQObject

| Inheritance Chart:
`TObject`
`TQObject`
| <- | `TMonitor` |

        private:

          virtual void* GetSender()
                   void SetReady(TSocket* sock)

        public:

                          TMonitor(Bool_t mainloop = kTRUE)
                          TMonitor(const TMonitor&)
                  virtual ~TMonitor()
             virtual void Activate(TSocket* sock)
             virtual void ActivateAll()
             virtual void Add(TSocket* sock, Int_t interest = kRead)
           static TClass* Class()
             virtual void DeActivate(TSocket* sock)
             virtual void DeActivateAll()
                    Int_t GetActive() const
                    Int_t GetDeActive() const
                   TList* GetListOfActives() const
                   TList* GetListOfDeActives() const
          virtual TClass* IsA() const
                TMonitor& operator=(const TMonitor&)
             virtual void Ready(TSocket* sock)
             virtual void Remove(TSocket* sock)
             virtual void RemoveAll()
                 TSocket* Select()
                 TSocket* Select(Long_t timeout)
                    Int_t Select(TList* rdready, TList* wrready, Long_t timeout)
             virtual void SetInterest(TSocket* sock, Int_t interest = kRead)
             virtual void ShowMembers(TMemberInspector& insp, char* parent)
             virtual void Streamer(TBuffer& b)
                     void StreamerNVirtual(TBuffer& b)

### Data Members

        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

        public:

          static const TMonitor::EInterest kRead
          static const TMonitor::EInterest kWrite

## Class Description

     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.

TMonitor(Bool_t mainloop)

     Create a monitor object. If mainloop is true the monitoring will be
     done in the main event loop.

~TMonitor()

     Cleanup the monitor object. Does not delete socket being monitored.

void Add(TSocket *sock, Int_t interest)

     Add socket to the monitor's active list. If interest=kRead then we
     want to monitor the socket for read readiness, if interest=kWrite
     then we monitor the socket for write readiness, if interest=kRead|kWrite
     then we monitor both read and write readiness.

void SetInterest(TSocket *sock, Int_t interest)

     Set interest mask for socket sock to interest. If the socket is not
     in the active list move it or add it there.
     If interest=kRead then we want to monitor the socket for read readiness,
     if interest=kWrite then we monitor the socket for write readiness,
     if interest=kRead|kWrite then we monitor both read and write readiness.

void Remove(TSocket *sock)

     Remove a socket from the monitor.

void RemoveAll()

     Remove all sockets from the monitor.

void Activate(TSocket *sock)

     Activate a de-activated socket.

void ActivateAll()

     Activate all de-activated sockets.

void DeActivate(TSocket *sock)

     De-activate a socket.

void DeActivateAll()

     De-activate all activated sockets.

TSocket* Select()

     Return pointer to socket for which an event is waiting.
     Return 0 in case of error.

TSocket* Select(Long_t timeout)

     Return pointer to socket for which an event is waiting.
     Wait a maximum of timeout milliseconds.
     If return is due to timeout it returns (TSocket *)-1.
     Return 0 in case of any other error situation.

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

     Return numbers of sockets that are ready for reading or writing.
     Wait a maximum of timeout milliseconds.
     Return 0 if timed-out. Return < 0 in case of error.
     If rdready and/or wrready are not 0, the lists of sockets with
     something to read and/or write are also returned.

void SetReady(TSocket *sock)

     Called by TSocketHandler::Notify() to signal which socket is ready
     to be read or written. User should not call this routine. The ready
     socket will be returned via the Select() user function.
     Ready(TSocket *sock) signal is emitted.

Int_t GetActive() const

     Return number of sockets in the active list.

Int_t GetDeActive() const

     Return number of sockets in the de-active list.

TList* GetListOfActives() const

     Returns a list with all active sockets. This list must be deleted
     by the user. DO NOT call Delete() on this list as it will delete
     the sockets that are still being used by the monitor.

TList* GetListOfDeActives() const

     Returns a list with all de-active sockets. This list must be deleted
     by the user. DO NOT call Delete() on this list as it will delete
     the sockets that are still being used by the monitor.

void Ready(TSocket *sock)

     Emit signal when some socket is ready

### Inline Functions

                  void* GetSender()
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)
               TMonitor TMonitor(const TMonitor&)
              TMonitor& operator=(const TMonitor&)

Author: Fons Rademakers 09/01/97
Last update: root/net:$Name: $:$Id: TMonitor.cxx,v 1.7 2004/12/15 17:48:03 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *