Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / AMI / Client_Interceptor.cpp
blobbb5950624a93264deb817adc21c9c67d45c1b796
1 /**
2 * @file Client_Interceptor.cpp
4 * @author Carlos O'Ryan <coryan@atdesk.com>
5 */
7 #include "Client_Interceptor.h"
8 #include "Shared_Interceptor.h"
9 #include "tao/OctetSeqC.h"
11 #include "ace/Log_Msg.h"
12 #include "ace/OS_NS_string.h"
14 unsigned long Echo_Client_Request_Interceptor::request_count = 0;
15 unsigned long Echo_Client_Request_Interceptor::reply_count = 0;
16 unsigned long Echo_Client_Request_Interceptor::other_count = 0;
17 unsigned long Echo_Client_Request_Interceptor::exception_count = 0;
19 Echo_Client_Request_Interceptor::
20 Echo_Client_Request_Interceptor ()
24 char *
25 Echo_Client_Request_Interceptor::name ()
27 return CORBA::string_dup ("Echo_Client_Interceptor");
30 void
31 Echo_Client_Request_Interceptor::destroy ()
35 void
36 Echo_Client_Request_Interceptor::send_poll (
37 PortableInterceptor::ClientRequestInfo_ptr)
39 ACE_ERROR((LM_ERROR,
40 "ERROR, unexpected interception point called send_poll()\n"));
41 throw CORBA::BAD_PARAM ();
44 void
45 Echo_Client_Request_Interceptor::send_request (
46 PortableInterceptor::ClientRequestInfo_ptr ri)
48 IOP::ServiceContext sc;
49 sc.context_id = ::service_id;
51 CORBA::Octet *buf = CORBA::OctetSeq::allocbuf(magic_cookie_len);
52 ACE_OS::memcpy(buf, magic_cookie, magic_cookie_len);
53 sc.context_data.replace (magic_cookie_len, magic_cookie_len, buf, 1);
55 // Add this context to the service context list.
56 ri->add_request_service_context (sc,
57 0);
59 // Check that the request service context can be retrieved.
60 IOP::ServiceContext_var rc =
61 ri->get_request_service_context (::service_id);
63 if (rc->context_data.length() != magic_cookie_len
64 || ACE_OS::memcmp(
65 magic_cookie, rc->context_data.get_buffer(),
66 magic_cookie_len) != 0
69 throw CORBA::BAD_PARAM();
72 Echo_Client_Request_Interceptor::request_count++;
75 void
76 Echo_Client_Request_Interceptor::receive_reply (
77 PortableInterceptor::ClientRequestInfo_ptr ri)
79 // Check that the request service context can be retrieved.
80 IOP::ServiceContext_var rc =
81 ri->get_request_service_context (::service_id);
83 if (rc->context_data.length() != magic_cookie_len
84 || ACE_OS::memcmp(
85 magic_cookie, rc->context_data.get_buffer(),
86 magic_cookie_len) != 0
89 throw CORBA::BAD_PARAM();
92 ++Echo_Client_Request_Interceptor::reply_count;
95 void
96 Echo_Client_Request_Interceptor::receive_other (
97 PortableInterceptor::ClientRequestInfo_ptr ri)
99 // Check that the request service context can be retrieved.
100 IOP::ServiceContext_var rc =
101 ri->get_request_service_context (::service_id);
103 if (rc->context_data.length() != magic_cookie_len
104 || ACE_OS::memcmp(
105 magic_cookie, rc->context_data.get_buffer(),
106 magic_cookie_len) != 0
109 throw CORBA::BAD_PARAM ();
112 Echo_Client_Request_Interceptor::other_count++;
115 void
116 Echo_Client_Request_Interceptor::receive_exception (
117 PortableInterceptor::ClientRequestInfo_ptr)
119 Echo_Client_Request_Interceptor::exception_count++;