3 //=============================================================================
7 * Header file for CORBA's Dynamic Invocation Interface "Request"
10 * @author Copyright 1994-1995 by Sun Microsystems, Inc.
11 * @author Additions and RequestSeq by Jeff Parsons <parsons@cs.wustl.edu>
13 //=============================================================================
18 #include /**/ "ace/pre.h"
20 #include "tao/orbconf.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 // To force execution of the static constructor
27 // that registers the dynamic service object.
28 #include "tao/DynamicInterface/Dynamic_Adapter_Impl.h"
30 #include "tao/DynamicInterface/ExceptionList.h"
33 #include "tao/Environment.h"
35 #include "tao/GIOPC.h"
36 #include "tao/AnyTypeCode/NVList.h"
38 #if defined (TAO_HAS_AMI)
39 #include "tao/Messaging/Messaging.h"
40 #endif /* TAO_HAS_AMI */
42 #include "ace/SString.h"
45 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
50 typedef NVList
*NVList_ptr
;
53 typedef Context
*Context_ptr
;
56 typedef ContextList
*ContextList_ptr
;
61 * @brief CORBA::Request
63 * Provides a way to create requests and populate it with parameters
64 * for use in the Dynamic Invocation Interface.
66 class TAO_DynamicInterface_Export Request
69 /// Return the target of this request.
70 CORBA::Object_ptr
target () const;
72 /// Return the operation name for the request.
73 const CORBA::Char
*operation () const;
75 /// Return the arguments for the request.
76 CORBA::NVList_ptr
arguments ();
78 /// Return the result for the request.
79 CORBA::NamedValue_ptr
result ();
81 /// Return the exceptions resulting from this request.
82 CORBA::ExceptionList_ptr
exceptions ();
84 /// Accessor for the Context member.
85 CORBA::Context_ptr
ctx () const;
87 /// Mutator for the Context member.
88 void ctx (CORBA::Context_ptr
);
90 /// Return a list of the request's result's contexts. Since TAO
91 /// does not implement Contexts, this will always be 0.
92 CORBA::ContextList_ptr
contexts ();
95 * @name Argument manipulation helper functions.
97 * Arg adders, one for each type of parameter, with and without
98 * optional name. Returns reference to Any for insertion using
102 CORBA::Any
&add_in_arg ();
103 CORBA::Any
&add_in_arg (const char* name
);
104 CORBA::Any
&add_inout_arg ();
105 CORBA::Any
&add_inout_arg (const char* name
);
106 CORBA::Any
&add_out_arg ();
107 CORBA::Any
&add_out_arg (const char* name
);
110 /// Initialize the return type.
111 void set_return_type (CORBA::TypeCode_ptr tc
);
113 /// Returns reference to Any for extraction using >>=.
114 CORBA::Any
&return_value ();
116 /// Perform method resolution and invoke an appropriate method.
118 * If the method returns successfully, its result is placed in
119 * the result argument specified on @c create_request. The behavior
120 * is undefined if this @c Request has already been used with a
121 * previous call to @c invoke, @c send, or
122 * @c send_multiple_requests.
124 * @note A default argument is set, but please note that this not
125 * recommended as the user may not be able to propagate the
130 /// Send a oneway request.
132 * @note A default argument is set, but please note that this not
133 * recommended as the user may not be able to propagate the
139 * @name The 'deferred synchronous' methods.
141 * The 'deferred synchronous' methods.
144 void send_deferred ();
145 void get_response ();
146 CORBA::Boolean
poll_response ();
149 /// Callback method for deferred synchronous requests.
150 void handle_response (TAO_InputCDR
&incoming
, GIOP::ReplyStatusType reply_status
);
152 #if defined (TAO_HAS_AMI)
153 /// The 'asynchronous' send method. The object is a DSI based callback
154 /// handler. This handler must implement Messaging::ReplyHandler
155 void sendc (CORBA::Object_ptr handler
);
157 static void _tao_reply_stub (
158 TAO_InputCDR
&_tao_reply_cdr
,
159 Messaging::ReplyHandler_ptr _tao_reply_handler
,
160 CORBA::ULong reply_status
);
161 #endif /* TAO_HAS_AMI */
163 /// Pseudo object methods.
164 static CORBA::Request
* _duplicate (CORBA::Request
*);
165 static CORBA::Request
* _nil ();
167 // = Reference counting.
168 CORBA::ULong
_incr_refcount ();
169 CORBA::ULong
_decr_refcount ();
171 /// Set the lazy evaluation flag.
172 void _tao_lazy_evaluation (bool lazy_evaluation
);
174 /// Get the byte order member.
175 int _tao_byte_order () const;
177 /// Set the byte order member.
178 void _tao_byte_order (int byte_order
);
180 /// Hold on to a user exception in case we are part of a TAO
182 void raw_user_exception (TAO_InputCDR
&cdr
);
184 /// Accessor for the input stream containing the exception.
185 ACE_CString
&raw_user_exception ();
187 /// Proprietary method to check whether a response has been
189 CORBA::Boolean
response_received ();
191 // Useful for template programming.
192 typedef CORBA::Request_ptr _ptr_type
;
193 typedef CORBA::Request_var _var_type
;
194 typedef CORBA::Request_out _out_type
;
197 friend class ::TAO_Dynamic_Adapter_Impl
;
199 // The following are not allowed except when called from the
201 Request (CORBA::Object_ptr obj
,
203 const CORBA::Char
*op
,
204 CORBA::NVList_ptr args
,
205 CORBA::NamedValue_ptr result
,
207 CORBA::ExceptionList_ptr exceptions
);
209 Request (CORBA::Object_ptr obj
,
211 const CORBA::Char
*op
);
217 CORBA::Object_ptr target_
;
219 /// Pointer to our ORB.
223 const char * opname_
;
226 CORBA::NVList_ptr args_
;
228 /// Result of the operation.
229 CORBA::NamedValue_ptr result_
;
231 /// Invocation flags.
234 /// @deprecated Holds exceptions.
235 // CORBA::Environment env_;
237 /// List of exceptions raised by the operation.
238 CORBA::ExceptionList_var exceptions_
;
240 /// List of the request's result's contexts.
241 CORBA::ContextList_ptr contexts_
;
243 /// Context associated with this request.
244 CORBA::Context_ptr ctx_
;
246 /// Reference counting.
247 std::atomic
<uint32_t> refcount_
;
249 /// Protect the response_received_.
250 TAO_SYNCH_MUTEX lock_
;
252 /// If not zero then the NVList is not evaluated by default.
253 bool lazy_evaluation_
;
255 /// Set to true upon completion of invoke() or handle_response().
256 CORBA::Boolean response_received_
;
258 /// Can be reset by a gateway when passing along a request.
261 /// Stores user exception as a CDR stream when this request is
262 /// used in a TAO gateway.
263 ACE_CString raw_user_exception_
;
265 } // End CORBA namespace.
267 TAO_END_VERSIONED_NAMESPACE_DECL
269 #if defined (__ACE_INLINE__)
270 # include "tao/DynamicInterface/Request.inl"
271 #endif /* __ACE_INLINE__ */
273 #include /**/ "ace/post.h"
275 #endif /* TAO_REQUEST_H */