Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / QoS / QoS_Decorator.cpp
blob3cbe77a40d491d78d4a7272a6fefe9f778f66c58
1 // QoS_Decorator.cpp
2 #include "QoS_Decorator.h"
4 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
6 ACE_ALLOC_HOOK_DEFINE(ACE_QOS_DECORATOR)
8 // Constructor.
9 ACE_QoS_Decorator_Base::ACE_QoS_Decorator_Base ()
12 // Constructor.
13 ACE_QoS_Decorator_Base::ACE_QoS_Decorator_Base (ACE_Event_Handler
14 *event_handler)
15 : event_handler_ (event_handler)
19 // Destructor.
20 ACE_QoS_Decorator_Base::~ACE_QoS_Decorator_Base ()
24 // Forward the call to ACE_Event_Handler component.
25 ACE_HANDLE
26 ACE_QoS_Decorator_Base::get_handle () const
28 return this->event_handler_->get_handle ();
31 // Forward the call to ACE_Event_Handler component.
32 int
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.
39 int
40 ACE_QoS_Decorator_Base::handle_qos (ACE_HANDLE fd)
42 return this->event_handler_->handle_qos (fd);
45 // Constructor.
46 ACE_QoS_Decorator::ACE_QoS_Decorator ()
49 // Constructor.
50 ACE_QoS_Decorator::ACE_QoS_Decorator (ACE_Event_Handler *event_handler,
51 ACE_QoS_Session *qos_session,
52 ACE_Reactor *reactor)
53 : qos_session_ (qos_session),
54 reactor_ (reactor)
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_));
63 // Destructor.
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.
73 ACE_HANDLE
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.
82 int
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.
91 int
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);
111 #endif
112 return 0;
115 // Constructor.
116 ACE_QoS_Event_Handler::ACE_QoS_Event_Handler ()
120 // Constructor.
121 ACE_QoS_Event_Handler::ACE_QoS_Event_Handler (ACE_QoS_Decorator_Base
122 *decorator_base)
123 : decorator_base_ (decorator_base)
127 // Destructor.
128 ACE_QoS_Event_Handler::~ACE_QoS_Event_Handler ()
132 // Set the QoS session.
133 void
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.
140 ACE_HANDLE
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