Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / DynamicInterface / AMH_DSI_Response_Handler.h
blob90a63d9de1587d708915d0f71be36ec09939c326
1 // -*- C++ -*-
3 //=====================================================================
4 /**
5 * @file AMH_DSI_Response_Handler.h
7 * @brief Handle the Response appropriately.
8 */
9 //=====================================================================
11 #ifndef TAO_AMH_DSI_RESPONSE_HANDLER_H
12 #define TAO_AMH_DSI_RESPONSE_HANDLER_H
13 #include /**/ "ace/pre.h"
15 #include "tao/orbconf.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "tao/LocalObject.h"
22 #include "tao/PortableServer/PortableServer.h"
23 #include "tao/Messaging/AMH_Response_Handler.h"
24 #include "tao/Valuetype/ValueBase.h"
25 #include "dynamicinterface_export.h"
27 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
29 class TAO_AMH_DSI_Response_Handler;
30 typedef TAO_AMH_DSI_Response_Handler *TAO_AMH_DSI_Response_Handler_ptr;
32 /**
33 * @class TAO_AMH_DSI_Response_Handler_var
35 * @brief The T_var class for response handler
37 * As any other pseudo object, this class has a T_var class too.
39 class TAO_DynamicInterface_Export TAO_AMH_DSI_Response_Handler_var
41 public:
42 TAO_AMH_DSI_Response_Handler_var ();
43 TAO_AMH_DSI_Response_Handler_var (TAO_AMH_DSI_Response_Handler_ptr);
44 TAO_AMH_DSI_Response_Handler_var (
45 const TAO_AMH_DSI_Response_Handler_var &);
46 ~TAO_AMH_DSI_Response_Handler_var ();
48 TAO_AMH_DSI_Response_Handler_var &operator= (
49 TAO_AMH_DSI_Response_Handler_ptr);
50 TAO_AMH_DSI_Response_Handler_var &operator= (
51 const TAO_AMH_DSI_Response_Handler_var &);
52 TAO_AMH_DSI_Response_Handler_ptr operator-> () const;
54 operator const TAO_AMH_DSI_Response_Handler_ptr &() const;
55 operator TAO_AMH_DSI_Response_Handler_ptr &();
57 TAO_AMH_DSI_Response_Handler_ptr in () const;
58 TAO_AMH_DSI_Response_Handler_ptr &inout ();
59 TAO_AMH_DSI_Response_Handler_ptr &out ();
60 TAO_AMH_DSI_Response_Handler_ptr _retn ();
61 TAO_AMH_DSI_Response_Handler_ptr ptr () const;
63 private:
64 TAO_AMH_DSI_Response_Handler_ptr ptr_;
67 class TAO_AMH_DSI_Exception_Holder;
68 typedef TAO_AMH_DSI_Exception_Holder *TAO_AMH_DSI_Exception_Holder_ptr;
70 /**
71 * @class TAO_AMH_DSI_Exception_Holder_var
73 * @brief The T_var class for exception holder
75 * As any other pseudo object, this class has a T_var class too.
77 class TAO_DynamicInterface_Export TAO_AMH_DSI_Exception_Holder_var
79 public:
80 TAO_AMH_DSI_Exception_Holder_var ();
81 TAO_AMH_DSI_Exception_Holder_var (TAO_AMH_DSI_Exception_Holder*);
82 TAO_AMH_DSI_Exception_Holder_var (const TAO_AMH_DSI_Exception_Holder*);
83 TAO_AMH_DSI_Exception_Holder_var (const TAO_AMH_DSI_Exception_Holder_var &);
84 ~TAO_AMH_DSI_Exception_Holder_var ();
86 TAO_AMH_DSI_Exception_Holder_var &operator= (TAO_AMH_DSI_Exception_Holder*);
87 TAO_AMH_DSI_Exception_Holder_var &operator= (
88 const TAO_AMH_DSI_Exception_Holder_var &);
89 TAO_AMH_DSI_Exception_Holder* operator-> () const;
91 operator const TAO_AMH_DSI_Exception_Holder* () const;
92 operator TAO_AMH_DSI_Exception_Holder*& ();
94 TAO_AMH_DSI_Exception_Holder* in () const;
95 TAO_AMH_DSI_Exception_Holder*& inout ();
96 TAO_AMH_DSI_Exception_Holder*& out ();
97 TAO_AMH_DSI_Exception_Holder* _retn ();
98 TAO_AMH_DSI_Exception_Holder* ptr () const;
100 // Hooks used by template sequence and valuetype manager classes
101 // for non-defined forward declared valuetypes.
102 static void tao_add_ref (TAO_AMH_DSI_Exception_Holder *);
103 static void tao_remove_ref (TAO_AMH_DSI_Exception_Holder *);
105 private:
106 TAO_AMH_DSI_Exception_Holder* ptr_;
110 * @class TAO_AMH_DSI_Exception_Holder_out
112 * @brief The T_out class for exception holder
114 class TAO_DynamicInterface_Export TAO_AMH_DSI_Exception_Holder_out
116 public:
117 TAO_AMH_DSI_Exception_Holder_out (TAO_AMH_DSI_Exception_Holder* &);
118 TAO_AMH_DSI_Exception_Holder_out (TAO_AMH_DSI_Exception_Holder_var &);
119 TAO_AMH_DSI_Exception_Holder_out (const TAO_AMH_DSI_Exception_Holder_out &);
120 TAO_AMH_DSI_Exception_Holder_out &operator= (
121 const TAO_AMH_DSI_Exception_Holder_out &);
122 TAO_AMH_DSI_Exception_Holder_out &operator= (
123 const TAO_AMH_DSI_Exception_Holder_var &);
124 TAO_AMH_DSI_Exception_Holder_out &operator= (
125 TAO_AMH_DSI_Exception_Holder*);
126 operator TAO_AMH_DSI_Exception_Holder*& ();
127 TAO_AMH_DSI_Exception_Holder*& ptr ();
128 TAO_AMH_DSI_Exception_Holder* operator-> ();
130 private:
131 TAO_AMH_DSI_Exception_Holder* &ptr_;
135 * @class TAO_AMH_DSI_Exception_Holder
137 * @brief This is the class for holding exception.
139 class TAO_DynamicInterface_Export TAO_AMH_DSI_Exception_Holder
140 : public virtual CORBA::DefaultValueRefCountBase,
141 public virtual CORBA::ValueBase
143 public:
144 typedef TAO_AMH_DSI_Exception_Holder_var _var_type;
145 TAO_AMH_DSI_Exception_Holder (CORBA::Exception *ex);
147 virtual ~TAO_AMH_DSI_Exception_Holder ();
148 virtual ::CORBA::ValueBase *_copy_value ();
150 static TAO_AMH_DSI_Exception_Holder* _downcast ( CORBA::ValueBase* );
152 static CORBA::Boolean _tao_unmarshal ( TAO_InputCDR &,
153 TAO_AMH_DSI_Exception_Holder *& );
154 virtual const char* _tao_obv_repository_id () const;
155 static const char* _tao_obv_static_repository_id ();
157 static void _tao_any_destructor (void *);
159 virtual void raise_invoke ( );
161 CORBA::TypeCode_ptr _tao_type () const;
162 void _tao_obv_truncatable_repo_ids (Repository_Id_List &) const;
163 CORBA::Boolean _tao_match_formal_type (ptrdiff_t ) const;
165 protected:
166 TAO_AMH_DSI_Exception_Holder ();
167 /// *** Terrible Hack ? ***
168 virtual CORBA::Boolean _tao_marshal_v (TAO_OutputCDR &) const;
169 virtual CORBA::Boolean _tao_unmarshal_v (TAO_InputCDR &);
171 private:
172 TAO_AMH_DSI_Exception_Holder (const TAO_AMH_DSI_Exception_Holder &);
173 void operator= (const TAO_AMH_DSI_Exception_Holder &);
174 CORBA::Exception *exception_;
176 protected:
177 virtual CORBA::Boolean _tao_marshal__Test_TAO_AMH_DSI_Exception_Holder (
178 TAO_OutputCDR &);
179 virtual CORBA::Boolean _tao_unmarshal__Test_TAO_AMH_DSI_Exception_Holder (
180 TAO_InputCDR &);
184 * @class TAO_AMH_DSI_Response_Handler
186 * @brief This is the main class for DSI using AMH.
188 * With ordinary DSI, the POA calls _dispatch, which in turn calls invoke
189 * on the DSI handler. Invoke completely handles the request, and packages
190 * the result in the request object so that it can be marshalled and sent
191 * back to the caller.
193 * With the AMH variation, the DSI handler's invoke method starts the
194 * processing, but delegates the result packaging to a response handler.
195 * This way, if the invocation takes a long time, or involves blocking
196 * calls, then the result handling can be managed by another thread.
197 * This is particularly useful for gateway implementations, where the
198 * middle tier should not have to block waiting for replies.
200 * As this is built on the CORBA object model, there are separate classes
201 * representing the interface and the implementation.
203 class TAO_DynamicInterface_Export TAO_AMH_DSI_Response_Handler
204 : public virtual TAO_AMH_Response_Handler
206 public:
207 typedef TAO_AMH_DSI_Response_Handler_ptr _ptr_type;
208 typedef TAO_AMH_DSI_Response_Handler_var _var_type;
210 TAO_AMH_DSI_Response_Handler (TAO_ServerRequest &sr);
211 ~TAO_AMH_DSI_Response_Handler ();
213 virtual void invoke_reply (CORBA::NVList_ptr args,
214 CORBA::NamedValue_ptr result);
216 virtual void invoke_excep ( TAO_AMH_DSI_Exception_Holder * h);
218 virtual void invoke_location_forward (CORBA::Object_ptr fwd,
219 CORBA::Boolean is_perm);
221 virtual void gateway_exception_reply (CORBA::ULong reply_status,
222 TAO_OutputCDR &encap);
224 virtual void gateway_exception_reply (CORBA::ULong reply_status,
225 TAO_InputCDR &encap);
228 * @param byte_order The intended byte order for the message output
229 * stream. For use in message gateways that forward messages from
230 * sources with different byte order than the native order.
232 void _tao_byte_order (int byte_order);
235 * Get the intended byte order for the message output stream.
236 * In case of gateway messages this could divert from the native
237 * byte order.
239 int _tao_byte_order ();
241 /// Returns a CORBA::Object_ptr for the target object.
242 CORBA::Object_ptr _this ();
244 /// CORBA Object related methods
245 static TAO_AMH_DSI_Response_Handler* _duplicate (
246 TAO_AMH_DSI_Response_Handler_ptr);
247 static TAO_AMH_DSI_Response_Handler* _nil ();
248 static TAO_AMH_DSI_Response_Handler* _narrow (CORBA::Object_ptr);
249 static TAO_AMH_DSI_Response_Handler* _unchecked_narrow (CORBA::Object_ptr);
251 protected:
252 /// Return 0. Should never be used.
253 virtual const char *_interface_repository_id () const;
255 /// Simply returns "this"
256 virtual void *_downcast (const char *repository_id);
258 private:
259 TAO_ORB_Core *orb_core_;
262 TAO_END_VERSIONED_NAMESPACE_DECL
264 #if defined (__ACE_INLINE__)
265 # include "AMH_DSI_Response_Handler.inl"
266 #endif /* __ACE_INLINE__ */
268 #include /**/ "ace/post.h"
269 #endif /* TAO_AMH_DSI_RESPONSE_HANDLER_H */