InspIRCd  3.0
Public Member Functions | Protected Attributes | Friends | List of all members
EventHandler Class Referenceabstract

#include <socketengine.h>

Inheritance diagram for EventHandler:
classbase ListenSocket StreamSocket ThreadSignalSocket BufferedSocket UserIOHandler ThreadSignalSocket

Public Member Functions

int GetFd () const
 
int GetEventMask () const
 
void SetFd (int FD)
 
 EventHandler ()
 
virtual ~EventHandler ()
 
virtual void OnEventHandlerRead ()=0
 
virtual void OnEventHandlerWrite ()
 
virtual void OnEventHandlerError (int errornum)
 
- Public Member Functions inherited from classbase
virtual CullResult cull ()
 

Protected Attributes

int fd
 

Friends

class SocketEngine
 

Detailed Description

This class is a basic I/O handler class. Any object which wishes to receive basic I/O events from the socketengine must derive from this class and implement the OnEventHandler*() methods. The derived class must then be added to SocketEngine using the method SocketEngine::AddFd(), after which point the derived class will receive events to its OnEventHandler*() methods. The event mask passed to SocketEngine::AddFd() determines what events the EventHandler gets notified about and with what semantics. SocketEngine::ChangeEventMask() can be called to update the event mask later. The only requirement beyond this for an event handler is that it must have a file descriptor. What this file descriptor is actually attached to is completely up to you.

Constructor & Destructor Documentation

◆ EventHandler()

EventHandler::EventHandler ( )

Constructor

◆ ~EventHandler()

virtual EventHandler::~EventHandler ( )
inlinevirtual

Destructor

Member Function Documentation

◆ GetFd()

int EventHandler::GetFd ( ) const
inline

Get the current file descriptor

Returns
The file descriptor of this handler

◆ OnEventHandlerError()

void EventHandler::OnEventHandlerError ( int  errornum)
virtual

Called by the socket engine in case of an error event. The default implementation does nothing.

Parameters
errornumError code

Reimplemented in StreamSocket, and ThreadSignalSocket.

◆ OnEventHandlerRead()

virtual void EventHandler::OnEventHandlerRead ( )
pure virtual

Called by the socket engine in case of a read event

Implemented in StreamSocket, ListenSocket, and ThreadSignalSocket.

◆ OnEventHandlerWrite()

void EventHandler::OnEventHandlerWrite ( )
virtual

Called by the socket engine in case of a write event. The default implementation does nothing.

Reimplemented in BufferedSocket, StreamSocket, and ThreadSignalSocket.

◆ SetFd()

void EventHandler::SetFd ( int  FD)

Set a new file desciptor

Parameters
FDThe new file descriptor. Do not call this method without first deleting the object from the SocketEngine if you have added it to a SocketEngine instance.

Member Data Documentation

◆ fd

int EventHandler::fd
protected

File descriptor. All events which can be handled must have a file descriptor. This allows you to add events for sockets, fifo's, pipes, and various other forms of IPC. Do not change this while the object is registered with the SocketEngine


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