Ice 3.7 C++98 API Reference
Loading...
Searching...
No Matches
IncomingAsync.h
Go to the documentation of this file.
1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5#ifndef ICE_INCOMING_ASYNC_H
6#define ICE_INCOMING_ASYNC_H
7
9#include <Ice/Incoming.h>
10
11#ifndef ICE_CPP11_MAPPING
12namespace Ice
13{
14
20{
21public:
22
23 virtual ~AMDCallback();
24
29 virtual void ice_exception(const ::std::exception& ex) = 0;
30
34 virtual void ice_exception() = 0;
35};
36
37}
38#endif
39
40namespace IceInternal
41{
42
43// TODO: fix this warning
44#if defined(_MSC_VER) && (_MSC_VER >= 1900)
45# pragma warning(push)
46# pragma warning(disable:4239)
47#endif
48
49//
50// We need virtual inheritance from AMDCallback, because we use multiple
51// inheritance from Ice::AMDCallback for generated AMD code.
52//
53class ICE_API IncomingAsync : public IncomingBase,
54#ifdef ICE_CPP11_MAPPING
55 public ::std::enable_shared_from_this<IncomingAsync>
56#else
57 public virtual Ice::AMDCallback
58#endif
59{
60public:
61
62 IncomingAsync(Incoming&);
63
64#ifdef ICE_CPP11_MAPPING
65
66 static std::shared_ptr<IncomingAsync> create(Incoming&);
67
68 std::function<void()> response()
69 {
70 auto self = shared_from_this();
71 return [self]()
72 {
73 self->writeEmptyParams();
74 self->completed();
75 };
76 }
77
78 template<class T>
79 std::function<void(const T&)> response()
80 {
81 auto self = shared_from_this();
82 return [self](const T& marshaledResult)
83 {
84 self->setMarshaledResult(marshaledResult);
85 self->completed();
86 };
87 }
88
89 std::function<void(std::exception_ptr)> exception()
90 {
91 auto self = shared_from_this();
92 return [self](std::exception_ptr ex) { self->completed(ex); };
93 }
94
95#else
96
97 virtual void ice_exception(const ::std::exception&);
98 virtual void ice_exception();
99
100#endif
101
102 void kill(Incoming&);
103
104 void completed();
105
106#ifdef ICE_CPP11_MAPPING
107 void completed(std::exception_ptr);
108#endif
109
110private:
111
112 void checkResponseSent();
113 bool _responseSent;
114
115 //
116 // We need a separate ConnectionIPtr, because IncomingBase only
117 // holds a ConnectionI* for optimization.
118 //
119 const ResponseHandlerPtr _responseHandlerCopy;
120};
121
122#if defined(_MSC_VER) && (_MSC_VER >= 1900)
123# pragma warning(pop)
124#endif
125
126}
127
128#ifndef ICE_CPP11_MAPPING
129namespace Ice
130{
131
137{
138public:
139
141
149 virtual void ice_response(bool ok, const std::vector<Ice::Byte>& bytes) = 0;
150
158 virtual void ice_response(bool ok, const std::pair<const Ice::Byte*, const Ice::Byte*>& bytes) = 0;
159};
160
161}
162
164namespace IceAsync
165{
166
167namespace Ice
168{
169
170class ICE_API AMD_Object_ice_invoke : public ::Ice::AMD_Object_ice_invoke, public IceInternal::IncomingAsync
171{
172public:
173
174 AMD_Object_ice_invoke(IceInternal::Incoming&);
175
176 virtual void ice_response(bool, const std::vector< ::Ice::Byte>&);
177 virtual void ice_response(bool, const std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&);
178};
179
180}
181
182}
184#endif
185
186#endif
#define ICE_API
Definition Config.h:197
Base class for generated AMD callback classes.
Definition IncomingAsync.h:20
virtual void ice_exception(const ::std::exception &ex)=0
Completes the asynchronous request with the given exception.
virtual void ice_exception()=0
Completes the asynchronous request with an UnknownException.
virtual ~AMDCallback()
Base class for the AMD callback for BlobjectAsync::ice_invoke_async.
Definition IncomingAsync.h:137
virtual void ice_response(bool ok, const std::vector< Ice::Byte > &bytes)=0
Completes the request.
virtual void ice_response(bool ok, const std::pair< const Ice::Byte *, const Ice::Byte * > &bytes)=0
Completes the request.
Base class for local Slice classes and interfaces.
Definition LocalObject.h:25
Definition BuiltinSequences.h:113