Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

QoS_Decorator.cpp

Go to the documentation of this file.
00001 // QoS_Decorator.cpp
00002 // $Id: QoS_Decorator.cpp,v 1.1.1.1 2001/12/04 14:33:13 chad Exp $
00003 
00004 #include "QoS_Decorator.h"
00005 
00006 ACE_RCSID(ace, QoS_Decorator, "$Id $")
00007 
00008 ACE_ALLOC_HOOK_DEFINE(ACE_QOS_DECORATOR)
00009 
00010 // Constructor.
00011 ACE_QoS_Decorator_Base::ACE_QoS_Decorator_Base (void)
00012 {}
00013 
00014 // Constructor.
00015 ACE_QoS_Decorator_Base::ACE_QoS_Decorator_Base (ACE_Event_Handler
00016                                                 *event_handler)
00017   : event_handler_ (event_handler)
00018 {
00019 }
00020 
00021 // Destructor.
00022 ACE_QoS_Decorator_Base::~ACE_QoS_Decorator_Base (void)
00023 {
00024 }
00025 
00026 // Forward the call to ACE_Event_Handler component.
00027 ACE_HANDLE
00028 ACE_QoS_Decorator_Base::get_handle (void) const
00029 {
00030  return this->event_handler_->get_handle ();
00031 }
00032 
00033 // Forward the call to ACE_Event_Handler component.
00034 int
00035 ACE_QoS_Decorator_Base::handle_input (ACE_HANDLE fd)
00036 {
00037   return this->event_handler_->handle_input (fd);
00038 }
00039 
00040 // Forward the call to ACE_Event_Handler component.
00041 int
00042 ACE_QoS_Decorator_Base::handle_qos (ACE_HANDLE fd)
00043 {
00044   return this->event_handler_->handle_qos (fd);
00045 }
00046 
00047 // Constructor.
00048 ACE_QoS_Decorator::ACE_QoS_Decorator (void)
00049 {}
00050 
00051 // Constructor.
00052 ACE_QoS_Decorator::ACE_QoS_Decorator (ACE_Event_Handler *event_handler,
00053                                       ACE_QoS_Session *qos_session,
00054                                       ACE_Reactor *reactor)
00055   : qos_session_ (qos_session),
00056     reactor_ (reactor)
00057 {
00058   ACE_NEW (this->decorator_base_,
00059            ACE_QoS_Decorator_Base (event_handler));
00060 
00061   ACE_NEW (this->qos_event_handler_,
00062            ACE_QoS_Event_Handler (this->decorator_base_));
00063 }
00064 
00065 // Destructor.
00066 ACE_QoS_Decorator::~ACE_QoS_Decorator (void)
00067 {
00068   delete this->decorator_base_;
00069   delete this->qos_event_handler_;
00070 }
00071 
00072 // Implements the undecorated functionality. This is sufficient for
00073 // GQoS. RAPI needs additional QoS decoration. This is done by the
00074 // ACE_QoS_Event_Handler class.
00075 ACE_HANDLE
00076 ACE_QoS_Decorator::get_handle (void) const
00077 {
00078   return this->decorator_base_->get_handle ();
00079 }
00080 
00081 // Implements the undecorated functionality. This is sufficient for
00082 // GQoS. RAPI needs additional QoS decoration. This is done by the
00083 // ACE_QoS_Event_Handler class.
00084 int
00085 ACE_QoS_Decorator::handle_input (ACE_HANDLE fd)
00086 {
00087   return this->decorator_base_->handle_input (fd);
00088 }
00089 
00090 // Implements the undecorated functionality. This is sufficient for
00091 // GQoS. RAPI needs additional QoS decoration. This is done by the
00092 // ACE_QoS_Event_Handler class.
00093 int
00094 ACE_QoS_Decorator::handle_qos (ACE_HANDLE fd)
00095 {
00096   return this->decorator_base_->handle_qos (fd);
00097 }
00098 
00099 // This method registers the RAPI QoS event handler with the reactor
00100 // if the application is using RAPI. Note that it is a no-op for GQoS
00101 // because an extra socket for handling QoS events is not required.
00102 int
00103 ACE_QoS_Decorator::init (void)
00104 {
00105 #if defined (ACE_HAS_RAPI)
00106 
00107   // Pass the QoS session to QoS Event Handler.
00108   this->qos_event_handler_->qos_session (this->qos_session_);
00109 
00110   // Register the QoS Event Handler with the Reactor.
00111   return this->reactor_->register_handler (this->qos_event_handler_,
00112                                            ACE_Event_Handler::READ_MASK);
00113 #endif
00114   return 0;
00115 
00116 }
00117 
00118 // Constructor.
00119 ACE_QoS_Event_Handler::ACE_QoS_Event_Handler (void)
00120 {
00121 }
00122 
00123 // Constructor.
00124 ACE_QoS_Event_Handler::ACE_QoS_Event_Handler (ACE_QoS_Decorator_Base
00125                                               *decorator_base)
00126   : decorator_base_ (decorator_base)
00127 {
00128 }
00129 
00130 // Destructor.
00131 ACE_QoS_Event_Handler::~ACE_QoS_Event_Handler (void)
00132 {
00133 }
00134 
00135 // Set the QoS session.
00136 void
00137 ACE_QoS_Event_Handler::qos_session (ACE_QoS_Session *qos_session)
00138 {
00139   this->qos_session_ = qos_session;
00140 }
00141 
00142 // Returns the RAPI file descriptor for listening to RAPI evnets.
00143 ACE_HANDLE
00144 ACE_QoS_Event_Handler::get_handle (void) const
00145 {
00146   return this->qos_session_->rsvp_events_handle ();
00147 }
00148 
00149 // Note, here the handle_input () calls the handle_qos () of the
00150 // Decorator Base which then calls handle_qos () of the
00151 // ACE_Event_Handler component within it. This helps to translate the
00152 // normal read events into qos events in case of RAPI so the
00153 // application using the API is oblivious to the fact that in RAPI,
00154 // QoS events are received on a different socket. This helps to
00155 // maintain a uniform design for the application irrespective of
00156 // whether it is using RAPI or GQoS.
00157 int
00158 ACE_QoS_Event_Handler::handle_input (ACE_HANDLE fd)
00159 {
00160   return this->decorator_base_->handle_qos (fd);
00161 }

Generated on Mon Jun 16 13:17:26 2003 for ACE_QoS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002