Loading...
Searching...
No Matches
ASSA::EventHandler Class Reference

EventHandler class. More...

`#include <EventHandler.h>`

Inheritance diagram for ASSA::EventHandler:

## Public Member Functions

| EventHandler ()
| Constructor.
virtual | ~EventHandler ()
| Virtual destructor.
virtual int | handle_read (int fd)
| Read event callback.
virtual int | handle_write (int fd)
| Write handler callback.
virtual int | handle_except (int fd)
| Exception handler callback.
virtual int | handle_timeout (TimerId tid)
| Timeout handler callback.
virtual int | handle_signal (int signum_)
| Signal handler callback.
virtual int | handle_close (int fd)
| EOF on peer socket handler callback.
virtual void | resetState (void)
| A hook for derived class to reset internal state as needed.
void | set_id (const std::string &id_)
| Set EventHandler ID.
std::string | get_id () const
| Retrieve EventHandler ID.

## Protected Attributes

std::string | m_id

## Detailed Description

EventHandler class.

EventHandler is a pure virtual class. It is an interface class to the Event Handlers. These events are processed by Reactor. The supported events are signals, timers, and I/O pipes such as file descriptors, sockets and such.

See also
  EventType

Definition at line 102 of file EventHandler.h.

## Constructor & Destructor Documentation

## EventHandler()

ASSA::EventHandler::EventHandler | ( |  | ) |

inline

Constructor.

Definition at line 164 of file EventHandler.h.

: m_id ("EventHandler")
{
trace_with_mask("EventHandler::EventHandler",REACTTRACE);
}
trace_with_mask
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition Logger.h:437
ASSA::EventHandler::m_id
std::string m_id
Definition EventHandler.h:160
ASSA::REACTTRACE
@ REACTTRACE
Extended Reactor/PrioriyQueue messages.
Definition LogMask.h:40

References m_id, ASSA::REACTTRACE, and trace_with_mask.

Referenced by ASSA::GenServer::init().

## ~EventHandler()

virtual ASSA::EventHandler::~EventHandler | ( |  | ) |

inline virtual

Virtual destructor.

Definition at line 109 of file EventHandler.h.

{ /* no-op */ }

## Member Function Documentation

## get_id()

std::string ASSA::EventHandler::get_id | ( |  | ) | const

inline

Retrieve EventHandler ID.

Definition at line 157 of file EventHandler.h.

{ return m_id; }

References m_id.

Referenced by ASSA::Reactor::dispatchHandler(), ASSA::Acceptor< SERVICE_HANDLER, PEER_ACCEPTOR >::handle_close(), ASSA::Reactor::registerIOHandler(), ASSA::Reactor::removeHandler(), and ASSA::Reactor::removeIOHandler().

## handle_close()

int ASSA::EventHandler::handle_close | ( | int | fd | ) |

inline virtual

EOF on peer socket handler callback.

There is no corresponding EventType. One is not needed because detecting EOF is a part of handle_read () data processing.

Returns
  0 on success, -1 on error

Reimplemented in ASSA::Acceptor< SERVICE_HANDLER, PEER_ACCEPTOR >, and ASSA::RemoteLogger.

Definition at line 211 of file EventHandler.h.

{
trace_with_mask("EventHandler::handle_close",REACTTRACE);
return -1;
}

References ASSA::REACTTRACE, and trace_with_mask.

Referenced by ASSA::Reactor::removeHandler(), and ASSA::Reactor::removeIOHandler().

## handle_except()

int ASSA::EventHandler::handle_except | ( | int | fd | ) |

inline virtual

Exception handler callback.

Returns
  0 on success, -1 on error

Definition at line 187 of file EventHandler.h.

{
trace_with_mask("EventHandler::handle_except",REACTTRACE);
return -1;
}

References ASSA::REACTTRACE, and trace_with_mask.

Referenced by ASSA::Reactor::dispatch().

## handle_read()

int ASSA::EventHandler::handle_read | ( | int | fd | ) |

inline virtual

Read event callback.

If reader detects EOF, it must return error to the Reactor. (See Reactor for details).

Returns
  0 on success, -1 on error

Reimplemented in ASSA::Acceptor< SERVICE_HANDLER, PEER_ACCEPTOR >.

Definition at line 171 of file EventHandler.h.

{
trace_with_mask("EventHandler::handle_read",REACTTRACE);
return -1;
}

References ASSA::REACTTRACE, and trace_with_mask.

Referenced by ASSA::Reactor::dispatch().

## handle_signal()

int ASSA::EventHandler::handle_signal | ( | int | signum_ | ) |

inline virtual

Signal handler callback.

Returns
  0 on success, -1 on error

Reimplemented in ASSA::CFUNC_Handler, ASSA::ChildStatusHandler, ASSA::GenServer, ASSA::SIGALRMHandler, ASSA::SIGCHLDHandler, ASSA::SIGINTHandler, ASSA::SIGPOLLHandler, ASSA::SIGUSR1Handler, and ASSA::SIGUSR2Handler.

Definition at line 203 of file EventHandler.h.

{
trace_with_mask("EventHandler::handle_signal",REACTTRACE);
return -1;
}

References ASSA::REACTTRACE, and trace_with_mask.

Referenced by ASSA::SigHandler::dispatch(), and ASSA::SigHandlers::dispatch().

## handle_timeout()

int ASSA::EventHandler::handle_timeout | ( | TimerId | tid | ) |

inline virtual

Timeout handler callback.

Returns
  1 to reschedule the timer, 0 otherwise

Reimplemented in ASSA::Connector< SERVICE_HANDLER, PEER_CONNECTOR >.

Definition at line 195 of file EventHandler.h.

{
trace_with_mask("EventHandler::handle_timeout",REACTTRACE);
return -1;
}

References ASSA::REACTTRACE, and trace_with_mask.

Referenced by ASSA::TimerQueue::expire().

## handle_write()

int ASSA::EventHandler::handle_write | ( | int | fd | ) |

inline virtual

Write handler callback.

Returns
  0 on success, -1 on error

Reimplemented in ASSA::Connector< SERVICE_HANDLER, PEER_CONNECTOR >.

Definition at line 179 of file EventHandler.h.

{
trace_with_mask("EventHandler::handle_write",REACTTRACE);
return -1;
}

References ASSA::REACTTRACE, and trace_with_mask.

Referenced by ASSA::Reactor::dispatch().

## resetState()

void ASSA::EventHandler::resetState | ( | void |  | ) |

inline virtual

A hook for derived class to reset internal state as needed.

Reimplemented in ASSA::SIGALRMHandler, ASSA::SIGCHLDHandler, ASSA::SIGINTHandler, ASSA::SIGUSR1Handler, and ASSA::SIGUSR2Handler.

Definition at line 219 of file EventHandler.h.

{
trace_with_mask("EventHandler::reset",REACTTRACE);
}

References ASSA::REACTTRACE, and trace_with_mask.

## set_id()

void ASSA::EventHandler::set_id | ( | const std::string & | id_ | ) |

inline

Set EventHandler ID.

ID allows Reactor and application-level code describe intelligently the kind of the EventHandler.

Definition at line 153 of file EventHandler.h.

{ m_id = id_; }

References m_id.

Referenced by ASSA::Connector< SERVICE_HANDLER, PEER_CONNECTOR >::Connector().

## Member Data Documentation

## m_id

std::string ASSA::EventHandler::m_id

protected

Definition at line 160 of file EventHandler.h.

Referenced by EventHandler(), get_id(), and set_id().

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

- EventHandler.h