Debian Codegraph @

include/grpcpp/impl/codegen/delegating_channel.h

raw
1 /*
2 *
3 * Copyright 2019 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_CODEGEN_DELEGATING_CHANNEL_H
20 #define GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H
21
22 // IWYU pragma: private
23
24 #include <memory>
25
26 #include <grpcpp/impl/codegen/channel_interface.h>
27
28 namespace grpc {
29 namespace experimental {
30
31 class DelegatingChannel : public grpc::ChannelInterface {
32 public:
33 ~DelegatingChannel() override {}
34
35 explicit DelegatingChannel(
36 std::shared_ptr<grpc::ChannelInterface> delegate_channel)
37 : delegate_channel_(delegate_channel) {}
38
39 grpc_connectivity_state GetState(bool try_to_connect) override {
40 return delegate_channel()->GetState(try_to_connect);
41 }
42
43 std::shared_ptr<grpc::ChannelInterface> delegate_channel() {
44 return delegate_channel_;
45 }
46
47 private:
48 internal::Call CreateCall(const internal::RpcMethod& method,
49 ClientContext* context,
50 grpc::CompletionQueue* cq) final {
51 return delegate_channel()->CreateCall(method, context, cq);
52 }
53
54 void PerformOpsOnCall(internal::CallOpSetInterface* ops,
55 internal::Call* call) final {
56 delegate_channel()->PerformOpsOnCall(ops, call);
57 }
58
59 void* RegisterMethod(const char* method) final {
60 return delegate_channel()->RegisterMethod(method);
61 }
62
63 void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
64 gpr_timespec deadline, grpc::CompletionQueue* cq,
65 void* tag) override {
66 delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq,
67 tag);
68 }
69
70 bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
71 gpr_timespec deadline) override {
72 return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline);
73 }
74
75 internal::Call CreateCallInternal(const internal::RpcMethod& method,
76 ClientContext* context,
77 grpc::CompletionQueue* cq,
78 size_t interceptor_pos) final {
79 return delegate_channel()->CreateCallInternal(method, context, cq,
80 interceptor_pos);
81 }
82
83 grpc::CompletionQueue* CallbackCQ() final {
84 return delegate_channel()->CallbackCQ();
85 }
86
87 std::shared_ptr<grpc::ChannelInterface> delegate_channel_;
88 };
89
90 } // namespace experimental
91 } // namespace grpc
92
93 #endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H