• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace grpc {
23 namespace experimental {
24 
25 class DelegatingChannel : public ::grpc::ChannelInterface {
26  public:
~DelegatingChannel()27   virtual ~DelegatingChannel() {}
28 
DelegatingChannel(std::shared_ptr<::grpc::ChannelInterface> delegate_channel)29   DelegatingChannel(std::shared_ptr<::grpc::ChannelInterface> delegate_channel)
30       : delegate_channel_(delegate_channel) {}
31 
GetState(bool try_to_connect)32   grpc_connectivity_state GetState(bool try_to_connect) override {
33     return delegate_channel()->GetState(try_to_connect);
34   }
35 
delegate_channel()36   std::shared_ptr<::grpc::ChannelInterface> delegate_channel() {
37     return delegate_channel_;
38   }
39 
40  private:
CreateCall(const internal::RpcMethod & method,ClientContext * context,::grpc_impl::CompletionQueue * cq)41   internal::Call CreateCall(const internal::RpcMethod& method,
42                             ClientContext* context,
43                             ::grpc_impl::CompletionQueue* cq) final {
44     return delegate_channel()->CreateCall(method, context, cq);
45   }
46 
PerformOpsOnCall(internal::CallOpSetInterface * ops,internal::Call * call)47   void PerformOpsOnCall(internal::CallOpSetInterface* ops,
48                         internal::Call* call) final {
49     delegate_channel()->PerformOpsOnCall(ops, call);
50   }
51 
RegisterMethod(const char * method)52   void* RegisterMethod(const char* method) final {
53     return delegate_channel()->RegisterMethod(method);
54   }
55 
NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,gpr_timespec deadline,::grpc_impl::CompletionQueue * cq,void * tag)56   void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
57                                gpr_timespec deadline,
58                                ::grpc_impl::CompletionQueue* cq,
59                                void* tag) override {
60     delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq,
61                                                 tag);
62   }
63 
WaitForStateChangeImpl(grpc_connectivity_state last_observed,gpr_timespec deadline)64   bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
65                               gpr_timespec deadline) override {
66     return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline);
67   }
68 
CreateCallInternal(const internal::RpcMethod & method,ClientContext * context,::grpc_impl::CompletionQueue * cq,size_t interceptor_pos)69   internal::Call CreateCallInternal(const internal::RpcMethod& method,
70                                     ClientContext* context,
71                                     ::grpc_impl::CompletionQueue* cq,
72                                     size_t interceptor_pos) final {
73     return delegate_channel()->CreateCallInternal(method, context, cq,
74                                                   interceptor_pos);
75   }
76 
CallbackCQ()77   ::grpc_impl::CompletionQueue* CallbackCQ() final {
78     return delegate_channel()->CallbackCQ();
79   }
80 
81   std::shared_ptr<::grpc::ChannelInterface> delegate_channel_;
82 };
83 
84 }  // namespace experimental
85 }  // namespace grpc
86 
87 #endif  // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H
88