Ice 3.7 C++11 API Reference
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 
8 #include <Ice/IncomingAsyncF.h>
9 #include <Ice/Incoming.h>
10 
11 #ifndef ICE_CPP11_MAPPING
12 namespace Ice
13 {
14 
19 class ICE_API AMDCallback : public Ice::LocalObject
20 {
21 public:
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 
40 namespace 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 //
53 class 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 {
60 public:
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 
110 private:
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
129 namespace Ice
130 {
131 
136 class ICE_API AMD_Object_ice_invoke : public virtual Ice::AMDCallback
137 {
138 public:
139 
140  virtual ~AMD_Object_ice_invoke();
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 
164 namespace IceAsync
165 {
166 
167 namespace Ice
168 {
169 
170 class ICE_API AMD_Object_ice_invoke : public ::Ice::AMD_Object_ice_invoke, public IceInternal::IncomingAsync
171 {
172 public:
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
Incoming.h
ICE_API
#define ICE_API
Definition: Config.h:197
Ice
Definition: BuiltinSequences.h:56
IncomingAsyncF.h