1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4
5 #include <IceUtil/IceUtil.h>
6 #include <Ice/Ice.h>
7 #include <TestAMDI.h>
8
9 using namespace std;
10 using namespace Ice;
11
12 #ifdef ICE_CPP11_MAPPING
13 void
requestFailedExceptionAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)14 TestAMDI::requestFailedExceptionAsync(function<void()> response, function<void(exception_ptr)>, const Current&)
15 {
16 response();
17 }
18
19 void
unknownUserExceptionAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)20 TestAMDI::unknownUserExceptionAsync(function<void()> response, function<void(exception_ptr)>, const Current&)
21 {
22 response();
23 }
24
25 void
unknownLocalExceptionAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)26 TestAMDI::unknownLocalExceptionAsync(function<void()> response, function<void(exception_ptr)>, const Current&)
27 {
28 response();
29 }
30
31 void
unknownExceptionAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)32 TestAMDI::unknownExceptionAsync(function<void()> response, function<void(exception_ptr)>, const Current&)
33 {
34 response();
35 }
36
37 void
userExceptionAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)38 TestAMDI::userExceptionAsync(function<void()> response, function<void(exception_ptr)>, const Current&)
39 {
40 response();
41 }
42
43 void
localExceptionAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)44 TestAMDI::localExceptionAsync(function<void()> response, function<void(exception_ptr)>, const Current&)
45 {
46 response();
47 }
48
49 void
stdExceptionAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)50 TestAMDI::stdExceptionAsync(function<void()> response, function<void(exception_ptr)>, const Current&)
51 {
52 response();
53 }
54
55 void
cppExceptionAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)56 TestAMDI::cppExceptionAsync(function<void()> response, function<void(exception_ptr)>, const Current&)
57 {
58 response();
59 }
60
61 void
unknownExceptionWithServantExceptionAsync(function<void ()>,function<void (exception_ptr)> error,const Current &)62 TestAMDI::unknownExceptionWithServantExceptionAsync(function<void()>,
63 function<void(exception_ptr)> error,
64 const Current&)
65 {
66 try
67 {
68 throw Ice::ObjectNotExistException(__FILE__, __LINE__);
69 }
70 catch(...)
71 {
72 error(current_exception());
73 }
74 }
75
76 void
impossibleExceptionAsync(bool _cpp_throw,function<void (const string &)> response,function<void (exception_ptr)> error,const Current &)77 TestAMDI::impossibleExceptionAsync(bool _cpp_throw,
78 function<void(const string&)> response,
79 function<void(exception_ptr)> error,
80 const Current&)
81 {
82 if(_cpp_throw)
83 {
84 try
85 {
86 throw Test::TestImpossibleException();
87 }
88 catch(...)
89 {
90 error(current_exception());
91 }
92 }
93 else
94 {
95 //
96 // Return a value so we can be sure that the stream position
97 // is reset correctly if finished() throws.
98 //
99 response("Hello");
100 }
101 }
102
103 void
intfUserExceptionAsync(bool _cpp_throw,function<void (const string &)> response,function<void (exception_ptr)> error,const Current &)104 TestAMDI::intfUserExceptionAsync(bool _cpp_throw,
105 function<void(const string&)> response,
106 function<void(exception_ptr)> error,
107 const Current&)
108 {
109 if(_cpp_throw)
110 {
111 try
112 {
113 throw Test::TestIntfUserException();
114 }
115 catch(...)
116 {
117 error(current_exception());
118 }
119 }
120 else
121 {
122 //
123 // Return a value so we can be sure that the stream position
124 // is reset correctly if finished() throws.
125 //
126 response("Hello");
127 }
128 }
129
130 void
asyncResponseAsync(function<void ()> response,function<void (exception_ptr)>,const Current &)131 TestAMDI::asyncResponseAsync(function<void()> response,
132 function<void(exception_ptr)>,
133 const Current&)
134 {
135 response();
136 throw Ice::ObjectNotExistException(__FILE__, __LINE__);
137 }
138
139 void
asyncExceptionAsync(function<void ()>,function<void (exception_ptr)> error,const Current &)140 TestAMDI::asyncExceptionAsync(function<void()>,
141 function<void(exception_ptr)> error,
142 const Current&)
143 {
144 try
145 {
146 throw Test::TestIntfUserException();
147 }
148 catch(...)
149 {
150 error(current_exception());
151 }
152 throw Ice::ObjectNotExistException(__FILE__, __LINE__);
153 }
154
155 void
shutdownAsync(function<void ()> response,function<void (exception_ptr)>,const Current & current)156 TestAMDI::shutdownAsync(function<void()> response,
157 function<void(exception_ptr)>,
158 const Current& current)
159 {
160 current.adapter->deactivate();
161 response();
162 }
163 #else
164 void
requestFailedException_async(const Test::AMD_TestIntf_requestFailedExceptionPtr & cb,const Current &)165 TestAMDI::requestFailedException_async(const Test::AMD_TestIntf_requestFailedExceptionPtr& cb, const Current&)
166 {
167 cb->ice_response();
168 }
169
170 void
unknownUserException_async(const Test::AMD_TestIntf_unknownUserExceptionPtr & cb,const Current &)171 TestAMDI::unknownUserException_async(const Test::AMD_TestIntf_unknownUserExceptionPtr& cb, const Current&)
172 {
173 cb->ice_response();
174 }
175
176 void
unknownLocalException_async(const Test::AMD_TestIntf_unknownLocalExceptionPtr & cb,const Current &)177 TestAMDI::unknownLocalException_async(const Test::AMD_TestIntf_unknownLocalExceptionPtr& cb, const Current&)
178 {
179 cb->ice_response();
180 }
181
182 void
unknownException_async(const Test::AMD_TestIntf_unknownExceptionPtr & cb,const Current &)183 TestAMDI::unknownException_async(const Test::AMD_TestIntf_unknownExceptionPtr& cb, const Current&)
184 {
185 cb->ice_response();
186 }
187
188 void
userException_async(const Test::AMD_TestIntf_userExceptionPtr & cb,const Current &)189 TestAMDI::userException_async(const Test::AMD_TestIntf_userExceptionPtr& cb, const Current&)
190 {
191 cb->ice_response();
192 }
193
194 void
localException_async(const Test::AMD_TestIntf_localExceptionPtr & cb,const Current &)195 TestAMDI::localException_async(const Test::AMD_TestIntf_localExceptionPtr& cb, const Current&)
196 {
197 cb->ice_response();
198 }
199
200 void
stdException_async(const Test::AMD_TestIntf_stdExceptionPtr & cb,const Current &)201 TestAMDI::stdException_async(const Test::AMD_TestIntf_stdExceptionPtr& cb, const Current&)
202 {
203 cb->ice_response();
204 }
205
206 void
cppException_async(const Test::AMD_TestIntf_cppExceptionPtr & cb,const Current &)207 TestAMDI::cppException_async(const Test::AMD_TestIntf_cppExceptionPtr& cb, const Current&)
208 {
209 cb->ice_response();
210 }
211
212 void
unknownExceptionWithServantException_async(const Test::AMD_TestIntf_unknownExceptionWithServantExceptionPtr & cb,const Current &)213 TestAMDI::unknownExceptionWithServantException_async(const Test::AMD_TestIntf_unknownExceptionWithServantExceptionPtr& cb, const Current&)
214 {
215 cb->ice_exception(Ice::ObjectNotExistException(__FILE__, __LINE__));
216 }
217
218 void
impossibleException_async(const Test::AMD_TestIntf_impossibleExceptionPtr & cb,bool _cpp_throw,const Current &)219 TestAMDI::impossibleException_async(const Test::AMD_TestIntf_impossibleExceptionPtr& cb, bool _cpp_throw,
220 const Current&)
221 {
222 if(_cpp_throw)
223 {
224 cb->ice_exception(Test::TestImpossibleException());
225 }
226 else
227 {
228 //
229 // Return a value so we can be sure that the stream position
230 // is reset correctly if finished() throws.
231 //
232 cb->ice_response("Hello");
233 }
234 }
235
236 void
intfUserException_async(const Test::AMD_TestIntf_intfUserExceptionPtr & cb,bool _cpp_throw,const Current &)237 TestAMDI::intfUserException_async(const Test::AMD_TestIntf_intfUserExceptionPtr& cb, bool _cpp_throw, const Current&)
238 {
239 if(_cpp_throw)
240 {
241 cb->ice_exception(Test::TestIntfUserException());
242 }
243 else
244 {
245 //
246 // Return a value so we can be sure that the stream position
247 // is reset correctly if finished() throws.
248 //
249 cb->ice_response("Hello");
250 }
251 }
252
253 void
asyncResponse_async(const Test::AMD_TestIntf_asyncResponsePtr & cb,const Current &)254 TestAMDI::asyncResponse_async(const Test::AMD_TestIntf_asyncResponsePtr& cb, const Current&)
255 {
256 cb->ice_response();
257 throw Ice::ObjectNotExistException(__FILE__, __LINE__);
258 }
259
260 void
asyncException_async(const Test::AMD_TestIntf_asyncExceptionPtr & cb,const Current &)261 TestAMDI::asyncException_async(const Test::AMD_TestIntf_asyncExceptionPtr& cb, const Current&)
262 {
263 cb->ice_exception(Test::TestIntfUserException());
264 throw Ice::ObjectNotExistException(__FILE__, __LINE__);
265 }
266
267 void
shutdown_async(const Test::AMD_TestIntf_shutdownPtr & cb,const Current & current)268 TestAMDI::shutdown_async(const Test::AMD_TestIntf_shutdownPtr& cb, const Current& current)
269 {
270 current.adapter->deactivate();
271 cb->ice_response();
272 }
273 #endif
274
275 string
message() const276 CookieI::message() const
277 {
278 return "blahblah";
279 }
280