• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
24 namespace grpc {
25 class CompletionQueue;
26 namespace experimental {
27 class ClientRpcInfo;
28 class ServerRpcInfo;
29 }  // namespace experimental
30 namespace internal {
31 class CallHook;
32 class CallOpSetInterface;
33 
34 /// Straightforward wrapping of the C call object
35 class Call final {
36  public:
Call()37   Call()
38       : call_hook_(nullptr),
39         cq_(nullptr),
40         call_(nullptr),
41         max_receive_message_size_(-1) {}
42   /** call is owned by the caller */
Call(grpc_call * call,CallHook * call_hook,::grpc::CompletionQueue * cq)43   Call(grpc_call* call, CallHook* call_hook, ::grpc::CompletionQueue* cq)
44       : call_hook_(call_hook),
45         cq_(cq),
46         call_(call),
47         max_receive_message_size_(-1) {}
48 
Call(grpc_call * call,CallHook * call_hook,::grpc::CompletionQueue * cq,experimental::ClientRpcInfo * rpc_info)49   Call(grpc_call* call, CallHook* call_hook, ::grpc::CompletionQueue* cq,
50        experimental::ClientRpcInfo* rpc_info)
51       : call_hook_(call_hook),
52         cq_(cq),
53         call_(call),
54         max_receive_message_size_(-1),
55         client_rpc_info_(rpc_info) {}
56 
Call(grpc_call * call,CallHook * call_hook,::grpc::CompletionQueue * cq,int max_receive_message_size,experimental::ServerRpcInfo * rpc_info)57   Call(grpc_call* call, CallHook* call_hook, ::grpc::CompletionQueue* cq,
58        int max_receive_message_size, experimental::ServerRpcInfo* rpc_info)
59       : call_hook_(call_hook),
60         cq_(cq),
61         call_(call),
62         max_receive_message_size_(max_receive_message_size),
63         server_rpc_info_(rpc_info) {}
64 
PerformOps(CallOpSetInterface * ops)65   void PerformOps(CallOpSetInterface* ops) {
66     call_hook_->PerformOpsOnCall(ops, this);
67   }
68 
call()69   grpc_call* call() const { return call_; }
cq()70   ::grpc::CompletionQueue* cq() const { return cq_; }
71 
max_receive_message_size()72   int max_receive_message_size() const { return max_receive_message_size_; }
73 
client_rpc_info()74   experimental::ClientRpcInfo* client_rpc_info() const {
75     return client_rpc_info_;
76   }
77 
server_rpc_info()78   experimental::ServerRpcInfo* server_rpc_info() const {
79     return server_rpc_info_;
80   }
81 
82  private:
83   CallHook* call_hook_;
84   ::grpc::CompletionQueue* cq_;
85   grpc_call* call_;
86   int max_receive_message_size_;
87   experimental::ClientRpcInfo* client_rpc_info_ = nullptr;
88   experimental::ServerRpcInfo* server_rpc_info_ = nullptr;
89 };
90 }  // namespace internal
91 }  // namespace grpc
92 
93 #endif  // GRPCPP_IMPL_CODEGEN_CALL_H
94