00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file QoS_Decorator.h 00006 * 00007 * $Id: QoS_Decorator.h 80826 2008-03-04 14:51:23Z wotte $ 00008 * 00009 * @author Vishal Kachroo <vishal@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef QOS_DECORATOR_H 00015 #define QOS_DECORATOR_H 00016 #include /**/ "ace/pre.h" 00017 00018 #include "ace/Reactor.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "ace/INET_Addr.h" 00025 #include "ace/Event_Handler.h" 00026 #include "SOCK_Dgram_Mcast_QoS.h" 00027 #include "ACE_QoS_Export.h" 00028 00029 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 /** 00032 * @class ACE_QoS_Decorator_Base 00033 * 00034 * @brief This class is the Decorator Pattern Base class for decorating 00035 * ACE_Event_Handler. 00036 * 00037 * It simply forwards the requests for get_handle (), 00038 * handle_input () and handle_qos () to its event_handler_ 00039 * component. Concrete decorators for ACE_Event_Handler will use 00040 * this class to access the basic event handler functionality and 00041 * decorate that by their own implementation. 00042 */ 00043 class ACE_QoS_Export ACE_QoS_Decorator_Base : public ACE_Event_Handler 00044 { 00045 00046 public: 00047 00048 // Initialization and termination methods. 00049 /// Constructor. 00050 ACE_QoS_Decorator_Base (void); 00051 00052 /// Constructor. 00053 ACE_QoS_Decorator_Base (ACE_Event_Handler *event_handler); 00054 00055 /// Destructor. 00056 ~ACE_QoS_Decorator_Base (void); 00057 00058 /// Forwards the request to its event_handler_ component. 00059 virtual ACE_HANDLE get_handle (void) const; 00060 00061 /// Forwards the request to its event_handler_ component. 00062 virtual int handle_input (ACE_HANDLE fd); 00063 00064 /// Forwards the request to its event_handler_ component. 00065 virtual int handle_qos (ACE_HANDLE fd); 00066 00067 private: 00068 00069 /// The event handler that is decorated by this class. 00070 ACE_Event_Handler *event_handler_; 00071 00072 }; 00073 00074 /** 00075 * @class ACE_QoS_Event_Handler 00076 * 00077 * @brief This Handler is registered with the Reactor for QoS events. 00078 * 00079 * Concrete QoS decorator uses this class to receive QoS events 00080 * for RAPI. It hides the application from knowing that it is 00081 * receiving QoS events on a different socket so the application 00082 * doesnt have to be designed differently for RAPI and GQoS. 00083 */ 00084 class ACE_QoS_Export ACE_QoS_Event_Handler : public ACE_Event_Handler 00085 { 00086 00087 /// Destructor. 00088 ~ACE_QoS_Event_Handler (void); 00089 00090 /// Returns the RAPI file descriptor for receiving QoS events. 00091 virtual ACE_HANDLE get_handle (void) const; 00092 00093 /// Calls the base class handle_input (). 00094 virtual int handle_input (ACE_HANDLE fd); 00095 00096 /// Sets the QoS session. 00097 void qos_session (ACE_QoS_Session *qos_session); 00098 00099 friend class ACE_QoS_Decorator; 00100 00101 private: 00102 00103 /// Constructor is private because only ACE_QoS_Decorator should 00104 /// create this object. 00105 ACE_QoS_Event_Handler (void); 00106 00107 /// The QoS Decorator passes in its base for this handler to use. 00108 ACE_QoS_Event_Handler (ACE_QoS_Decorator_Base *decorator_base); 00109 00110 /// Used to get to the RAPI file descriptor for QoS Events. 00111 ACE_QoS_Session *qos_session_; 00112 00113 /// Requests on the class are forwarded to this base class; 00114 ACE_QoS_Decorator_Base *decorator_base_; 00115 00116 }; 00117 00118 /** 00119 * @class ACE_QoS_Decorator 00120 * 00121 * @brief Concrete QoS Decorator. 00122 * 00123 * Decorates the ACE_Event_Handler to additionally handle QoS 00124 * events uniformly for different QoS mechanisms like RAPI and 00125 * GQoS. 00126 */ 00127 class ACE_QoS_Export ACE_QoS_Decorator : public ACE_QoS_Decorator_Base 00128 { 00129 00130 public: 00131 00132 // Initialization and termination methods. 00133 /// Constructor. 00134 ACE_QoS_Decorator (void); 00135 00136 /// Constructor. 00137 ACE_QoS_Decorator (ACE_Event_Handler *event_handler, 00138 ACE_QoS_Session *qos_session, 00139 ACE_Reactor *reactor = ACE_Reactor::instance ()); 00140 00141 /// Destructor. 00142 ~ACE_QoS_Decorator (void); 00143 00144 /// Calls the base class get_handle (). 00145 virtual ACE_HANDLE get_handle (void) const; 00146 00147 /// Calls the base class handle_input (). 00148 virtual int handle_input (ACE_HANDLE fd); 00149 00150 /// Calls the base class handle_qos (). 00151 virtual int handle_qos (ACE_HANDLE fd); 00152 00153 /// This method registers the QoS Event Handler with the Reactor 00154 /// to receive RAPI events. 00155 int init (void); 00156 00157 private: 00158 00159 /// Requests on the class are forwarded to this base class; 00160 ACE_QoS_Decorator_Base *decorator_base_; 00161 00162 /// Handles the QoS events and in that sense decorates the usual 00163 /// ACE_Event_Handler. 00164 ACE_QoS_Event_Handler *qos_event_handler_; 00165 00166 /// Passed to the ACE_QoS_Event_Handler for retrieving the RAPI 00167 /// session specific information like rapi_fd. 00168 ACE_QoS_Session *qos_session_; 00169 00170 /// If the application wants to use an instance of Reactor other 00171 /// than the Singleton one. 00172 ACE_Reactor *reactor_; 00173 00174 }; 00175 00176 ACE_END_VERSIONED_NAMESPACE_DECL 00177 00178 #include /**/ "ace/post.h" 00179 #endif /* QOS_DECORATOR_H */