ACE  6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
ACE_Event_Handler_T< T > Class Template Reference

Enable a class that doesn't inherit from the ACE_Event_Handler to be incorporated into the ACE_Reactor framework. Thanks to Greg Lavender (g.lav.nosp@m.ende.nosp@m.r@iso.nosp@m.de.c.nosp@m.om) for sharing this idea. More...

#include <Event_Handler_T.h>

Inheritance diagram for ACE_Event_Handler_T< T >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Event_Handler_T< T >:
Collaboration graph
[legend]

Public Types

typedef ACE_HANDLE(T::* GET_HANDLE )(void) const
 
typedef void(T::* SET_HANDLE )(ACE_HANDLE)
 
typedef int(T::* IO_HANDLER )(ACE_HANDLE)
 Handle I/O events.
 
typedef int(T::* TO_HANDLER )(const ACE_Time_Value &, const void *)
 Handle timeout events.
 
typedef int(T::* CL_HANDLER )(ACE_HANDLE, ACE_Reactor_Mask)
 Handle close events.
 
typedef int(T::* SIG_HANDLER )(int, siginfo_t *, ucontext_t *)
 = Initialization and termination methods.
 
- Public Types inherited from ACE_Event_Handler
enum  {
  LO_PRIORITY = 0, HI_PRIORITY = 10, NULL_MASK = 0, READ_MASK = (1 << 0),
  WRITE_MASK = (1 << 1), EXCEPT_MASK = (1 << 2), ACCEPT_MASK = (1 << 3), CONNECT_MASK = (1 << 4),
  TIMER_MASK = (1 << 5), QOS_MASK = (1 << 6), GROUP_QOS_MASK = (1 << 7), SIGNAL_MASK = (1 << 8),
  ALL_EVENTS_MASK, RWE_MASK, DONT_CALL = (1 << 9)
}
 
enum  { ACE_EVENT_HANDLER_NOT_RESUMED = -1, ACE_REACTOR_RESUMES_HANDLER = 0, ACE_APPLICATION_RESUMES_HANDLER }
 
typedef long Reference_Count
 Reference count type.
 

Public Member Functions

 ACE_Event_Handler_T (T *op_handler, int delete_handler, GET_HANDLE get_handle=0, IO_HANDLER input=0, CL_HANDLER close=0, SIG_HANDLER sig=0, TO_HANDLER timeout=0, IO_HANDLER output=0, SET_HANDLE set_handle=0, IO_HANDLER except=0)
 Initialize the op_handler.
 
 ~ACE_Event_Handler_T (void)
 Close down and delete the <op_handler>
 
virtual ACE_HANDLE get_handle (void) const
 Get the I/O handle.
 
virtual void set_handle (ACE_HANDLE)
 Set the I/O handle.
 
virtual int handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 Called when input events occur (e.g., connection or data).
 
virtual int handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 
virtual int handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 Called when an exceptional events occur (e.g., SIGURG).
 
virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg=0)
 
virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask close_mask)
 
virtual int handle_signal (int signum, siginfo_t *=0, ucontext_t *=0)
 
T * op_handler (void)
 
void op_handler (T *)
 
GET_HANDLE handle_get (void)
 
void handle_get (GET_HANDLE)
 
SET_HANDLE handle_set (void)
 
void handle_set (SET_HANDLE)
 
IO_HANDLER input_handler (void)
 
void input_handler (IO_HANDLER)
 
IO_HANDLER output_handler (void)
 
void output_handler (IO_HANDLER)
 
IO_HANDLER except_handler (void)
 
void except_handler (IO_HANDLER)
 
TO_HANDLER to_handler (void)
 
void to_handler (TO_HANDLER)
 
CL_HANDLER cl_handler (void)
 
void cl_handler (CL_HANDLER)
 
SIG_HANDLER sig_handler (void)
 
void sig_handler (SIG_HANDLER)
 
void dump (void) const
 Dump the state of an object.
 
- Public Member Functions inherited from ACE_Event_Handler
virtual ~ACE_Event_Handler (void)
 Destructor is virtual to enable proper cleanup.
 
virtual int priority (void) const
 
virtual void priority (int priority)
 Set the priority of the Event_Handler.
 
virtual int handle_exit (ACE_Process *)
 Called when a process exits.
 
virtual int resume_handler (void)
 
virtual int handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual int handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual void reactor (ACE_Reactor *reactor)
 Set the event demultiplexors.
 
virtual ACE_Reactorreactor (void) const
 Get the event demultiplexors.
 
virtual
ACE_Reactor_Timer_Interface
reactor_timer_interface (void) const
 Get only the reactor's timer related interface.
 
virtual Reference_Count add_reference (void)
 Increment reference count on the handler.
 
virtual Reference_Count remove_reference (void)
 Decrement reference count on the handler.
 
Reference_Counting_Policyreference_counting_policy (void)
 Current Reference_Counting_Policy.
 

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.
 

Protected Attributes

T * op_handler_
 Pointer to the object that handles all the delegated operations.
 
IO_HANDLER input_handler_
 
IO_HANDLER output_handler_
 
IO_HANDLER except_handler_
 
TO_HANDLER to_handler_
 Handle timeout events.
 
CL_HANDLER cl_handler_
 Handle close events.
 
SIG_HANDLER sig_handler_
 Handle signal events.
 
int delete_handler_
 
SET_HANDLE set_handle_
 
GET_HANDLE get_handle_
 
- Protected Attributes inherited from ACE_Event_Handler
Atomic_Reference_Count reference_count_
 Reference count.
 

Additional Inherited Members

- Static Public Member Functions inherited from ACE_Event_Handler
static ACE_THR_FUNC_RETURN read_adapter (void *event_handler)
 
static int register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED)
 
static int remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr)
 Performs the inverse of the register_stdin_handler() method.
 
- Protected Types inherited from ACE_Event_Handler
typedef ACE_Atomic_Op
< ACE_SYNCH_MUTEX,
Reference_Count
Atomic_Reference_Count
 Typedef for implementation of reference counting.
 
- Protected Member Functions inherited from ACE_Event_Handler
 ACE_Event_Handler (ACE_Reactor *=0, int priority=ACE_Event_Handler::LO_PRIORITY)
 Force ACE_Event_Handler to be an abstract base class.
 

Detailed Description

template<class T>
class ACE_Event_Handler_T< T >

Enable a class that doesn't inherit from the ACE_Event_Handler to be incorporated into the ACE_Reactor framework. Thanks to Greg Lavender (g.lav.nosp@m.ende.nosp@m.r@iso.nosp@m.de.c.nosp@m.om) for sharing this idea.

It is sometimes the case that an application has a hierarchy of operation dispatcher classes that have their own inheritance hierarchy but also would like to integrate with the ACE_Reactor. Rather than adopt a "mixin" approach, it is often cleaner to define a template as a subclass of ACE_Event_Handler and parameterize it with an operation dispatcher type. When constructing an instantiation of the ACE_Event_Handler_T object, a set of pointers to member functions must be provided so that when one of the handle_* methods is called by the ACE_Reactor, the appropriate method is called on the underlying operations object. This is done since in some cases it is useful to map any event that happens to the same method on an object. The ACE_Event_Handler_T template is instantiated by an operations object and registered with the ACE_Reactor, and it then calls the appropriate op_handler. So, it's basically just another level of indirection in event dispatching. The coupling betweent the ultimate handler of the event and the ACE_Event_Handler class is relaxed a bit by have this intermediate <op_handler_> object of type <T> around. The client object can then dynamically change the bindings for the various handlers so that during the life of one of the operation objects, it can change how it wants events to be handled. It just instantiates a new instance of the template with different bindings and reregisters this new object with the ACE_Reactor.

Member Typedef Documentation

template<class T >
typedef int(T::* ACE_Event_Handler_T< T >::CL_HANDLER)(ACE_HANDLE, ACE_Reactor_Mask)

Handle close events.

template<class T >
typedef ACE_HANDLE(T::* ACE_Event_Handler_T< T >::GET_HANDLE)(void) const
template<class T >
typedef int(T::* ACE_Event_Handler_T< T >::IO_HANDLER)(ACE_HANDLE)

Handle I/O events.

template<class T >
typedef void(T::* ACE_Event_Handler_T< T >::SET_HANDLE)(ACE_HANDLE)
template<class T >
typedef int(T::* ACE_Event_Handler_T< T >::SIG_HANDLER)(int, siginfo_t *, ucontext_t *)

= Initialization and termination methods.

template<class T >
typedef int(T::* ACE_Event_Handler_T< T >::TO_HANDLER)(const ACE_Time_Value &, const void *)

Handle timeout events.

Constructor & Destructor Documentation

template<class T >
ACE_Event_Handler_T< T >::ACE_Event_Handler_T ( T *  op_handler,
int  delete_handler,
GET_HANDLE  get_handle = 0,
IO_HANDLER  input = 0,
CL_HANDLER  close = 0,
SIG_HANDLER  sig = 0,
TO_HANDLER  timeout = 0,
IO_HANDLER  output = 0,
SET_HANDLE  set_handle = 0,
IO_HANDLER  except = 0 
)

Initialize the op_handler.

template<class T >
ACE_Event_Handler_T< T >::~ACE_Event_Handler_T ( void  )

Close down and delete the <op_handler>

Member Function Documentation

template<class T >
ACE_Event_Handler_T< T >::CL_HANDLER ACE_Event_Handler_T< T >::cl_handler ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::cl_handler ( CL_HANDLER  )
template<class T >
void ACE_Event_Handler_T< T >::dump ( void  ) const

Dump the state of an object.

template<class T >
ACE_Event_Handler_T< T >::IO_HANDLER ACE_Event_Handler_T< T >::except_handler ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::except_handler ( IO_HANDLER  )
template<class T >
ACE_HANDLE ACE_Event_Handler_T< T >::get_handle ( void  ) const
virtual

Get the I/O handle.

Reimplemented from ACE_Event_Handler.

template<class T >
int ACE_Event_Handler_T< T >::handle_close ( ACE_HANDLE  handle,
ACE_Reactor_Mask  close_mask 
)
virtual

Called when a handle_*() method returns -1 or when the remove_handler() method is called on an ACE_Reactor. The close_mask indicates which event has triggered the handle_close() method callback on a particular handle.

Reimplemented from ACE_Event_Handler.

template<class T >
int ACE_Event_Handler_T< T >::handle_exception ( ACE_HANDLE  fd = ACE_INVALID_HANDLE)
virtual

Called when an exceptional events occur (e.g., SIGURG).

Reimplemented from ACE_Event_Handler.

template<class T >
ACE_Event_Handler_T< T >::GET_HANDLE ACE_Event_Handler_T< T >::handle_get ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::handle_get ( GET_HANDLE  )
template<class T >
int ACE_Event_Handler_T< T >::handle_input ( ACE_HANDLE  fd = ACE_INVALID_HANDLE)
virtual

Called when input events occur (e.g., connection or data).

Reimplemented from ACE_Event_Handler.

template<class T >
int ACE_Event_Handler_T< T >::handle_output ( ACE_HANDLE  fd = ACE_INVALID_HANDLE)
virtual

Called when output events are possible (e.g., when flow control abates or non-blocking connection completes).

Reimplemented from ACE_Event_Handler.

template<class T >
ACE_Event_Handler_T< T >::SET_HANDLE ACE_Event_Handler_T< T >::handle_set ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::handle_set ( SET_HANDLE  )
template<class T >
int ACE_Event_Handler_T< T >::handle_signal ( int  signum,
siginfo_t = 0,
ucontext_t = 0 
)
virtual

Called when object is signaled by OS (either via UNIX signals or when a Win32 object becomes signaled).

Reimplemented from ACE_Event_Handler.

template<class T >
int ACE_Event_Handler_T< T >::handle_timeout ( const ACE_Time_Value current_time,
const void *  act = 0 
)
virtual

Called when timer expires. current_time represents the current time that the Event_Handler was selected for timeout dispatching and act is the asynchronous completion token that was passed in when <schedule_timer> was invoked.

Reimplemented from ACE_Event_Handler.

template<class T >
ACE_Event_Handler_T< T >::IO_HANDLER ACE_Event_Handler_T< T >::input_handler ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::input_handler ( IO_HANDLER  )
template<class T >
T * ACE_Event_Handler_T< T >::op_handler ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::op_handler ( T *  op)
inline
template<class T >
ACE_Event_Handler_T< T >::IO_HANDLER ACE_Event_Handler_T< T >::output_handler ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::output_handler ( IO_HANDLER  )
template<class T >
void ACE_Event_Handler_T< T >::set_handle ( ACE_HANDLE  )
virtual

Set the I/O handle.

Reimplemented from ACE_Event_Handler.

template<class T >
ACE_Event_Handler_T< T >::SIG_HANDLER ACE_Event_Handler_T< T >::sig_handler ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::sig_handler ( SIG_HANDLER  )
template<class T >
ACE_Event_Handler_T< T >::TO_HANDLER ACE_Event_Handler_T< T >::to_handler ( void  )
inline
template<class T >
void ACE_Event_Handler_T< T >::to_handler ( TO_HANDLER  )

Member Data Documentation

template<class T >
ACE_Event_Handler_T< T >::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

template<class T >
CL_HANDLER ACE_Event_Handler_T< T >::cl_handler_
protected

Handle close events.

template<class T >
int ACE_Event_Handler_T< T >::delete_handler_
protected

Keeps track of whether we need to delete the handler in the destructor.

template<class T >
IO_HANDLER ACE_Event_Handler_T< T >::except_handler_
protected
template<class T >
GET_HANDLE ACE_Event_Handler_T< T >::get_handle_
protected
template<class T >
IO_HANDLER ACE_Event_Handler_T< T >::input_handler_
protected
template<class T >
T* ACE_Event_Handler_T< T >::op_handler_
protected

Pointer to the object that handles all the delegated operations.

template<class T >
IO_HANDLER ACE_Event_Handler_T< T >::output_handler_
protected
template<class T >
SET_HANDLE ACE_Event_Handler_T< T >::set_handle_
protected
template<class T >
SIG_HANDLER ACE_Event_Handler_T< T >::sig_handler_
protected

Handle signal events.

template<class T >
TO_HANDLER ACE_Event_Handler_T< T >::to_handler_
protected

Handle timeout events.


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