sockets::Monitor Class Reference

Base class for monitors. More...

#include <monitor.h>

List of all members.

Public Types

enum  { evRead = 0x0001, evWrite = 0x0002 }

Public Member Functions

 Monitor (std::string const &name, size_t hint)
 Constructor.
virtual ~Monitor ()
 Destructor.
virtual void do_events (time_t wait)
 Do events.
virtual bool add (Socket *socket, int fd, unsigned int events)
 Monitors a socket.
virtual bool update (Socket *socket, int fd, unsigned int events)
 Updates events monitored for a socket.
virtual void remove (Socket *socket, int fd)
 Unmonitors a socket.
std::string const & name () const
 Returns the name of the monitor.

Protected Types

typedef
containers::VectorSP
< Socket *, size_t > 
sockets_list
 Type of the list of sockets.

Protected Member Functions

Socketget_socket (int fd) const
 Gets a socket for a given fd.
void set_socket (int fd, Socket *s)
 Sets a socket for a given fd.
size_t hint () const
 Returns the hint.

Protected Attributes

sockets_list m_sockets
 The sockets list.


Detailed Description

Base class for monitors. A monitor is used to watch requested events on sockets registered with it.

The do_events(), add(), update() and remove() function must be overriden in derived classes.


Member Enumeration Documentation

anonymous enum

Enumerator:
evRead  Read event.
evWrite  Write event.


Constructor & Destructor Documentation

sockets::Monitor::Monitor ( std::string const &  name,
size_t  hint 
)

Constructor.

Parameters:
[in] name The name of the monitor.
[in] hint An estimate of the number of maximum sockets that will be in use at a given time. This is NOT an actual maximum value.


Member Function Documentation

virtual void sockets::Monitor::do_events ( time_t  wait  )  [inline, virtual]

This function checks for new events on the monitored sockets.

The default implementation does nothing.

Parameters:
[in] wait The number of milliseconds to wait for events on sockets, or 0 if no waiting must be done.

virtual bool sockets::Monitor::add ( Socket socket,
int  fd,
unsigned int  events 
) [virtual]

Adds a socket to the monitor. This socket will be watched for the given events and receive notifications when they happen.

The default implementation calls set_socket() for the given socket/fd pair.

Parameters:
[in] socket The socket to add.
[in] fd The socket file descriptor.
[in] events The events to watch for initially.
Returns:
true if successful, false otherwise.

virtual bool sockets::Monitor::update ( Socket socket,
int  fd,
unsigned int  events 
) [virtual]

Updates events monitored for a socket. The socket must have been added previously through the add() function.

The default implementation does nothing.

Parameters:
[in] socket The socket to update.
[in] fd The socket file descriptor.
[in] events The events to watch for.
Returns:
true if successful, false otherwise.

virtual void sockets::Monitor::remove ( Socket socket,
int  fd 
) [virtual]

Unmonitors a socket. The socket must have been added previously through the add() function.

The default implementation removes the socket from the internal socket list.

Parameters:
[in] socket The socket to remove.
[in] fd The socket file descriptor.


The documentation for this class was generated from the following file:
Generated on Fri Apr 18 22:03:29 2008 for Epona API by  doxygen 1.5.3