Ice 3.7 C++11 API Reference
Incoming.h
Go to the documentation of this file.
1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_INCOMING_H
6 #define ICE_INCOMING_H
7 
8 #include <Ice/InstanceF.h>
9 #include <Ice/ConnectionIF.h>
10 #include <Ice/ServantLocatorF.h>
11 #include <Ice/ServantManagerF.h>
12 #include <Ice/OutputStream.h>
13 #include <Ice/InputStream.h>
14 #include <Ice/Object.h>
15 #include <Ice/Current.h>
16 #include <Ice/IncomingAsyncF.h>
17 #include <Ice/ObserverHelper.h>
18 #include <Ice/ResponseHandlerF.h>
19 
20 #include <deque>
21 
22 #ifdef ICE_CPP11_MAPPING
23 
24 namespace Ice
25 {
26 
33 {
34 public:
35 
39  MarshaledResult(const Current& current);
40 
45  std::shared_ptr<OutputStream> getOutputStream() const
46  {
47  return ostr;
48  }
49 
50 protected:
51 
53  std::shared_ptr<OutputStream> ostr;
54 };
55 
56 }
57 
58 #endif
59 
60 namespace IceInternal
61 {
62 
63 class ICE_API IncomingBase : private IceUtil::noncopyable
64 {
65 public:
66 
67  Ice::OutputStream* startWriteParams();
68  void endWriteParams();
69  void writeEmptyParams();
70  void writeParamEncaps(const Ice::Byte*, Ice::Int, bool);
71 
72 #ifdef ICE_CPP11_MAPPING
73  void setMarshaledResult(const Ice::MarshaledResult&);
74 #endif
75 
76  void response(bool);
77  void exception(const std::exception&, bool);
78  void exception(const std::string&, bool);
79 #if defined(_MSC_VER) && (_MSC_VER == 1500)
80  //
81  // COMPILERFIX v90 get confused with overloads above
82  // when passing a const char* as first argument.
83  //
84  void exception(const char* msg, bool amd)
85  {
86  exception(std::string(msg), amd);
87  }
88 #endif
89 
90 protected:
91 
92  IncomingBase(Instance*, ResponseHandler*, Ice::Connection*, const Ice::ObjectAdapterPtr&, bool, Ice::Byte, Ice::Int);
93  IncomingBase(IncomingBase&);
94 
95  void warning(const Ice::Exception&) const;
96  void warning(const std::string&) const;
97 
98  bool servantLocatorFinished(bool);
99 
100  void handleException(const std::exception&, bool);
101  void handleException(const std::string&, bool);
102 
103 #if defined(_MSC_VER) && (_MSC_VER == 1500)
104  //
105  // COMPILERFIX v90 get confused with overloads above
106  // when passing a const char* as first argument.
107  //
108  void handleException(const char* msg, bool amd)
109  {
110  handleException(std::string(msg), amd);
111  }
112 #endif
113 
114  Ice::Current _current;
115  Ice::ObjectPtr _servant;
116  Ice::ServantLocatorPtr _locator;
117 #ifdef ICE_CPP11_MAPPING
118  ::std::shared_ptr<void> _cookie;
119 #else
120  Ice::LocalObjectPtr _cookie;
121 #endif
122  DispatchObserver _observer;
123  bool _response;
124  Ice::Byte _compress;
125  Ice::FormatType _format;
126  Ice::OutputStream _os;
127 
128  //
129  // Optimization. The request handler may not be deleted while a
130  // stack-allocated Incoming still holds it.
131  //
132  ResponseHandler* _responseHandler;
133 
134 #ifdef ICE_CPP11_MAPPING
135  using DispatchInterceptorCallbacks = std::deque<std::pair<std::function<bool()>,
136  std::function<bool(std::exception_ptr)>>>;
137 #else
138  typedef std::deque<Ice::DispatchInterceptorAsyncCallbackPtr> DispatchInterceptorCallbacks;
139 #endif
140  DispatchInterceptorCallbacks _interceptorCBs;
141 };
142 
143 // TODO: fix this warning
144 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
145 # pragma warning(push)
146 # pragma warning(disable:4239)
147 #endif
148 
149 class ICE_API Incoming : public IncomingBase
150 {
151 public:
152 
153  Incoming(Instance*, ResponseHandler*, Ice::Connection*, const Ice::ObjectAdapterPtr&, bool, Ice::Byte, Ice::Int);
154 
155  const Ice::Current& getCurrent()
156  {
157  return _current;
158  }
159 
160 #ifdef ICE_CPP11_MAPPING
161  void push(std::function<bool()>, std::function<bool(std::exception_ptr)>);
162 #else
163  void push(const Ice::DispatchInterceptorAsyncCallbackPtr&);
164 #endif
165  void pop();
166 
167  void setAsync(const IncomingAsyncPtr& in)
168  {
169  assert(!_inAsync);
170  _inAsync = in;
171  }
172 
173  void startOver();
174 
175  void setFormat(Ice::FormatType format)
176  {
177  _format = format;
178  }
179 
180  void invoke(const ServantManagerPtr&, Ice::InputStream*);
181 
182  // Inlined for speed optimization.
183  void skipReadParams()
184  {
185  _current.encoding = _is->skipEncapsulation();
186  }
187  Ice::InputStream* startReadParams()
188  {
189  //
190  // Remember the encoding used by the input parameters, we'll
191  // encode the response parameters with the same encoding.
192  //
193  _current.encoding = _is->startEncapsulation();
194  return _is;
195  }
196  void endReadParams() const
197  {
198  _is->endEncapsulation();
199  }
200  void readEmptyParams()
201  {
202  _current.encoding = _is->skipEmptyEncapsulation();
203  }
204  void readParamEncaps(const Ice::Byte*& v, Ice::Int& sz)
205  {
206  _current.encoding = _is->readEncapsulation(v, sz);
207  }
208 
209 private:
210 
211  friend class IncomingAsync;
212 
213  Ice::InputStream* _is;
214  Ice::Byte* _inParamPos;
215 
216  IncomingAsyncPtr _inAsync;
217 };
218 
219 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
220 # pragma warning(pop)
221 #endif
222 
223 }
224 
225 #endif
ObserverHelper.h
Ice::MarshaledResult
Base class for marshaled result structures, which are generated for operations having the marshaled-r...
Definition: Incoming.h:33
Ice::LocalObjectPtr
IceInternal::Handle< LocalObject > LocalObjectPtr
Definition: LocalObjectF.h:17
Ice::InputStream
Interface for input streams used to extract Slice types from a sequence of bytes.
Definition: InputStream.h:50
Ice::MarshaledResult::ostr
std::shared_ptr< OutputStream > ostr
The output stream used to marshal the results.
Definition: Incoming.h:53
ServantManagerF.h
Current.h
InstanceF.h
OutputStream.h
ICE_API
#define ICE_API
Definition: Config.h:197
Ice::Byte
unsigned char Byte
The mapping for the Slice byte type.
Definition: Config.h:50
Ice::Connection
The user-level interface to a connection.
Definition: Connection.h:285
Ice::InputStream::startEncapsulation
const EncodingVersion & startEncapsulation()
Reads the start of an encapsulation.
Definition: InputStream.h:373
ServantLocatorF.h
IceUtil::noncopyable
Definition: Config.h:313
ConnectionIF.h
Object.h
Ice::FormatType
FormatType
Describes the possible formats for classes and exceptions.
Definition: Format.h:21
Ice::OutputStream
Interface for output streams used to create a sequence of bytes from Slice types.
Definition: OutputStream.h:28
Ice::MarshaledResult::getOutputStream
std::shared_ptr< OutputStream > getOutputStream() const
Obtains the output stream that is used to marshal the results.
Definition: Incoming.h:45
IceUtil::Exception
Abstract base class for all Ice exceptions.
Definition: Exception.h:22
Ice
Definition: BuiltinSequences.h:56
Ice::MarshaledResult::MarshaledResult
MarshaledResult(const Current &current)
The constructor requires the Current object that was passed to the servant.
InputStream.h
Ice::Current
Information about the current method invocation for servers.
Definition: Current.h:120
ResponseHandlerF.h
Ice::Int
int Int
The mapping for the Slice int type.
Definition: Config.h:54
IncomingAsyncF.h