summaryrefslogtreecommitdiff
path: root/TAO/tao/Invocation.h
blob: 74eefd8ab4ec832e884c3f2a3ea147dcb8161d69 (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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// This may look like C, but it's really -*- C++ -*-
// $Id$

// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    Invocation.h
//
// = DESCRIPTION
//   Encapsulate the logic for remote invocations, oneways or twoways.
//
//   THREADING NOTE: Threads should never manipulate another
//   thread's invocations.  In this implementation, all data
//   structures used to represent invocations (and parts of them)
//   are owned by the thread which created them.  Multiple threads
//   may make of course concurrent invocations safely, since the
//   GIOP code is reentrant.
//
// = AUTHOR
//   Carlos O'Ryan <coryan@cs.wustl.edu>
//
// ============================================================================

#if !defined (TAO_INVOCATION_H)
#  define TAO_INVOCATION_H

#include "tao/CDR.h"

class TAO_Export TAO_GIOP_Invocation
{
  // = TITLE
  //   Encapsulates common behavior for both oneway and twoway
  //   invocations.
  //
  // = DESCRIPTION
  //   This class connects (or lookups a connection from the cache) to
  //   the remote server, builds the CDR stream for the Request, send
  //   the CDR stream and expects the response and interprets the
  //   incoming CDR stream.
  //
public:
  // = Initialization and termination methods.
  TAO_GIOP_Invocation (IIOP_Object *data,
		       const char *operation,
		       TAO_ORB_Core* orb_core);
  ~TAO_GIOP_Invocation (void);

  void put_param (CORBA::TypeCode_ptr tc,
                  void *value,
                  CORBA::Environment &env);
  // Encodes the value into the undelying CDR stream based on the
  // TypeCode parameter

  TAO_OutputCDR &out_stream (void);
  // return the underlying output stream

protected:
  void start (CORBA::Boolean is_roundtrip,
              TAO_GIOP::Message_Type message_type,
	      CORBA::Environment &env);
  // Locates the right Client_Connection_Handler and initializes the
  // CDR stream.
  // The message_type tells how to initialize the output CDR stream

  TAO_GIOP_ReplyStatusType invoke (CORBA::Boolean is_roundtrip,
				   CORBA::Environment &env);
  // Sends the request, does not wait for the response.

  TAO_GIOP_ReplyStatusType close_connection (void);
  // resets the forwarding profile and behaves like
  // we are fowarded (to the same server)

  TAO_GIOP_ReplyStatusType location_forward (TAO_InputCDR &inp_stream,
                                             CORBA::Environment &env);
  // do the location forwarding, which means exchanging the profile

protected:
  IIOP_Object *data_;
  // The object on which this invocation is going.

  const char *opname_;
  // Name of the operation being invoked.

  CORBA::ULong my_request_id_;
  // Request ID of this operation.

  char buffer [CDR::DEFAULT_BUFSIZE];
  // Buffer used for both the output and input CDR streams, this is
  // "safe" because we only one of the streams at a time.

  TAO_OutputCDR out_stream_;
  // Stream into which the response is placed.

  TAO_ORB_Core* orb_core_;
  // The orb_core context where we make this invocation.
};

class TAO_Export TAO_GIOP_Twoway_Invocation : public TAO_GIOP_Invocation
{
  // = TITLE
  //   Sends a two-way request, and expects the reply.
  //
  // = DESCRIPTION
  //   This class connects (or lookups a connection from the cache) to
  //   the remote server, builds the CDR stream for the Request, send
  //   the CDR stream and expects the response and interprets the
  //   incoming CDR stream.
  //
public:
  // = Initialization and termination methods.
  TAO_GIOP_Twoway_Invocation (IIOP_Object *data,
			      const char *operation,
			      TAO_ORB_Core* orb_core);

  void start (CORBA::Environment &env);
  // Calls TAO_GIOP_Invocation::start.

  TAO_GIOP_ReplyStatusType invoke (CORBA::ExceptionList &exceptions,
                                   CORBA::Environment &env);
  // Send request, block until any reply comes back, and unmarshal
  // reply parameters as appropriate.

  TAO_GIOP_ReplyStatusType invoke (TAO_Exception_Data *excepts,
                                   CORBA::ULong except_count,
                                   CORBA::Environment &env);
  // Special purpose invoke method used by the stubs. This
  // accomplishes the same task as the normal invoke except that
  // Exceptions are allocated and decoded here. This keeps the size of
  // the stubs small and abstracts all the common code here.

  void get_value (CORBA::TypeCode_ptr tc,
                  void *value,
                  CORBA::Environment &env);
  // No CORBA::Context support (deprecated).

  TAO_InputCDR &inp_stream (void);
  // return the underlying input stream

private:
  TAO_InputCDR inp_stream_;
  // Stream into which the request is placed.
};

class TAO_Export TAO_GIOP_Oneway_Invocation : public TAO_GIOP_Invocation
{
  // = TITLE
  //   Sends a oneway request.
  //
public:
  // = Initialization and termination methods.
  TAO_GIOP_Oneway_Invocation (IIOP_Object *data,
			      const char *operation,
			      TAO_ORB_Core* orb_core);

  void start (CORBA::Environment &env);
  // Call TAO_GIOP_Invocation::start()

  TAO_GIOP_ReplyStatusType invoke (CORBA::Environment &env);
  // Send request, without blocking for any response.
};


class TAO_Export TAO_GIOP_Locate_Request_Invocation : public TAO_GIOP_Invocation
{
  // = TITLE
  //   Sends a locate request.
  //
public:
  // = Initialization and termination methods.
  TAO_GIOP_Locate_Request_Invocation (IIOP_Object *data,
				      TAO_ORB_Core* orb_core);

  void start (CORBA::Environment &env);
  // Calls TAO_GIOP_Invocation::start.

  TAO_GIOP_ReplyStatusType invoke (CORBA::Environment &env);
  // Send request, without blocking for any response.

private:
  TAO_InputCDR inp_stream_;
  // Stream into which the request is placed.
};


#if defined (__ACE_INLINE__)
# include "tao/Invocation.i"
#endif /* __ACE_INLINE__ */

#endif /* TAO_INVOCATION_H */