| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright 2015 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 |
|
| 19 |
#ifndef GRPCPP_IMPL_CALL_H |
| 20 |
#define GRPCPP_IMPL_CALL_H |
| 21 |
|
| 22 |
#include <grpc/impl/codegen/grpc_types.h> |
| 23 |
#include <grpcpp/impl/call_hook.h> |
| 24 |
|
| 25 |
namespace grpc { |
| 26 |
class CompletionQueue; |
| 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 |
Call() |
| 39 |
: call_hook_(nullptr), |
| 40 |
cq_(nullptr), |
| 41 |
call_(nullptr), |
| 42 |
max_receive_message_size_(-1) {} |
| 43 |
/** call is owned by the caller */ |
| 44 |
Call(grpc_call* call, CallHook* call_hook, grpc::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, grpc::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, grpc::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 |
void PerformOps(CallOpSetInterface* ops) { |
| 67 |
call_hook_->PerformOpsOnCall(ops, this); |
| 68 |
} |
| 69 |
|
| 70 |
grpc_call* call() const { return call_; } |
| 71 |
grpc::CompletionQueue* cq() const { return cq_; } |
| 72 |
|
| 73 |
int max_receive_message_size() const { return max_receive_message_size_; } |
| 74 |
|
| 75 |
experimental::ClientRpcInfo* client_rpc_info() const { |
| 76 |
return client_rpc_info_; |
| 77 |
} |
| 78 |
|
| 79 |
experimental::ServerRpcInfo* server_rpc_info() const { |
| 80 |
return server_rpc_info_; |
| 81 |
} |
| 82 |
|
| 83 |
private: |
| 84 |
CallHook* call_hook_; |
| 85 |
grpc::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_CALL_H |