Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Invocation_Adapter.h
blob244383701e6a92957dec65ab9e4ae30aafd70197
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Invocation_Adapter.h
7 * @author Balachandran Natarajan <bala@dre.vanderbilt.edu>
8 */
9 //=============================================================================
10 #ifndef TAO_INVOCATION_ADAPTER_H
11 #define TAO_INVOCATION_ADAPTER_H
13 #include /**/ "ace/pre.h"
15 #include "ace/Global_Macros.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include /**/ "tao/TAO_Export.h"
22 #include "tao/Invocation_Utils.h"
23 #include "tao/Collocation_Strategy.h"
24 #include "tao/CORBA_methods.h"
25 #include "tao/Pseudo_VarOut_T.h"
27 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 class ACE_Time_Value;
29 ACE_END_VERSIONED_NAMESPACE_DECL
31 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
33 class TAO_Operation_Details;
34 class TAO_Stub;
36 namespace CORBA
38 class Object;
39 typedef Object *Object_ptr;
40 typedef TAO_Pseudo_Var_T<Object> Object_var;
43 namespace TAO
45 class Argument;
46 struct Exception_Data;
47 class Profile_Transport_Resolver;
48 class Invocation_Retry_State;
50 /**
51 * @class Invocation_Adapter
53 * @brief Generic interface for the invocation object visible to the
54 * IDL compiler.
56 * The main objective of this class is to adapt the type and
57 * invocation specific information declared in the IDL by the
58 * application and convert them as CORBA invocations to the target
59 * object. Implementation of this class knows how to make
60 * invocations on a collocated or a remote object.
62 * This adapter class serves as the base class for various types of
63 * invocations like AMI, DII, DSI etc. Adapter classes for AMI, DII,
64 * DSI inherit from this class and their local behavioral
65 * information before kicking off an invocation.
67 * @@ More info..
68 * Wafer thin inclusions
69 * All stuff created on stack
70 * Only handles starts and restarts
73 class TAO_Export Invocation_Adapter
75 public:
76 /// The only constructor used by the IDL compiler, and only way to
77 /// create this adapter.
78 /**
79 * @param target Points to the object on which this invocation is
80 * being invoked.
82 * @param args Array of pointers to the argument list in the
83 * operation declaration. This includes the return, inout and out
84 * arguments.
86 * @param arg_number Number of arguments in the above array. This
87 * is the number of elements in the above array.
89 * @param operation The name of the operation being invoked.
91 * @param op_len Number of characters in the operation name. This
92 * is an optimization which helps us to avoid calling strlen ()
93 * while creating a message format.
95 * @param collocation_opportunity Indicate which collocation optimizations
96 * should be possible
98 * @param type The operation type which could be a oneway or two
99 * way operation. This information is available in the IDL file.
101 * @param mode Invocation mode. This information is also available
102 * in the IDL file and in the generated code.
104 Invocation_Adapter (CORBA::Object_ptr target,
105 Argument **args,
106 int arg_number,
107 const char *operation,
108 size_t op_len,
109 int collocation_opportunity,
110 TAO::Invocation_Type type = TAO_TWOWAY_INVOCATION,
111 TAO::Invocation_Mode mode = TAO_SYNCHRONOUS_INVOCATION,
112 bool has_in_args = true);
114 virtual ~Invocation_Adapter ();
116 /// Invoke the target, and used by the generated code.
118 * The implementation decides whether the target is remote or
119 * collocated and takes the right decision.
121 * @param ex Array of exception data declared by the application
122 * in their IDL.
124 * @param ex_count Number of elements in the array.
126 virtual void invoke (const TAO::Exception_Data *ex, unsigned long ex_count);
129 * @param byte_order The intended byte order for the message output
130 * stream. For use in message gateways that forward messages from
131 * sources with different byte order than the native order.
133 void _tao_byte_order (int byte_order);
136 * Get the intended byte order for the message output stream.
137 * In case of gateway messages this could divert from the native
138 * byte order.
140 int _tao_byte_order ();
142 protected:
144 * The stub pointer passed to this call has all the details about
145 * the object to which the invocation needs to be routed to. The
146 * implementation of this method looks if we are collocated or not
147 * and takes care of reinvoking the target if it receives
148 * forwarding information or if the first invocation fails
149 * for some reason, like a loss of connection during send () etc.
151 virtual void invoke_i (TAO_Stub *stub, TAO_Operation_Details &details);
154 * @name Helper methods for making different types of invocations.
156 * These methods useful for various types of invocations like
157 * SII, AMI, DII and DSI. All the subclasses implement these
158 * methods to get the right behavior at their level.
160 //@{
161 /// Helper method that prepares the necessary stuff for a remote
162 /// invocation.
165 * This method does the following essential activities needed for
166 * a remote invocation.
168 * - Extracts the roundtrip timeout policies set in the ORB or
169 * Object or at the thread level
170 * - Uses the target information to pick a profile and a transport
171 * object on which the invocation needs to be sent
173 * - Checks whether the operation is a oneway or twoway and
174 * delegates the call.
176 virtual Invocation_Status invoke_remote_i (
177 TAO_Stub *stub,
178 TAO_Operation_Details &details,
179 CORBA::Object_var &effective_target,
180 ACE_Time_Value *&max_wait_time,
181 Invocation_Retry_State *retry_state = 0);
183 /// Make a collocated call.
185 * This method creates an object that takes care of making collocated
186 * invocations and calls invoke () on it. If the invoke ()
187 * returns with a location forwarded reply we return a restart
189 * @param stub The stub object on which the invocation is made.
191 * @param details The operations details of the operation that is being
192 * invoked.
194 virtual Invocation_Status invoke_collocated_i (
195 TAO_Stub *stub,
196 TAO_Operation_Details &details,
197 CORBA::Object_var &effective_target,
198 Collocation_Strategy strat);
200 /// Helper method to make a two way invocation.
202 * This method creates a synchronous twoway invocation object to
203 * which the actual task of request handling is delegated. Once
204 * the invocation returns this method checks whether the request
205 * is forwarded to a new location.
207 virtual Invocation_Status invoke_twoway (
208 TAO_Operation_Details &details,
209 CORBA::Object_var &effective_target,
210 Profile_Transport_Resolver &r,
211 ACE_Time_Value *&max_wait_time,
212 Invocation_Retry_State *retry_state = 0);
214 /// Helper method to make a one way invocation.
216 * This method creates a synchronous oneway invocation object to
217 * which the actual task of request handling is delegated. Once
218 * the invocation returns this method checks whether the request
219 * is forwarded to a new location to take appropriate action.
221 virtual Invocation_Status invoke_oneway (
222 TAO_Operation_Details &details,
223 CORBA::Object_var &effective_target,
224 Profile_Transport_Resolver &r,
225 ACE_Time_Value *&max_wait_time);
226 //@}
228 /// Helper function that extracts the roundtrip timeout policies
229 /// set in the ORB.
230 bool get_timeout (TAO_Stub *stub, ACE_Time_Value &val);
232 /// Helper method that extracts TAO_Stub from the target object.
233 TAO_Stub *get_stub () const;
235 /// Helper method that takes care of setting the profiles within
236 /// the stub object if the target gets forwarded
237 void object_forwarded (CORBA::Object_var &effective_target,
238 TAO_Stub *stub,
239 CORBA::Boolean permanent_forward);
241 /// Helper method to set the response flags within @a details
242 void set_response_flags (TAO_Stub *stub,
243 TAO_Operation_Details &details);
245 private:
246 Invocation_Adapter () = delete;
247 Invocation_Adapter (Invocation_Adapter const &) = delete;
248 Invocation_Adapter & operator= (const Invocation_Adapter &) = delete;
251 * This method returns the right collocation strategy, if any,
252 * to be used to perform a method invocation on the given object.
254 * @note
255 * No-Collocation is a special case of collocation.
257 TAO::Collocation_Strategy collocation_strategy (CORBA::Object_ptr object);
258 //@}
260 protected:
261 /// The target object on which this invocation is carried out.
262 CORBA::Object_ptr target_;
264 /// Array of arguments for this operation
265 Argument ** const args_;
267 /// Number of arguments for this operation.
269 * This includes the return values too
271 int const number_args_;
273 bool has_in_args_;
275 /// Name of the operation.
276 char const * operation_;
278 /// String length of the operation name.
279 size_t const op_len_;
281 /// Collocation opportunity for this operation.
282 int const collocation_opportunity_;
284 /// The invocation type
285 Invocation_Type const type_;
287 /// The invocation mode
288 Invocation_Mode const mode_;
290 /// Intended byte order for message output stream
291 int byte_order_;
293 } // End namespace TAO
295 TAO_END_VERSIONED_NAMESPACE_DECL
297 #if defined (__ACE_INLINE__)
298 # include "tao/Invocation_Adapter.inl"
299 #endif /* __ACE_INLINE__ */
301 #include /**/ "ace/post.h"
303 #endif /*TAO_INVOCATION_ADAPTER_H*/