00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Sig_Adapter.h 00006 * 00007 * $Id: Sig_Adapter.h 74005 2006-08-14 11:30:00Z johnnyw $ 00008 * 00009 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_SIG_ADAPTER_H 00014 #define ACE_SIG_ADAPTER_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include /**/ "ace/ACE_export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "ace/Event_Handler.h" 00025 #include "ace/Signal.h" 00026 00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00028 00029 /** 00030 * @class ACE_Sig_Adapter 00031 * 00032 * @brief Provide an adapter that transforms various types of signal 00033 * handlers into the scheme used by the ACE_Reactor. 00034 */ 00035 class ACE_Export ACE_Sig_Adapter : public ACE_Event_Handler 00036 { 00037 public: 00038 ACE_Sig_Adapter (ACE_Sig_Action &, int sigkey); 00039 ACE_Sig_Adapter (ACE_Event_Handler *, int sigkey); 00040 ACE_Sig_Adapter (ACE_Sig_Handler_Ex, int sigkey = 0); 00041 ~ACE_Sig_Adapter (void); 00042 00043 /// Returns this signal key that's used to remove this from the 00044 /// ACE_Reactor's internal table. 00045 int sigkey (void); 00046 00047 /// Called by the <Reactor> to dispatch the signal handler. 00048 virtual int handle_signal (int, siginfo_t *, ucontext_t *); 00049 00050 private: 00051 /// Key for this signal handler (used to remove it). 00052 int sigkey_; 00053 00054 /// Is this an external handler or an ACE handler? 00055 enum 00056 { 00057 /// We're just wrapping an ACE_Event_Handler. 00058 ACE_HANDLER, 00059 /// An ACE_Sig_Action. 00060 SIG_ACTION, 00061 /// A normal C function. 00062 C_FUNCTION 00063 } type_; 00064 00065 // = This should be a union, but C++ won't allow that because the 00066 // <ACE_Sig_Action> has a constructor. 00067 /// This is an external handler (ugh). 00068 ACE_Sig_Action sa_; 00069 00070 /// This is an ACE hander. 00071 ACE_Event_Handler *eh_; 00072 00073 /// This is a normal C function. 00074 ACE_Sig_Handler_Ex sig_func_; 00075 }; 00076 00077 ACE_END_VERSIONED_NAMESPACE_DECL 00078 00079 #include /**/ "ace/post.h" 00080 00081 #endif /* ACE_SIG_ADAPTER_H */