Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
IncomingRequest.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_INCOMING_REQUEST_H
4#define ICE_INCOMING_REQUEST_H
5
6#include "Config.h"
7#include "ConnectionF.h"
8#include "Current.h"
9#include "ObjectAdapterF.h"
10
11namespace Ice
12{
13 class InputStream;
14
15 /// Represents a request received by a connection. It's the argument to the dispatch function on Object.
16 /// @remark IncomingRequest is neither copyable nor movable. It can be used only on the dispatch thread.
17 /// @see Object::dispatch
18 /// @headerfile Ice/Ice.h
19 class ICE_API IncomingRequest final
20 {
21 public:
22 /// Constructs an IncomingRequest object.
23 /// @param requestId The request ID. It's `0` for one-way requests.
24 /// @param connection The connection that received the request. It's nullptr for collocated invocations.
25 /// @param adapter The object adapter to set in Current.
26 /// @param inputStream The input stream buffer over the incoming Ice protocol request message. The stream is
27 /// positioned at the beginning of the request header - the next data to read is the identity of the target.
28 /// @param requestCount The number of requests remaining in @p inputStream. This value is always `1` for
29 /// non-batched requests.
30 /// @remark This constructor reads the request header from @p inputStream. When it completes, the input stream
31 /// is positioned at the beginning of encapsulation carried by the request.
32 /// @remark The Ice runtime calls this constructor when it dispatches an incoming request. You may want to call
33 /// it in a middleware unit test.
35 int32_t requestId,
36 ConnectionPtr connection,
37 ObjectAdapterPtr adapter,
39 std::int32_t requestCount);
40
41 IncomingRequest(const IncomingRequest&) = delete;
42 IncomingRequest(IncomingRequest&&) noexcept = delete;
43 IncomingRequest& operator=(const IncomingRequest&) = delete;
44 IncomingRequest& operator=(IncomingRequest&&) = delete;
45
46 /// Gets the Current object of the request.
47 /// @return A reference to the current object of the request.
48 Current& current() noexcept { return _current; }
49
50 /// Gets the Current object of the request.
51 /// @return A const reference to the current object of the request.
52 [[nodiscard]] const Ice::Current& current() const noexcept { return _current; }
53
54 /// Gets the input stream buffer of the request.
55 /// @return A reference to the input stream buffer.
56 InputStream& inputStream() noexcept { return _inputStream; }
57
58 /// Gets the number of bytes in the request.
59 /// @return The number of bytes in the request. These are all the bytes starting with the identity of the
60 /// target.
61 [[nodiscard]] std::int32_t size() const { return _requestSize; }
62
63 /// Gets the request count.
64 /// @return The number of requests remaining in the input stream when this IncomingRequest was constructed.
65 [[nodiscard]] std::int32_t requestCount() const noexcept { return _requestCount; }
66
67 private:
68 InputStream& _inputStream;
69 Current _current;
70 std::int32_t _requestSize;
71 std::int32_t _requestCount;
72 };
73}
74
75#endif
InputStream & inputStream() noexcept
Gets the input stream buffer of the request.
IncomingRequest(int32_t requestId, ConnectionPtr connection, ObjectAdapterPtr adapter, InputStream &inputStream, std::int32_t requestCount)
Constructs an IncomingRequest object.
std::int32_t requestCount() const noexcept
Gets the request count.
std::int32_t size() const
Gets the number of bytes in the request.
const Ice::Current & current() const noexcept
Gets the Current object of the request.
Current & current() noexcept
Gets the Current object of the request.
Represents a byte buffer used for unmarshaling data encoded using the Slice encoding.
Definition InputStream.h:50
std::shared_ptr< ObjectAdapter > ObjectAdapterPtr
A shared pointer to an ObjectAdapter.
std::shared_ptr< Connection > ConnectionPtr
A shared pointer to a Connection.
Definition ConnectionF.h:18
The Ice RPC framework.
Definition SampleEvent.h:59
Provides information about an incoming request being dispatched.
Definition Current.h:18