Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

SUEFdHandler Class Reference

File descriptor handler for SUEEventSelector. More...

#include <sue_sel.hpp>

Inheritance diagram for SUEFdHandler:

Inheritance graph
[legend]
List of all members.

Public Methods

 SUEFdHandler (int a_fd=-1)
 Constructor.

virtual ~SUEFdHandler ()
 Destructor.

virtual void FdHandle (bool a_r, bool a_w, bool a_ex)=0
 Callback function for notification.

void SetFd (int a_fd)
 Set/change the file descriptor value.

virtual bool WantRead () const
 Do we want to read?

virtual bool WantWrite () const
 Do we want to write?

virtual bool WantExcept () const
 Do we want exceptions?


Protected Attributes

int fd
 File descriptor to handle.


Friends

class SUEEventSelector

Detailed Description

File descriptor handler for SUEEventSelector.

When we've got a file descriptor to be handled with select() call (that is, with SUEEventSelector class), we need to create a subclass of SUEFdHandler overriding void FdHandle(bool, bool, bool) virtual method. Then, create an object of that class and register it with the SUEEventSelector object.

Warning:
It is assumed that the descriptor doesn't change after the object is registered. If you need to change it, then unregister the object, change the descriptor and then register the object again.
Examples:

sitter.cpp.


Constructor & Destructor Documentation

SUEFdHandler::SUEFdHandler int    a_fd = -1
 

Constructor.

Constructor of the class.

Parameters:
a_fd  is the file descriptor
Note:
File descriptor should not be changed when the handler is installed.

virtual SUEFdHandler::~SUEFdHandler   [virtual]
 

Destructor.

Destructor of the class

Warning:
It is the user's duty to make sure the object is NO LONGER REGISTERED with the selector before destroying the object


Member Function Documentation

virtual void SUEFdHandler::FdHandle bool    a_r,
bool    a_w,
bool    a_ex
[pure virtual]
 

Callback function for notification.

The SUEEventSelector calls this method when the file descriptor changes it's status to notify us about it.

Note:
This method MUST be overriden in a subclass in order to provide the appropriate functionality.

Implemented in SUEGenericDuplexSession.

Examples:
sitter.cpp.

void SUEFdHandler::SetFd int    a_fd [inline]
 

Set/change the file descriptor value.

This method is intended to be used in case we don't know the actual descriptor's value at the moment of creation of the object so that we can't pass it to the constructor.

Note:
This must be done BEFORE we register the object with the UPEventSelector object.
Warning:
Calling this method after the handler is registered with the selector will lead to unpredictable effects.
Examples:
sitter.cpp.

virtual bool SUEFdHandler::WantExcept   const [inline, virtual]
 

Do we want exceptions?

Should the selector call this object's handler when an exception happens to the descriptor?

Reimplemented in SUEGenericDuplexSession.

virtual bool SUEFdHandler::WantRead   const [inline, virtual]
 

Do we want to read?

Should the selector call this object's handler when new data is available for reading?

Reimplemented in SUEGenericDuplexSession.

Examples:
sitter.cpp.

virtual bool SUEFdHandler::WantWrite   const [inline, virtual]
 

Do we want to write?

Should the selector call this object's handler when it is safe to write (that is, write(2) will not block)?

Reimplemented in SUEGenericDuplexSession.

Examples:
sitter.cpp.


Friends And Related Function Documentation

friend class SUEEventSelector [friend]
 


Member Data Documentation

int SUEFdHandler::fd [protected]
 

File descriptor to handle.


The documentation for this class was generated from the following file:
Generated on Fri Feb 27 13:17:26 2004 for SUE Library by doxygen1.2.18