Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / Invocation_Base.h
blobc44772a678d60831923ef87a3b609952bad955d1
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Invocation_Base.h
7 * @author Balachandran Natarajan <bala@dre.vanderbilt.edu>
8 */
9 //=============================================================================
11 #ifndef TAO_INVOCATION_BASE_H
12 #define TAO_INVOCATION_BASE_H
14 #include /**/ "ace/pre.h"
16 #include "tao/Object.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "tao/Invocation_Utils.h"
23 #include "tao/GIOPC.h"
25 #if TAO_HAS_INTERCEPTORS == 1
26 #include "tao/Exception.h"
27 #include "tao/PI_ForwardC.h"
28 #include "tao/ClientRequestInterceptor_Adapter.h"
29 #include "tao/ServerRequestInterceptor_Adapter.h"
30 #endif /* TAO_HAS_INTERCEPTORS == 1 */
32 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
34 class TAO_Service_Context;
35 class TAO_Operation_Details;
36 class TAO_Stub;
38 namespace TAO
40 class Invocation_Adapter;
42 /**
43 * @class Invocation_Base
45 * @brief The base class for the invocation object
47 * This class is the base of the invocation object hierarchy. This
48 * hierarchy is classified based on the type of invocation and the
49 * mode of invocation. One of the objects from the hierarchy is
50 * created on the stack for every invocation.
52 * In addition this class encapsulates the essential details that
53 * are required for PortableInterceptors to function
54 * correctly. Further this class also provides some helper and
55 * accessor methods that are used by clients.
57 class TAO_Export Invocation_Base
59 public:
60 virtual ~Invocation_Base ();
62 /// Accessor and mutator methods
63 //@{
64 TAO_Stub *stub () const;
66 /// Accessor and mutator methods for forwarded object
67 /// locations.
68 /**
69 * These access methods have to be public so that the
70 * PortableInterceptor can use them
72 CORBA::Object_ptr forwarded_reference ();
73 void forwarded_reference (CORBA::Object_ptr o);
75 /// Accessors for the service context list.
76 /**
77 * The service context lists are actually cached
78 * elsewhere. Providing this accessor helps the PI to access this
79 * list in both remote and collocated mode.
81 TAO_Service_Context &request_service_context ();
82 TAO_Service_Context &reply_service_context ();
84 /// Return the forwarded object location by loosing ownership.
85 CORBA::Object_ptr steal_forwarded_reference ();
87 /// Return the effective target of the invocation.
88 /**
89 * Please see the PortableInterceptor specification in the CORBA
90 * spec to understand what effective target means.
92 CORBA::Object_ptr effective_target () const;
94 /// Return the target object
95 CORBA::Object_ptr target () const;
97 /// Does this invocation return a response?
98 CORBA::Boolean response_expected () const;
100 /// Accessor of reply_status of the invocation.
101 GIOP::ReplyStatusType reply_status () const;
103 /// Mutator of reply_status of the invocation.
104 void reply_status (GIOP::ReplyStatusType s);
106 /// The operaton details of the invocation
107 TAO_Operation_Details &operation_details ();
108 //@}
110 protected:
112 * @param otarget The original target on which this invocation
113 * was started.
115 * @param target the target on which this invocation is flowing
116 * ie. the effective target
118 * @param op operation details of the invocation on @a target
120 * @param response_expected flag to indicate whether the
121 * operation encapsulated by @a op returns a response or not.
123 Invocation_Base (CORBA::Object_ptr otarget,
124 CORBA::Object_ptr target,
125 TAO_Stub *stub,
126 TAO_Operation_Details &op,
127 bool response_expected,
128 bool request_is_remote);
130 protected:
131 /// The operation details on which we are operating on.
132 TAO_Operation_Details &details_;
134 /// Forwarded object reference.
135 CORBA::Object_var forwarded_to_;
137 /// Is response expected?
138 bool response_expected_;
140 /// A GIOP reply status of the invocation.
141 GIOP::ReplyStatusType reply_status_;
143 private:
144 Invocation_Base (const Invocation_Base&);
145 Invocation_Base & operator= (const Invocation_Base &);
147 private:
148 //@{
150 * The following object reference pointers are *not*
151 * duplicated. They are cached for portable interceptors, and they
152 * just live for the lifetime of the request. Hence there is no
153 * point in duplicating the pointers.
155 /// The original target on which the invocation was started.
156 CORBA::Object_ptr otarget_;
158 /// The effective target on which the invocation is on.
159 CORBA::Object_ptr target_;
160 //@}
162 TAO_Stub *stub_;
164 /// Operations invoked by the
165 /// PortableInterceptor::ClientRequestInfo object to get details
166 /// about the operation and related stuff.
167 //@{
168 #if TAO_HAS_INTERCEPTORS == 1
169 public:
170 /// Return a reference to the number of interceptors pushed on to
171 /// the current interceptor flow stack.
173 * @note It is a reference since the Portable Interceptor flow stack
174 * code must be able to modify this value and use that value
175 * at a later time without being forced to use TSS.
177 size_t &stack_size ();
179 CORBA::Exception *caught_exception ();
181 /// Change the exception status.
182 void exception (CORBA::Exception *exception);
184 /// Invocation status.
185 TAO::Invocation_Status invoke_status () const;
186 /// Mutator to set the invocation status.
187 void invoke_status (Invocation_Status s);
189 PortableInterceptor::ReplyStatus pi_reply_status () const;
191 /// Accessor used to determine if the current invocation is part
192 /// of a remote request, and if not, it will be considered to be
193 /// part of a collocated request.
194 bool is_remote_request() const;
196 protected:
197 /// Helper method to invoke send_request interception call to all
198 /// the registered interceptors.
199 Invocation_Status send_request_interception ();
201 /// Helper method to invoke receive_reply interception call to all
202 /// the registered interceptors.
203 Invocation_Status receive_reply_interception ();
205 /// Helper method to invoke receive_other interception call to all
206 /// the registered interceptors.
207 Invocation_Status receive_other_interception ();
209 /// Helper methods to handle interception calls when exceptions
210 /// are thrown by the PortableInterceptor.
211 PortableInterceptor::ReplyStatus
212 handle_any_exception (CORBA::Exception * e);
214 PortableInterceptor::ReplyStatus handle_all_exception ();
216 protected:
217 /// The client requestor adapter
218 ClientRequestInterceptor_Adapter *cri_adapter_;
219 ServerRequestInterceptor_Adapter *sri_adapter_;
221 size_t stack_size_;
223 TAO::Invocation_Status invoke_status_;
225 private:
226 /// Pointer to the caught exception.
227 CORBA::Exception *caught_exception_;
229 /// Flag used to distinguish a remote invocation versus a collocated
230 /// (thru-poa) invocation.
231 bool const is_remote_request_;
232 #endif /*TAO_HAS_INTERCEPTORS*/
233 //@}
237 TAO_END_VERSIONED_NAMESPACE_DECL
239 #if defined (__ACE_INLINE__)
240 # include "tao/Invocation_Base.inl"
241 #endif /* __ACE_INLINE__ */
243 #include /**/ "ace/post.h"
245 #endif /*TAO_INVOCATION_BASE_H*/