GRPC C++ 0.10.0.0

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
service_type.h
Go to the documentation of this file.
1 /*
2 *
3 * Copyright 2015, Google Inc.
4 * 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
34 #ifndef GRPCXX_IMPL_SERVICE_TYPE_H
35 #define GRPCXX_IMPL_SERVICE_TYPE_H
36
37 #include <grpc++/config.h>
38 #include <grpc++/impl/serialization_traits.h>
39 #include <grpc++/server.h>
40 #include <grpc++/status.h>
41
42 namespace grpc {
43
44 class Call;
45 class CompletionQueue;
46 class RpcService;
47 class Server;
48 class ServerCompletionQueue;
49 class ServerContext;
50
51 class SynchronousService {
52 public:
53 virtual ~SynchronousService() {}
54 virtual RpcService* service() = 0;
55 };
56
57 class ServerAsyncStreamingInterface {
58 public:
59 virtual ~ServerAsyncStreamingInterface() {}
60
61 virtual void SendInitialMetadata(void* tag) = 0;
62
63 private:
64 friend class Server;
65 virtual void BindCall(Call* call) = 0;
66 };
67
68 class AsynchronousService {
69 public:
70 AsynchronousService(const char** method_names, size_t method_count)
71 : server_(nullptr),
72 method_names_(method_names),
73 method_count_(method_count),
74 request_args_(nullptr) {}
75
76 ~AsynchronousService() { delete[] request_args_; }
77
78 protected:
79 template <class Message>
80 void RequestAsyncUnary(int index, ServerContext* context, Message* request,
81 ServerAsyncStreamingInterface* stream,
82 CompletionQueue* call_cq,
83 ServerCompletionQueue* notification_cq, void* tag) {
84 server_->RequestAsyncCall(request_args_[index], context, stream, call_cq,
85 notification_cq, tag, request);
86 }
87 void RequestClientStreaming(int index, ServerContext* context,
88 ServerAsyncStreamingInterface* stream,
89 CompletionQueue* call_cq,
90 ServerCompletionQueue* notification_cq,
91 void* tag) {
92 server_->RequestAsyncCall(request_args_[index], context, stream, call_cq,
93 notification_cq, tag);
94 }
95 template <class Message>
96 void RequestServerStreaming(int index, ServerContext* context,
97 Message* request,
98 ServerAsyncStreamingInterface* stream,
99 CompletionQueue* call_cq,
100 ServerCompletionQueue* notification_cq,
101 void* tag) {
102 server_->RequestAsyncCall(request_args_[index], context, stream, call_cq,
103 notification_cq, tag, request);
104 }
105 void RequestBidiStreaming(int index, ServerContext* context,
106 ServerAsyncStreamingInterface* stream,
107 CompletionQueue* call_cq,
108 ServerCompletionQueue* notification_cq, void* tag) {
109 server_->RequestAsyncCall(request_args_[index], context, stream, call_cq,
110 notification_cq, tag);
111 }
112
113 private:
114 friend class Server;
115 Server* server_;
116 const char** const method_names_;
117 size_t method_count_;
118 void** request_args_;
119 };
120
121 } // namespace grpc
122
123 #endif // GRPCXX_IMPL_SERVICE_TYPE_H
grpc::ServerAsyncStreamingInterface::SendInitialMetadata
virtual void SendInitialMetadata(void *tag)=0
grpc::AsynchronousService::~AsynchronousService
~AsynchronousService()
Definition: service_type.h:76
grpc::AsynchronousService
Definition: service_type.h:68
grpc::SynchronousService::~SynchronousService
virtual ~SynchronousService()
Definition: service_type.h:53
config.h
grpc::ServerAsyncStreamingInterface
Definition: service_type.h:57
serialization_traits.h
grpc::AsynchronousService::RequestClientStreaming
void RequestClientStreaming(int index, ServerContext *context, ServerAsyncStreamingInterface *stream, CompletionQueue *call_cq, ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:87
grpc::SynchronousService
Definition: service_type.h:51
grpc::RpcService
Definition: rpc_service_method.h:227
server.h
grpc::Server
Definition: server.h:61
grpc::Call
Definition: call.h:565
grpc::AsynchronousService::RequestServerStreaming
void RequestServerStreaming(int index, ServerContext *context, Message *request, ServerAsyncStreamingInterface *stream, CompletionQueue *call_cq, ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:96
grpc::ServerContext
Definition: server_context.h:86
grpc::AsynchronousService::AsynchronousService
AsynchronousService(const char **method_names, size_t method_count)
Definition: service_type.h:70
grpc::CompletionQueue
Definition: completion_queue.h:87
status.h
grpc::SynchronousService::service
virtual RpcService * service()=0
grpc::AsynchronousService::RequestBidiStreaming
void RequestBidiStreaming(int index, ServerContext *context, ServerAsyncStreamingInterface *stream, CompletionQueue *call_cq, ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:105
grpc::ServerAsyncStreamingInterface::~ServerAsyncStreamingInterface
virtual ~ServerAsyncStreamingInterface()
Definition: service_type.h:59
grpc::ServerCompletionQueue
Definition: completion_queue.h:162
grpc::AsynchronousService::RequestAsyncUnary
void RequestAsyncUnary(int index, ServerContext *context, Message *request, ServerAsyncStreamingInterface *stream, CompletionQueue *call_cq, ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:80
grpc::protobuf::Message
::google::protobuf::Message Message
Definition: config_protobuf.h:60