summaryrefslogtreecommitdiff
path: root/ace/QoS/QoS_Decorator.h
blob: 3fc38879113801d84ba32b896ee574a98b12fb25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    QoS_Decorator.h
 *
 *  $Id$
 *
 *  @author Vishal Kachroo <vishal@cs.wustl.edu>
 */
//=============================================================================


#ifndef QOS_DECORATOR_H
#define QOS_DECORATOR_H
#include "ace/pre.h"

#include "ace/Reactor.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/INET_Addr.h"
#include "ace/Event_Handler.h"
#include "SOCK_Dgram_Mcast_QoS.h"
#include "ACE_QoS_Export.h"

ACE_RCSID(QOS_Decorator, QOS_Decorator, "$Id$")

/**
 * @class ACE_QoS_Decorator_Base
 *
 * @brief This class is the Decorator Pattern Base class for decorating
 * ACE_Event_Handler.
 *
 * It simply forwards the requests for get_handle (),
 * handle_input () and handle_qos () to its event_handler_
 * component. Concrete decorators for ACE_Event_Handler will use
 * this class to access the basic event handler functionality and
 * decorate that by their own implementation.
 */
class ACE_QoS_Export ACE_QoS_Decorator_Base : public ACE_Event_Handler
{

public:

  // Initialization and termination methods.
  /// Constructor.
  ACE_QoS_Decorator_Base (void);

  /// Constructor.
  ACE_QoS_Decorator_Base (ACE_Event_Handler *event_handler);

  /// Destructor.
  ~ACE_QoS_Decorator_Base (void);

  /// Forwards the request to its event_handler_ component.
  virtual ACE_HANDLE get_handle (void) const;

  /// Forwards the request to its event_handler_ component.
  virtual int handle_input (ACE_HANDLE fd);

  /// Forwards the request to its event_handler_ component.
  virtual int handle_qos (ACE_HANDLE fd);

private:

  /// The event handler that is decorated by this class.
  ACE_Event_Handler *event_handler_;

};

/**
 * @class ACE_QoS_Event_Handler
 *
 * @brief This Handler is registered with the Reactor for QoS events.
 *
 * Concrete QoS decorator uses this class to receive QoS events
 * for RAPI.  It hides the application from knowing that it is
 * receiving QoS events on a different socket so the application
 * doesnt have to be designed differently for RAPI and GQoS.
 */
class ACE_QoS_Export ACE_QoS_Event_Handler : public ACE_Event_Handler
{

  /// Destructor.
  ~ACE_QoS_Event_Handler (void);

  /// Returns the RAPI file descriptor for receiving QoS events.
  virtual ACE_HANDLE get_handle (void) const;

  /// Calls the base class handle_input ().
  virtual int handle_input (ACE_HANDLE fd);

  /// Sets the QoS session.
  void qos_session (ACE_QoS_Session *qos_session);

  friend class ACE_QoS_Decorator;

private:

  /// Constructor is private because only ACE_QoS_Decorator should
  /// create this object.
  ACE_QoS_Event_Handler (void);

  /// The QoS Decorator passes in its base for this handler to use.
  ACE_QoS_Event_Handler (ACE_QoS_Decorator_Base *decorator_base);

  /// Used to get to the RAPI file descriptor for QoS Events.
  ACE_QoS_Session *qos_session_;

  /// Requests on the class are forwarded to this base class;
  ACE_QoS_Decorator_Base *decorator_base_;

};

/**
 * @class ACE_QoS_Decorator
 *
 * @brief Concrete QoS Decorator.
 *
 * Decorates the ACE_Event_Handler to additionally handle QoS
 * events uniformly for different QoS mechanisms like RAPI and
 * GQoS.
 */
class ACE_QoS_Export ACE_QoS_Decorator : public ACE_QoS_Decorator_Base
{

public:

  // Initialization and termination methods.
  /// Constructor.
  ACE_QoS_Decorator (void);

  /// Constructor.
  ACE_QoS_Decorator (ACE_Event_Handler *event_handler,
                     ACE_QoS_Session *qos_session,
                     ACE_Reactor *reactor = ACE_Reactor::instance ());

  /// Destructor.
  ~ACE_QoS_Decorator (void);

  /// Calls the base class get_handle ().
  virtual ACE_HANDLE get_handle (void) const;

  /// Calls the base class handle_input ().
  virtual int handle_input (ACE_HANDLE fd);

  /// Calls the base class handle_qos ().
  virtual int handle_qos (ACE_HANDLE fd);

  /// This method registers the QoS Event Handler with the Reactor
  /// to receive RAPI events.
  int init (void);

private:

  /// Requests on the class are forwarded to this base class;
  ACE_QoS_Decorator_Base *decorator_base_;

  /// Handles the QoS events and in that sense decorates the usual
  /// ACE_Event_Handler.
  ACE_QoS_Event_Handler *qos_event_handler_;

  /// Passed to the ACE_QoS_Event_Handler for retrieving the RAPI
  /// session specific information like rapi_fd.
  ACE_QoS_Session *qos_session_;

  /// If the application wants to use an instance of Reactor other
  /// than the Singleton one.
  ACE_Reactor *reactor_;

};

#include "ace/post.h"
#endif  /* QOS_DECORATOR_H */