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