libassa  3.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Attributes | List of all members
ASSA::EventHandler Class Reference

EventHandler class. More...

#include <EventHandler.h>

Inheritance diagram for ASSA::EventHandler:
ASSA::Acceptor< SERVICE_HANDLER, PEER_ACCEPTOR > ASSA::CFUNC_Handler ASSA::ChildStatusHandler ASSA::Connector< SERVICE_HANDLER, PEER_CONNECTOR > ASSA::GenServer ASSA::ServiceHandler< PEER_STREAM > ASSA::SIGALRMHandler ASSA::SIGCHLDHandler ASSA::SIGINTHandler ASSA::SIGPOLLHandler ASSA::SIGUSR1Handler ASSA::SIGUSR2Handler ASSA::ServiceHandler< ASSA::IPv4Socket >

Public Member Functions

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

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

ASSA::EventHandler::EventHandler ( )
inline

Constructor.

Definition at line 165 of file EventHandler.h.

References ASSA::REACTTRACE, and trace_with_mask.

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

Virtual destructor.

Definition at line 109 of file EventHandler.h.

109 { /* no-op */ }

Member Function Documentation

std::string ASSA::EventHandler::get_id ( ) const
inline
int ASSA::EventHandler::handle_close ( int  fd)
inlinevirtual

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 212 of file EventHandler.h.

References ASSA::REACTTRACE, and trace_with_mask.

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

213 {
214  trace_with_mask("EventHandler::handle_close",REACTTRACE);
215  return -1;
216 }
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition: Logger.h:437
Extended Reactor/PrioriyQueue messages.
Definition: LogMask.h:40
int ASSA::EventHandler::handle_except ( int  fd)
inlinevirtual

Exception handler callback.

Returns
0 on success, -1 on error

Definition at line 188 of file EventHandler.h.

References ASSA::REACTTRACE, and trace_with_mask.

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

189 {
190  trace_with_mask("EventHandler::handle_except",REACTTRACE);
191  return -1;
192 }
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition: Logger.h:437
Extended Reactor/PrioriyQueue messages.
Definition: LogMask.h:40
int ASSA::EventHandler::handle_read ( int  fd)
inlinevirtual

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 172 of file EventHandler.h.

References ASSA::REACTTRACE, and trace_with_mask.

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

173 {
174  trace_with_mask("EventHandler::handle_read",REACTTRACE);
175  return -1;
176 }
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition: Logger.h:437
Extended Reactor/PrioriyQueue messages.
Definition: LogMask.h:40
int ASSA::EventHandler::handle_signal ( int  signum_)
inlinevirtual

Signal handler callback.

Returns
0 on success, -1 on error

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

Definition at line 204 of file EventHandler.h.

References ASSA::REACTTRACE, and trace_with_mask.

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

205 {
206  trace_with_mask("EventHandler::handle_signal",REACTTRACE);
207  return -1;
208 }
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition: Logger.h:437
Extended Reactor/PrioriyQueue messages.
Definition: LogMask.h:40
int ASSA::EventHandler::handle_timeout ( TimerId  tid)
inlinevirtual

Timeout handler callback.

Returns
1 to reschedule the timer, 0 otherwise

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

Definition at line 196 of file EventHandler.h.

References ASSA::REACTTRACE, and trace_with_mask.

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

197 {
198  trace_with_mask("EventHandler::handle_timeout",REACTTRACE);
199  return -1;
200 }
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition: Logger.h:437
Extended Reactor/PrioriyQueue messages.
Definition: LogMask.h:40
int ASSA::EventHandler::handle_write ( int  fd)
inlinevirtual

Write handler callback.

Returns
0 on success, -1 on error

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

Definition at line 180 of file EventHandler.h.

References ASSA::REACTTRACE, and trace_with_mask.

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

181 {
182  trace_with_mask("EventHandler::handle_write",REACTTRACE);
183  return -1;
184 }
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition: Logger.h:437
Extended Reactor/PrioriyQueue messages.
Definition: LogMask.h:40
void ASSA::EventHandler::resetState ( void  )
inlinevirtual

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

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

Definition at line 220 of file EventHandler.h.

References ASSA::REACTTRACE, and trace_with_mask.

221 {
222  trace_with_mask("EventHandler::reset",REACTTRACE);
223 }
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition: Logger.h:437
Extended Reactor/PrioriyQueue messages.
Definition: LogMask.h:40
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.

References m_id.

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

153 { m_id = id_; }
std::string m_id
Definition: EventHandler.h:160

Member Data Documentation

std::string ASSA::EventHandler::m_id
protected

Definition at line 160 of file EventHandler.h.

Referenced by get_id(), and set_id().


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