-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapi_srpc.pb.hpp
More file actions
143 lines (111 loc) · 5.42 KB
/
Copy pathapi_srpc.pb.hpp
File metadata and controls
143 lines (111 loc) · 5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//go:build deps_only && cgo
// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
// protoc-gen-starpc-cpp version: v0.49.16
// source: github.com/aperturerobotics/controllerbus/bus/api/api.proto
#pragma once
#include <functional>
#include <memory>
#include <string>
#include <utility>
#include "srpc/starpc.hpp"
#include "api.pb.h"
namespace bus::api {
// Service ID for ControllerBusService
constexpr const char* kSRPCControllerBusServiceServiceID = "bus.api.ControllerBusService";
class SRPCControllerBusService_ExecControllerClient;
class SRPCControllerBusService_ExecControllerStream;
// SRPCControllerBusServiceClient is the client API for ControllerBusService service.
class SRPCControllerBusServiceClient {
public:
virtual ~SRPCControllerBusServiceClient() = default;
// SRPCClient returns the underlying SRPC client.
virtual starpc::Client* SRPCClient() = 0;
// GetBusInfo
virtual starpc::Error GetBusInfo(const bus::api::GetBusInfoRequest& in, bus::api::GetBusInfoResponse* out) = 0;
// ExecController
virtual std::pair<std::unique_ptr<SRPCControllerBusService_ExecControllerClient>, starpc::Error> ExecController(const controller::exec::ExecControllerRequest& in) = 0;
};
// SRPCControllerBusServiceClientImpl implements SRPCControllerBusServiceClient.
class SRPCControllerBusServiceClientImpl : public SRPCControllerBusServiceClient {
public:
explicit SRPCControllerBusServiceClientImpl(starpc::Client* cc, const std::string& service_id = "")
: cc_(cc), service_id_(service_id.empty() ? kSRPCControllerBusServiceServiceID : service_id) {}
starpc::Client* SRPCClient() override { return cc_; }
// GetBusInfo
virtual starpc::Error GetBusInfo(const bus::api::GetBusInfoRequest& in, bus::api::GetBusInfoResponse* out) override;
// ExecController
virtual std::pair<std::unique_ptr<SRPCControllerBusService_ExecControllerClient>, starpc::Error> ExecController(const controller::exec::ExecControllerRequest& in) override;
private:
starpc::Client* cc_;
std::string service_id_;
};
// NewSRPCControllerBusServiceClient creates a new client.
inline std::unique_ptr<SRPCControllerBusServiceClient> NewSRPCControllerBusServiceClient(starpc::Client* cc) {
return std::make_unique<SRPCControllerBusServiceClientImpl>(cc);
}
// SRPCControllerBusServiceServer is the server API for ControllerBusService service.
class SRPCControllerBusServiceServer {
public:
virtual ~SRPCControllerBusServiceServer() = default;
// GetBusInfo
virtual starpc::Error GetBusInfo(const bus::api::GetBusInfoRequest& req, bus::api::GetBusInfoResponse* resp) = 0;
// ExecController
virtual starpc::Error ExecController(const controller::exec::ExecControllerRequest& req, SRPCControllerBusService_ExecControllerStream* strm) = 0;
};
// SRPCControllerBusServiceHandler implements starpc::Handler for ControllerBusService.
class SRPCControllerBusServiceHandler : public starpc::Handler {
public:
SRPCControllerBusServiceHandler(SRPCControllerBusServiceServer* impl, const std::string& service_id = "")
: impl_(impl), service_id_(service_id.empty() ? kSRPCControllerBusServiceServiceID : service_id) {}
const std::string& GetServiceID() const override { return service_id_; }
std::vector<std::string> GetMethodIDs() const override;
std::pair<bool, starpc::Error> InvokeMethod(
const std::string& service_id,
const std::string& method_id,
starpc::Stream* strm) override;
private:
SRPCControllerBusServiceServer* impl_;
std::string service_id_;
};
// NewSRPCControllerBusServiceHandler creates a new handler for the given implementation.
inline std::unique_ptr<SRPCControllerBusServiceHandler> NewSRPCControllerBusServiceHandler(SRPCControllerBusServiceServer* impl) {
return std::make_unique<SRPCControllerBusServiceHandler>(impl);
}
// SRPCRegisterControllerBusService registers the server implementation with the mux.
// The returned handler must outlive the mux registration.
inline std::pair<std::unique_ptr<SRPCControllerBusServiceHandler>, starpc::Error> SRPCRegisterControllerBusService(starpc::Mux* mux, SRPCControllerBusServiceServer* impl) {
auto handler = NewSRPCControllerBusServiceHandler(impl);
starpc::Error err = mux->Register(handler.get());
if (err != starpc::Error::OK) {
return {nullptr, err};
}
return {std::move(handler), starpc::Error::OK};
}
// SRPCControllerBusService_ExecControllerClient is the client stream for ExecController.
class SRPCControllerBusService_ExecControllerClient {
public:
explicit SRPCControllerBusService_ExecControllerClient(std::unique_ptr<starpc::Stream> strm) : strm_(std::move(strm)) {}
starpc::Error Recv(controller::exec::ExecControllerResponse* msg) {
return strm_->MsgRecv(msg);
}
starpc::Error CloseSend() { return strm_->CloseSend(); }
starpc::Error Close() { return strm_->Close(); }
private:
std::unique_ptr<starpc::Stream> strm_;
};
// SRPCControllerBusService_ExecControllerStream is the server stream for ExecController.
class SRPCControllerBusService_ExecControllerStream {
public:
explicit SRPCControllerBusService_ExecControllerStream(starpc::Stream* strm) : strm_(strm) {}
starpc::Error Send(const controller::exec::ExecControllerResponse& msg) {
return strm_->MsgSend(msg);
}
starpc::Error SendAndClose(const controller::exec::ExecControllerResponse& msg) {
starpc::Error err = strm_->MsgSend(msg);
if (err != starpc::Error::OK) return err;
return strm_->CloseSend();
}
private:
starpc::Stream* strm_;
};
} // namespace bus::api