|
| 1 | +//go:build deps_only && cgo |
| 2 | + |
| 3 | +// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT. |
| 4 | +// protoc-gen-starpc-cpp version: v0.46.1 |
| 5 | +// source: github.com/aperturerobotics/template/example/example.proto |
| 6 | + |
| 7 | +#pragma once |
| 8 | + |
| 9 | +#include <functional> |
| 10 | +#include <memory> |
| 11 | +#include <string> |
| 12 | +#include <utility> |
| 13 | + |
| 14 | +#include "srpc/starpc.hpp" |
| 15 | + |
| 16 | +#include "example.pb.h" |
| 17 | + |
| 18 | +namespace example { |
| 19 | + |
| 20 | +// Service ID for Echoer |
| 21 | +constexpr const char* kSRPCEchoerServiceID = "example.Echoer"; |
| 22 | + |
| 23 | +class SRPCEchoer_EchoServerStreamClient; |
| 24 | +class SRPCEchoer_EchoServerStreamStream; |
| 25 | +class SRPCEchoer_EchoClientStreamClient; |
| 26 | +class SRPCEchoer_EchoClientStreamStream; |
| 27 | +class SRPCEchoer_EchoBidiStreamClient; |
| 28 | +class SRPCEchoer_EchoBidiStreamStream; |
| 29 | + |
| 30 | +// SRPCEchoerClient is the client API for Echoer service. |
| 31 | +class SRPCEchoerClient { |
| 32 | + public: |
| 33 | + virtual ~SRPCEchoerClient() = default; |
| 34 | + |
| 35 | + // SRPCClient returns the underlying SRPC client. |
| 36 | + virtual starpc::Client* SRPCClient() = 0; |
| 37 | + |
| 38 | + // Echo |
| 39 | + virtual starpc::Error Echo(const example::EchoMsg& in, example::EchoMsg* out) = 0; |
| 40 | + // EchoServerStream |
| 41 | + virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error> EchoServerStream(const example::EchoMsg& in) = 0; |
| 42 | + // EchoClientStream |
| 43 | + virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error> EchoClientStream() = 0; |
| 44 | + // EchoBidiStream |
| 45 | + virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error> EchoBidiStream() = 0; |
| 46 | +}; |
| 47 | + |
| 48 | +// SRPCEchoerClientImpl implements SRPCEchoerClient. |
| 49 | +class SRPCEchoerClientImpl : public SRPCEchoerClient { |
| 50 | + public: |
| 51 | + explicit SRPCEchoerClientImpl(starpc::Client* cc, const std::string& service_id = "") |
| 52 | + : cc_(cc), service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {} |
| 53 | + |
| 54 | + starpc::Client* SRPCClient() override { return cc_; } |
| 55 | + |
| 56 | + // Echo |
| 57 | + virtual starpc::Error Echo(const example::EchoMsg& in, example::EchoMsg* out) override; |
| 58 | + // EchoServerStream |
| 59 | + virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error> EchoServerStream(const example::EchoMsg& in) override; |
| 60 | + // EchoClientStream |
| 61 | + virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error> EchoClientStream() override; |
| 62 | + // EchoBidiStream |
| 63 | + virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error> EchoBidiStream() override; |
| 64 | + |
| 65 | + private: |
| 66 | + starpc::Client* cc_; |
| 67 | + std::string service_id_; |
| 68 | +}; |
| 69 | + |
| 70 | +// NewSRPCEchoerClient creates a new client. |
| 71 | +inline std::unique_ptr<SRPCEchoerClient> NewSRPCEchoerClient(starpc::Client* cc) { |
| 72 | + return std::make_unique<SRPCEchoerClientImpl>(cc); |
| 73 | +} |
| 74 | + |
| 75 | +// SRPCEchoerServer is the server API for Echoer service. |
| 76 | +class SRPCEchoerServer { |
| 77 | + public: |
| 78 | + virtual ~SRPCEchoerServer() = default; |
| 79 | + |
| 80 | + // Echo |
| 81 | + virtual starpc::Error Echo(const example::EchoMsg& req, example::EchoMsg* resp) = 0; |
| 82 | + // EchoServerStream |
| 83 | + virtual starpc::Error EchoServerStream(const example::EchoMsg& req, SRPCEchoer_EchoServerStreamStream* strm) = 0; |
| 84 | + // EchoClientStream |
| 85 | + virtual starpc::Error EchoClientStream(SRPCEchoer_EchoClientStreamStream* strm, example::EchoMsg* resp) = 0; |
| 86 | + // EchoBidiStream |
| 87 | + virtual starpc::Error EchoBidiStream(SRPCEchoer_EchoBidiStreamStream* strm) = 0; |
| 88 | +}; |
| 89 | + |
| 90 | +// SRPCEchoerHandler implements starpc::Handler for Echoer. |
| 91 | +class SRPCEchoerHandler : public starpc::Handler { |
| 92 | + public: |
| 93 | + SRPCEchoerHandler(SRPCEchoerServer* impl, const std::string& service_id = "") |
| 94 | + : impl_(impl), service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {} |
| 95 | + |
| 96 | + const std::string& GetServiceID() const override { return service_id_; } |
| 97 | + std::vector<std::string> GetMethodIDs() const override; |
| 98 | + std::pair<bool, starpc::Error> InvokeMethod( |
| 99 | + const std::string& service_id, |
| 100 | + const std::string& method_id, |
| 101 | + starpc::Stream* strm) override; |
| 102 | + |
| 103 | + private: |
| 104 | + SRPCEchoerServer* impl_; |
| 105 | + std::string service_id_; |
| 106 | +}; |
| 107 | + |
| 108 | +// NewSRPCEchoerHandler creates a new handler for the given implementation. |
| 109 | +inline std::unique_ptr<SRPCEchoerHandler> NewSRPCEchoerHandler(SRPCEchoerServer* impl) { |
| 110 | + return std::make_unique<SRPCEchoerHandler>(impl); |
| 111 | +} |
| 112 | + |
| 113 | +// SRPCRegisterEchoer registers the server implementation with the mux. |
| 114 | +// The returned handler must outlive the mux registration. |
| 115 | +inline std::pair<std::unique_ptr<SRPCEchoerHandler>, starpc::Error> SRPCRegisterEchoer(starpc::Mux* mux, SRPCEchoerServer* impl) { |
| 116 | + auto handler = NewSRPCEchoerHandler(impl); |
| 117 | + starpc::Error err = mux->Register(handler.get()); |
| 118 | + if (err != starpc::Error::OK) { |
| 119 | + return {nullptr, err}; |
| 120 | + } |
| 121 | + return {std::move(handler), starpc::Error::OK}; |
| 122 | +} |
| 123 | + |
| 124 | +// SRPCEchoer_EchoServerStreamClient is the client stream for EchoServerStream. |
| 125 | +class SRPCEchoer_EchoServerStreamClient { |
| 126 | + public: |
| 127 | + explicit SRPCEchoer_EchoServerStreamClient(std::unique_ptr<starpc::Stream> strm) : strm_(std::move(strm)) {} |
| 128 | + |
| 129 | + starpc::Error Recv(example::EchoMsg* msg) { |
| 130 | + return strm_->MsgRecv(msg); |
| 131 | + } |
| 132 | + |
| 133 | + starpc::Error CloseSend() { return strm_->CloseSend(); } |
| 134 | + starpc::Error Close() { return strm_->Close(); } |
| 135 | + |
| 136 | + private: |
| 137 | + std::unique_ptr<starpc::Stream> strm_; |
| 138 | +}; |
| 139 | + |
| 140 | +// SRPCEchoer_EchoServerStreamStream is the server stream for EchoServerStream. |
| 141 | +class SRPCEchoer_EchoServerStreamStream { |
| 142 | + public: |
| 143 | + explicit SRPCEchoer_EchoServerStreamStream(starpc::Stream* strm) : strm_(strm) {} |
| 144 | + |
| 145 | + starpc::Error Send(const example::EchoMsg& msg) { |
| 146 | + return strm_->MsgSend(msg); |
| 147 | + } |
| 148 | + |
| 149 | + starpc::Error SendAndClose(const example::EchoMsg& msg) { |
| 150 | + starpc::Error err = strm_->MsgSend(msg); |
| 151 | + if (err != starpc::Error::OK) return err; |
| 152 | + return strm_->CloseSend(); |
| 153 | + } |
| 154 | + |
| 155 | + private: |
| 156 | + starpc::Stream* strm_; |
| 157 | +}; |
| 158 | + |
| 159 | +// SRPCEchoer_EchoClientStreamClient is the client stream for EchoClientStream. |
| 160 | +class SRPCEchoer_EchoClientStreamClient { |
| 161 | + public: |
| 162 | + explicit SRPCEchoer_EchoClientStreamClient(std::unique_ptr<starpc::Stream> strm) : strm_(std::move(strm)) {} |
| 163 | + |
| 164 | + starpc::Error Send(const example::EchoMsg& msg) { |
| 165 | + return strm_->MsgSend(msg); |
| 166 | + } |
| 167 | + |
| 168 | + starpc::Error CloseAndRecv(example::EchoMsg* msg) { |
| 169 | + starpc::Error err = strm_->CloseSend(); |
| 170 | + if (err != starpc::Error::OK) return err; |
| 171 | + return strm_->MsgRecv(msg); |
| 172 | + } |
| 173 | + |
| 174 | + starpc::Error CloseSend() { return strm_->CloseSend(); } |
| 175 | + starpc::Error Close() { return strm_->Close(); } |
| 176 | + |
| 177 | + private: |
| 178 | + std::unique_ptr<starpc::Stream> strm_; |
| 179 | +}; |
| 180 | + |
| 181 | +// SRPCEchoer_EchoClientStreamStream is the server stream for EchoClientStream. |
| 182 | +class SRPCEchoer_EchoClientStreamStream { |
| 183 | + public: |
| 184 | + explicit SRPCEchoer_EchoClientStreamStream(starpc::Stream* strm) : strm_(strm) {} |
| 185 | + |
| 186 | + starpc::Error Recv(example::EchoMsg* msg) { |
| 187 | + return strm_->MsgRecv(msg); |
| 188 | + } |
| 189 | + |
| 190 | + private: |
| 191 | + starpc::Stream* strm_; |
| 192 | +}; |
| 193 | + |
| 194 | +// SRPCEchoer_EchoBidiStreamClient is the client stream for EchoBidiStream. |
| 195 | +class SRPCEchoer_EchoBidiStreamClient { |
| 196 | + public: |
| 197 | + explicit SRPCEchoer_EchoBidiStreamClient(std::unique_ptr<starpc::Stream> strm) : strm_(std::move(strm)) {} |
| 198 | + |
| 199 | + starpc::Error Send(const example::EchoMsg& msg) { |
| 200 | + return strm_->MsgSend(msg); |
| 201 | + } |
| 202 | + |
| 203 | + starpc::Error Recv(example::EchoMsg* msg) { |
| 204 | + return strm_->MsgRecv(msg); |
| 205 | + } |
| 206 | + |
| 207 | + starpc::Error CloseSend() { return strm_->CloseSend(); } |
| 208 | + starpc::Error Close() { return strm_->Close(); } |
| 209 | + |
| 210 | + private: |
| 211 | + std::unique_ptr<starpc::Stream> strm_; |
| 212 | +}; |
| 213 | + |
| 214 | +// SRPCEchoer_EchoBidiStreamStream is the server stream for EchoBidiStream. |
| 215 | +class SRPCEchoer_EchoBidiStreamStream { |
| 216 | + public: |
| 217 | + explicit SRPCEchoer_EchoBidiStreamStream(starpc::Stream* strm) : strm_(strm) {} |
| 218 | + |
| 219 | + starpc::Error Send(const example::EchoMsg& msg) { |
| 220 | + return strm_->MsgSend(msg); |
| 221 | + } |
| 222 | + |
| 223 | + starpc::Error SendAndClose(const example::EchoMsg& msg) { |
| 224 | + starpc::Error err = strm_->MsgSend(msg); |
| 225 | + if (err != starpc::Error::OK) return err; |
| 226 | + return strm_->CloseSend(); |
| 227 | + } |
| 228 | + |
| 229 | + starpc::Error Recv(example::EchoMsg* msg) { |
| 230 | + return strm_->MsgRecv(msg); |
| 231 | + } |
| 232 | + |
| 233 | + private: |
| 234 | + starpc::Stream* strm_; |
| 235 | +}; |
| 236 | + |
| 237 | +} // namespace example |
0 commit comments