blob: 5ac0371efb72d9db6e499b26748182af5d08a98b [file] [log] [blame]
Craig Tillerdb57c4f2015-02-24 10:34:47 -08001/*
2 *
David Garcia Quintas61908542016-01-20 11:21:27 -08003 * Copyright 2015-2016, Google Inc.
Craig Tillerdb57c4f2015-02-24 10:34:47 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
yang-g9e2f90c2015-08-21 15:35:03 -070034#ifndef GRPCXX_GENERIC_GENERIC_STUB_H
35#define GRPCXX_GENERIC_GENERIC_STUB_H
Craig Tillerdb57c4f2015-02-24 10:34:47 -080036
yang-g9fb35a52015-08-21 15:49:35 -070037#include <grpc++/support/async_stream.h>
yang-g9e2f90c2015-08-21 15:35:03 -070038#include <grpc++/support/byte_buffer.h>
Craig Tillerdb57c4f2015-02-24 10:34:47 -080039
40namespace grpc {
41
Yang Gao75e2f6d2015-03-19 07:04:38 -070042class CompletionQueue;
Yang Gao49996492015-03-12 16:40:19 -070043typedef ClientAsyncReaderWriter<ByteBuffer, ByteBuffer>
44 GenericClientAsyncReaderWriter;
Craig Tillerdb57c4f2015-02-24 10:34:47 -080045
Yang Gao005eb882015-03-11 22:17:13 -070046// Generic stubs provide a type-unsafe interface to call gRPC methods
Craig Tillerdb57c4f2015-02-24 10:34:47 -080047// by name.
Yang Gao179f8682015-03-12 14:36:58 -070048class GenericStub GRPC_FINAL {
Craig Tillerdb57c4f2015-02-24 10:34:47 -080049 public:
David Garcia Quintasf3ddb7c2016-01-20 16:02:22 -080050 explicit GenericStub(std::shared_ptr<ChannelInterface> channel)
51 : channel_(channel) {}
Craig Tillerdb57c4f2015-02-24 10:34:47 -080052
53 // begin a call to a named method
Yang Gao49996492015-03-12 16:40:19 -070054 std::unique_ptr<GenericClientAsyncReaderWriter> Call(
Craig Tillerd6c98df2015-08-18 09:33:44 -070055 ClientContext* context, const grpc::string& method, CompletionQueue* cq,
56 void* tag);
Craig Tillerdb57c4f2015-02-24 10:34:47 -080057
58 private:
David Garcia Quintas44f32492016-01-14 18:00:04 -080059 std::shared_ptr<ChannelInterface> channel_;
Craig Tillerdb57c4f2015-02-24 10:34:47 -080060};
61
Yang Gao6baa9b62015-03-17 10:49:39 -070062} // namespace grpc
Craig Tillerdb57c4f2015-02-24 10:34:47 -080063
yang-g9e2f90c2015-08-21 15:35:03 -070064#endif // GRPCXX_GENERIC_GENERIC_STUB_H