summaryrefslogtreecommitdiff
path: root/TAO/tao/Request_Mux_Strategy.h
blob: 900f63a300e4167083cef67fc4bb6d803a639c79 (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
// $Id$

// ============================================================================
//
// = LIBRARY
//     TAO
//
// = FILENAME
//     Request_Mux_Strategy.h
//
// = DESCRIPTION
//     IIOP Request Mux Strategies.
//
// = AUTHOR
//     Alexander Babu Arulanthu <alex@cs.wustl.edu>
//
// ============================================================================

#ifndef TAO_REQUEST_MUX_STRATEGY_H
#define TAO_REQUEST_MUX_STRATEGY_H

#include "tao/CDR.h"

// Forward declarations.

class TAO_Reply_Dispatcher;


class TAO_Export TAO_Request_Mux_Strategy
{
  // = TITLE
  //
  //     Strategy to determine whether the connection should be
  //     multiplexed for multiple requests or it is exclusive for a
  //     single request at a time.
  //
  // = DESCRIPTION
  //

public:
  TAO_Request_Mux_Strategy (void);
  // Base class constructor.

  virtual ~TAO_Request_Mux_Strategy (void);
  // Base class destructor.

  virtual CORBA::ULong request_id (void)  = 0;
  // Generate and return an unique request id for the current
  // invocation.

  // = Bind and Find methods for the <Request ID, ReplyDispatcher>
  //   pairs. The ReplyDispatcher is not the CORBA ReplyDispatcher of
  //   the AMI's.

  virtual int bind_dispatcher (CORBA::ULong request_id,
                               TAO_Reply_Dispatcher *rh) = 0;
  // Bind the dispatcher with the request id.

  virtual TAO_Reply_Dispatcher* find_dispatcher (CORBA::ULong request_id) = 0;
  // Find the Reply Dispatcher.

  // = "Factory methods" to obtain the CDR stream, in the Muxed case
  //    the factory simply allocates a new one, in the Exclusive case
  //    the factory returns a pointer to the pre-allocated CDR.

  virtual void set_cdr_stream (TAO_InputCDR *cdr) = 0;
  // Set the CDR stream.

  virtual TAO_InputCDR *get_cdr_stream (void);
  // Get the CDR stream.

  virtual void destroy_cdr_stream (TAO_InputCDR *) = 0;
  // Destroy the CDR stream.

protected:
  TAO_InputCDR *cdr_;
  // Pointer to the CDR stream used to read the incoming message. This
  // is obtained from the Invocation object. This is preallocated in
  // the SMI and dynamically allocated in AMI.
};

class TAO_Export TAO_Muxed_RMS : public  TAO_Request_Mux_Strategy
{
  // = TITLE
  //
  //    Connection is multiplexed for many requests.
  //
  // = DESCRIPTION
  //

public:
  TAO_Muxed_RMS (void);
  // Constructor.

  virtual ~TAO_Muxed_RMS (void);
  // Destructor.

  virtual CORBA::ULong request_id (void);
  // Generate and return an unique request id for the current
  // invocation.

  virtual int bind_dispatcher (CORBA::ULong request_id,
                               TAO_Reply_Dispatcher *rh);
  // Bind the dispatcher with the request id.

  virtual TAO_Reply_Dispatcher* find_dispatcher (CORBA::ULong request_id);
  // Find the Reply Dispatcher.

  // virtual TAO_InputCDR *cdr_stream (void);
  // Create a new CDR stream and return.

  virtual void set_cdr_stream (TAO_InputCDR *cdr);
  // Set the CDR stream.

  // virtual TAO_InputCDR *cdr_stream (void);
  // Get the CDR stream.

  virtual void destroy_cdr_stream (TAO_InputCDR *);
  // Delete the cdr stream.

protected:
  // @@ HASH TABLE???
};

class TAO_Export TAO_Exclusive_RMS : public TAO_Request_Mux_Strategy
{
  // = TITLE
  //
  //    Connection exclusive for the request.
  //
  // = DESCRIPTION
  //

public:
  TAO_Exclusive_RMS (void);
  // Constructor.

  virtual ~TAO_Exclusive_RMS (void);
  // Destructor.

  virtual CORBA::ULong request_id (void);
  // Generate and return an unique request id for the current
  // invocation. We can actually return a predecided ULong, since we
  // allow only one invocation over this connection at a time.

  virtual int bind_dispatcher (CORBA::ULong request_id,
                               TAO_Reply_Dispatcher *rh);
  // Bind the dispatcher with the request id.

  virtual TAO_Reply_Dispatcher* find_dispatcher (CORBA::ULong request_id);
  // Find the Reply Dispatcher.

  // virtual TAO_InputCDR *get_cdr_stream (void);
  // Return the preallocated CDR stream.

  virtual void set_cdr_stream (TAO_InputCDR *cdr);
  // Set the CDR stream.

  // virtual TAO_InputCDR *cdr_stream (void);
  // Get the CDR stream.

  virtual void destroy_cdr_stream (TAO_InputCDR *);
  // NO-OP function.

protected:
  CORBA::ULong request_id_generator_;
  // Used to generate a different request_id on each call to
  // request_id()

  CORBA::ULong request_id_;
  // Request id for the current request.

  TAO_Reply_Dispatcher *rd_;
  // Reply Dispatcher corresponding to the request.
};

#endif /* REQUEST_MUX_STRATEGY_H */