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

#include <socketengine.h>

Inheritance diagram for EventHandler:
Cullable insp::uncopiable ListenSocket StreamSocket ThreadSignalSocket BufferedSocket UserIOHandler

Public Member Functions

int GetFd () const
 
bool HasFd () const
 
int GetEventMask () const
 
void SetFd (int FD)
 
 EventHandler ()
 
virtual void OnEventHandlerRead ()=0
 
virtual void OnEventHandlerWrite ()
 
virtual void OnEventHandlerError (int errornum)
 
- Public Member Functions inherited from Cullable
virtual ~Cullable ()
 
virtual Result Cull ()
 

Protected Attributes

int fd
 

Friends

class SocketEngine
 

Additional Inherited Members

- Protected Member Functions inherited from Cullable
 Cullable ()
 

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

Member Function Documentation

◆ GetFd()

int EventHandler::GetFd ( ) const
inline

Get the current file descriptor

Returns
The file descriptor of this handler

◆ HasFd()

bool EventHandler::HasFd ( ) const
inline

Checks if this event handler has a fd associated with it.

◆ 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 ThreadSignalSocket, and StreamSocket.

◆ OnEventHandlerRead()

virtual void EventHandler::OnEventHandlerRead ( )
pure virtual

Called by the socket engine in case of a read event

Implemented in ThreadSignalSocket, ListenSocket, and StreamSocket.

◆ OnEventHandlerWrite()

void EventHandler::OnEventHandlerWrite ( )
virtual

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

Reimplemented in ThreadSignalSocket, BufferedSocket, and StreamSocket.

◆ SetFd()

void EventHandler::SetFd ( int  FD)

Set a new file descriptor

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: