2 #include "QoS_Decorator.h"
4 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
6 ACE_ALLOC_HOOK_DEFINE(ACE_QOS_DECORATOR
)
9 ACE_QoS_Decorator_Base::ACE_QoS_Decorator_Base ()
13 ACE_QoS_Decorator_Base::ACE_QoS_Decorator_Base (ACE_Event_Handler
15 : event_handler_ (event_handler
)
20 ACE_QoS_Decorator_Base::~ACE_QoS_Decorator_Base ()
24 // Forward the call to ACE_Event_Handler component.
26 ACE_QoS_Decorator_Base::get_handle () const
28 return this->event_handler_
->get_handle ();
31 // Forward the call to ACE_Event_Handler component.
33 ACE_QoS_Decorator_Base::handle_input (ACE_HANDLE fd
)
35 return this->event_handler_
->handle_input (fd
);
38 // Forward the call to ACE_Event_Handler component.
40 ACE_QoS_Decorator_Base::handle_qos (ACE_HANDLE fd
)
42 return this->event_handler_
->handle_qos (fd
);
46 ACE_QoS_Decorator::ACE_QoS_Decorator ()
50 ACE_QoS_Decorator::ACE_QoS_Decorator (ACE_Event_Handler
*event_handler
,
51 ACE_QoS_Session
*qos_session
,
53 : qos_session_ (qos_session
),
56 ACE_NEW (this->decorator_base_
,
57 ACE_QoS_Decorator_Base (event_handler
));
59 ACE_NEW (this->qos_event_handler_
,
60 ACE_QoS_Event_Handler (this->decorator_base_
));
64 ACE_QoS_Decorator::~ACE_QoS_Decorator ()
66 delete this->decorator_base_
;
67 delete this->qos_event_handler_
;
70 // Implements the undecorated functionality. This is sufficient for
71 // GQoS. RAPI needs additional QoS decoration. This is done by the
72 // ACE_QoS_Event_Handler class.
74 ACE_QoS_Decorator::get_handle () const
76 return this->decorator_base_
->get_handle ();
79 // Implements the undecorated functionality. This is sufficient for
80 // GQoS. RAPI needs additional QoS decoration. This is done by the
81 // ACE_QoS_Event_Handler class.
83 ACE_QoS_Decorator::handle_input (ACE_HANDLE fd
)
85 return this->decorator_base_
->handle_input (fd
);
88 // Implements the undecorated functionality. This is sufficient for
89 // GQoS. RAPI needs additional QoS decoration. This is done by the
90 // ACE_QoS_Event_Handler class.
92 ACE_QoS_Decorator::handle_qos (ACE_HANDLE fd
)
94 return this->decorator_base_
->handle_qos (fd
);
97 // This method registers the RAPI QoS event handler with the reactor
98 // if the application is using RAPI. Note that it is a no-op for GQoS
99 // because an extra socket for handling QoS events is not required.
101 ACE_QoS_Decorator::init ()
103 #if defined (ACE_HAS_RAPI)
105 // Pass the QoS session to QoS Event Handler.
106 this->qos_event_handler_
->qos_session (this->qos_session_
);
108 // Register the QoS Event Handler with the Reactor.
109 return this->reactor_
->register_handler (this->qos_event_handler_
,
110 ACE_Event_Handler::READ_MASK
);
116 ACE_QoS_Event_Handler::ACE_QoS_Event_Handler ()
121 ACE_QoS_Event_Handler::ACE_QoS_Event_Handler (ACE_QoS_Decorator_Base
123 : decorator_base_ (decorator_base
)
128 ACE_QoS_Event_Handler::~ACE_QoS_Event_Handler ()
132 // Set the QoS session.
134 ACE_QoS_Event_Handler::qos_session (ACE_QoS_Session
*qos_session
)
136 this->qos_session_
= qos_session
;
139 // Returns the RAPI file descriptor for listening to RAPI evnets.
141 ACE_QoS_Event_Handler::get_handle () const
143 return this->qos_session_
->rsvp_events_handle ();
146 // Note, here the handle_input () calls the handle_qos () of the
147 // Decorator Base which then calls handle_qos () of the
148 // ACE_Event_Handler component within it. This helps to translate the
149 // normal read events into qos events in case of RAPI so the
150 // application using the API is oblivious to the fact that in RAPI,
151 // QoS events are received on a different socket. This helps to
152 // maintain a uniform design for the application irrespective of
153 // whether it is using RAPI or GQoS.
155 ACE_QoS_Event_Handler::handle_input (ACE_HANDLE fd
)
157 return this->decorator_base_
->handle_qos (fd
);
160 ACE_END_VERSIONED_NAMESPACE_DECL