GNet::EventHandler Class Reference

A base class for classes that handle asynchronous socket events. More...

#include <geventhandler.h>

Inheritance diagram for GNet::EventHandler:

GNet::Server GNet::ServerPeer GNet::SimpleClient Main::Run GNet::MultiServerImp GNet::BufferedServerPeer GNet::HeapClient GNet::ResolverImp GPop::ServerPeer GSmtp::AdminServerPeer GSmtp::ServerPeer GNet::Client GSmtp::Client GSmtp::RequestClient GSmtp::SpamClient

List of all members.

Public Member Functions

virtual ~EventHandler ()
 Destructor.
virtual void readEvent ()
 Called for a read event.
virtual void writeEvent ()
 Called for a write event.
virtual void exceptionEvent ()
 Called for an exception event.
virtual void onException (std::exception &)=0
 Called when an exception is thrown out of readEvent(), writeEvent() or exceptionEvent().


Detailed Description

A base class for classes that handle asynchronous socket events.

An event handler object has its virtual methods called when an event is detected on the associated file descriptor.

If an event handler throws an exception which is caught by the event loop then the event loop calls the handler's onException() method.

A file descriptors and associated event handlers are typically kept in a EventHandlerList container within the EventLoop singleton.

Definition at line 54 of file geventhandler.h.


Constructor & Destructor Documentation

GNet::EventHandler::~EventHandler (  )  [virtual]

Destructor.

Definition at line 31 of file geventhandler.cpp.


Member Function Documentation

void GNet::EventHandler::readEvent (  )  [virtual]

Called for a read event.

Overridable. The default implementation does nothing.

Reimplemented in GNet::Server, GNet::ServerPeer, and GNet::SimpleClient.

Definition at line 35 of file geventhandler.cpp.

References G_DEBUG.

void GNet::EventHandler::writeEvent (  )  [virtual]

Called for a write event.

Overrideable. The default implementation does nothing.

Reimplemented in GNet::Server, GNet::ServerPeer, and GNet::SimpleClient.

Definition at line 40 of file geventhandler.cpp.

References G_DEBUG.

void GNet::EventHandler::exceptionEvent (  )  [virtual]

Called for an exception event.

Overridable. The default implementation throws an exception resulting in a call to onException().

Definition at line 45 of file geventhandler.cpp.

virtual void GNet::EventHandler::onException ( std::exception &   )  [pure virtual]

Called when an exception is thrown out of readEvent(), writeEvent() or exceptionEvent().

The implementation may just do a "throw" to throw the current exception out of the event loop, or a "delete this" for objects that manage themselves on the heap.

EventHandler objects or timer objects that are sub-objects of other EventHandler objects will normally have their implementation of onException() or onTimerException() delgate to the outer object's onException().

Implemented in GNet::HeapClient, GNet::ResolverImp, GNet::Server, GNet::ServerPeer, and Main::Run.

Referenced by GNet::ResolverImp::onException(), GNet::Timer< T >::onTimeoutException(), and GNet::FdSet::raiseEvent().


The documentation for this class was generated from the following files:

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5