1/*
2 *
3 * Copyright 2018 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18#ifndef GRPCPP_IMPL_CODEGEN_CALL_H
19#define GRPCPP_IMPL_CODEGEN_CALL_H
20
21#include <grpc/impl/codegen/grpc_types.h>
22#include <grpcpp/impl/codegen/call_hook.h>
23
24namespace grpc_impl {
25class CompletionQueue;
26}
27
28namespace grpc {
29namespace experimental {
30class ClientRpcInfo;
31class ServerRpcInfo;
32} // namespace experimental
33namespace internal {
34class CallHook;
35class CallOpSetInterface;
36
37/// Straightforward wrapping of the C call object
38class Call final {
39 public:
40 Call()
41 : call_hook_(nullptr),
42 cq_(nullptr),
43 call_(nullptr),
44 max_receive_message_size_(-1) {}
45 /** call is owned by the caller */
46 Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq)
47 : call_hook_(call_hook),
48 cq_(cq),
49 call_(call),
50 max_receive_message_size_(-1) {}
51
52 Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq,
53 experimental::ClientRpcInfo* rpc_info)
54 : call_hook_(call_hook),
55 cq_(cq),
56 call_(call),
57 max_receive_message_size_(-1),
58 client_rpc_info_(rpc_info) {}
59
60 Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq,
61 int max_receive_message_size, experimental::ServerRpcInfo* rpc_info)
62 : call_hook_(call_hook),
63 cq_(cq),
64 call_(call),
65 max_receive_message_size_(max_receive_message_size),
66 server_rpc_info_(rpc_info) {}
67
68 void PerformOps(CallOpSetInterface* ops) {
69 call_hook_->PerformOpsOnCall(ops, call: this);
70 }
71
72 grpc_call* call() const { return call_; }
73 ::grpc_impl::CompletionQueue* cq() const { return cq_; }
74
75 int max_receive_message_size() const { return max_receive_message_size_; }
76
77 experimental::ClientRpcInfo* client_rpc_info() const {
78 return client_rpc_info_;
79 }
80
81 experimental::ServerRpcInfo* server_rpc_info() const {
82 return server_rpc_info_;
83 }
84
85 private:
86 CallHook* call_hook_;
87 ::grpc_impl::CompletionQueue* cq_;
88 grpc_call* call_;
89 int max_receive_message_size_;
90 experimental::ClientRpcInfo* client_rpc_info_ = nullptr;
91 experimental::ServerRpcInfo* server_rpc_info_ = nullptr;
92};
93} // namespace internal
94} // namespace grpc
95
96#endif // GRPCPP_IMPL_CODEGEN_CALL_H
97

source code of include/grpcpp/impl/codegen/call.h