- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
GNet::EventHandler Class Referenceabstract

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

`#include <geventhandler.h>`

Inheritance diagram for GNet::EventHandler:

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

## 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::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 onTimeoutException() delgate to the outer object's onException().

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

Referenced by GNet::FdSet::raiseEvent().

void GNet::EventHandler::readEvent | ( |  | ) |
| virtual

Called for a read event.

Overridable. The default implementation does nothing.

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

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::ServerPeer, GNet::SimpleClient, and GNet::Server.

Definition at line 40 of file geventhandler.cpp.

References G_DEBUG.

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

- geventhandler.h
- geventhandler.cpp