Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Collocated / Dynamic / interceptors.cpp
blobd3bc9c6d76f9c929f7614f2aa7c1f1ea9e6c2a72
1 #include "interceptors.h"
2 #include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h"
3 #include "tao/AnyTypeCode/DynamicC.h"
4 #include "tao/AnyTypeCode/TypeCode.h"
5 #include "ace/Log_Msg.h"
6 #include "ace/OS_NS_string.h"
8 const char *request_msg = "The Echo_Request_Interceptor request message";
9 const char *reply_msg = "The Echo_Request_Interceptor reply message";
10 CORBA::ULong Echo_Client_Request_Interceptor::client_interceptor_check_ = 0;
11 CORBA::ULong Echo_Server_Request_Interceptor::server_interceptor_check_ = 0;
13 Echo_Client_Request_Interceptor::Echo_Client_Request_Interceptor ()
14 : myname_ ("Echo_Client_Interceptor")
18 Echo_Client_Request_Interceptor::~Echo_Client_Request_Interceptor ()
22 char *
23 Echo_Client_Request_Interceptor::name ()
25 return CORBA::string_dup (this->myname_);
28 void
29 Echo_Client_Request_Interceptor::destroy ()
33 void
34 Echo_Client_Request_Interceptor::send_poll (
35 PortableInterceptor::ClientRequestInfo_ptr
38 // Do nothing
41 void
42 Echo_Client_Request_Interceptor::send_request (
43 PortableInterceptor::ClientRequestInfo_ptr ri)
45 client_interceptor_check_++;
47 CORBA::String_var op =
48 ri->operation ();
50 #if 0
51 ACE_DEBUG ((LM_DEBUG,
52 "Echo_Client_Request_Interceptor::send_request\n"));
54 ACE_DEBUG ((LM_DEBUG,
55 "Echo_Client_Request_Interceptor::send_request from "
56 "\"%C\"\n",
57 op.in ()));
59 #endif /*if 0*/
61 if (ACE_OS::strcmp (op.in (), "normal") == 0)
63 Dynamic::ParameterList_var paramlist =
64 ri->arguments ();
66 CORBA::Long param;
67 CORBA::ULong i = 0; // index -- explicitly used to avoid
68 // overloaded operator ambiguity.
69 paramlist[i].argument >>= param;
71 #if 0
72 ACE_DEBUG ((LM_DEBUG,
73 "The arg is %d\n",
74 param));
75 #endif /*if 0*/
79 void
80 Echo_Client_Request_Interceptor::receive_other (
81 PortableInterceptor::ClientRequestInfo_ptr ri)
83 client_interceptor_check_++;
85 CORBA::String_var op = ri->operation ();
87 #if 0
88 ACE_DEBUG ((LM_DEBUG,
89 "Echo_Client_Request_Interceptor::receive_other "
90 "from \"%C\"\n",
91 op.in ()));
92 #endif /*if 0*/
95 void
96 Echo_Client_Request_Interceptor::receive_reply (
97 PortableInterceptor::ClientRequestInfo_ptr ri)
99 client_interceptor_check_++;
101 CORBA::String_var op = ri->operation ();
103 #if 0
104 ACE_DEBUG ((LM_DEBUG,
105 "Echo_Client_Request_Interceptor::receive_reply "
106 "from \"%C\"\n",
107 op.in ()));
108 #endif /*if 0*/
110 if (ACE_OS::strcmp (op.in (), "normal") == 0)
112 Dynamic::ParameterList_var paramlist =
113 ri->arguments ();
115 CORBA::Long param;
116 CORBA::ULong i = 0; // index -- explicitly used to avoid
117 // overloaded operator ambiguity.
118 paramlist[i].argument >>= param;
120 else if (ACE_OS::strcmp (op.in (), "calculate") == 0)
122 Dynamic::ParameterList_var paramlist =
123 ri->arguments ();
125 CORBA::Long param1, param2, result;
126 CORBA::ULong i = 0; // index -- explicitly used to avoid
127 // overloaded operator ambiguity.
128 paramlist[i++].argument >>= param1;
129 paramlist[i].argument >>= param2;
131 CORBA::Any_var result_any = ri->result ();
133 (result_any.in ()) >>= result;
135 #if 0
136 ACE_DEBUG ((LM_DEBUG,
137 "The result of calculate is %d + %d = %d\n",
138 param1,
139 param2,
140 result));
141 #endif /*if 0*/
145 void
146 Echo_Client_Request_Interceptor::receive_exception (
147 PortableInterceptor::ClientRequestInfo_ptr ri)
149 client_interceptor_check_++;
151 CORBA::String_var op = ri->operation ();
153 CORBA::String_var exception_id =
154 ri->received_exception_id ();
156 ACE_DEBUG ((LM_DEBUG,
157 "Echo_Client_Request_Interceptor::received_exception "
158 "from \"%C\"\n",
159 op.in ()));
161 ACE_DEBUG ((LM_DEBUG,
162 "Exception ID = %C\n",
163 exception_id.in ()));
166 Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor ()
167 : myname_ ("Echo_Server_Interceptor")
171 Echo_Server_Request_Interceptor::~Echo_Server_Request_Interceptor ()
175 char *
176 Echo_Server_Request_Interceptor::name ()
178 return CORBA::string_dup (this->myname_);
181 void
182 Echo_Server_Request_Interceptor::destroy ()
186 void
187 Echo_Server_Request_Interceptor::receive_request_service_contexts (
188 PortableInterceptor::ServerRequestInfo_ptr)
192 void
193 Echo_Server_Request_Interceptor::receive_request (
194 PortableInterceptor::ServerRequestInfo_ptr ri)
196 ++server_interceptor_check_;
198 CORBA::String_var op = ri->operation ();
200 PortableInterceptor::ObjectId_var test_oid =
201 ri->object_id ();
203 ACE_DEBUG ((LM_DEBUG,
204 "Echo_Server_Request_Interceptor::receive_request from \"%C\"\n",
205 op.in ()));
207 if (ACE_OS::strcmp (op.in (), "normal") == 0)
209 Dynamic::ParameterList_var paramlist =
210 ri->arguments ();
212 CORBA::Long param;
213 CORBA::ULong i = 0; // index -- explicitly used to avoid
214 // overloaded operator ambiguity.
215 paramlist[i].argument >>= param;
217 ACE_DEBUG ((LM_DEBUG,
218 "The arg is %d\n",
219 param));
222 CORBA::String_var tmdi =
223 ri->target_most_derived_interface ();
225 ACE_DEBUG ((LM_DEBUG,
226 "Target most derived interface: %C\n",
227 tmdi.in ()));
230 void
231 Echo_Server_Request_Interceptor::send_reply (
232 PortableInterceptor::ServerRequestInfo_ptr ri)
234 ++server_interceptor_check_;
236 CORBA::String_var op = ri->operation ();
238 ACE_DEBUG ((LM_DEBUG,
239 "Echo_Server_Request_Interceptor::send_reply from \"%C\"\n",
240 op.in ()));
242 if (ACE_OS::strcmp (op.in (), "normal") == 0)
244 Dynamic::ParameterList_var paramlist =
245 ri->arguments ();
247 CORBA::Long param;
248 CORBA::ULong i = 0; // index -- explicitly used to avoid
249 // overloaded operator ambiguity.
250 paramlist[i].argument >>= param;
251 ACE_DEBUG ((LM_DEBUG,
252 "The arg is %d\n",
253 param));
256 if (ACE_OS::strcmp (op.in (), "calculate") == 0)
258 Dynamic::ParameterList_var paramlist =
259 ri->arguments ();
261 CORBA::Long param1, param2, result = 0;
262 CORBA::ULong i = 0; // index -- explicitly used to avoid
263 // overloaded operator ambiguity.
264 paramlist[i++].argument >>= param1;
265 paramlist[i].argument >>= param2;
267 CORBA::Any_var result_any = ri->result ();
269 (result_any.in ()) >>= result;
271 ACE_DEBUG ((LM_DEBUG,
272 "The result of calculate is %d + %d = %d\n",
273 param1,
274 param2,
275 result));
279 void
280 Echo_Server_Request_Interceptor::send_exception (
281 PortableInterceptor::ServerRequestInfo_ptr ri)
283 ++server_interceptor_check_;
285 CORBA::String_var op = ri->operation ();
287 ACE_DEBUG ((LM_DEBUG,
288 "Echo_Server_Request_Interceptor::send_exception "
289 "from \"%C\"\n",
290 op.in ()));
293 CORBA::Any_var any =
294 ri->sending_exception ();
296 CORBA::TypeCode_var type = any->type ();
298 const char *exception_id = type->id ();
300 ACE_DEBUG ((LM_DEBUG,
301 "Exception ID = %C\n",
302 exception_id));
305 void
306 Echo_Server_Request_Interceptor::send_other (
307 PortableInterceptor::ServerRequestInfo_ptr)
309 ++server_interceptor_check_;
311 // Do Nothing