yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
unified_grpc_server.h
Go to the documentation of this file.
1#ifndef YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_
2#define YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_
3
4#ifdef YAZE_WITH_GRPC
5
6#include <memory>
7
8#include "absl/status/status.h"
10
11// Include grpcpp for grpc::Service forward declaration
12#include <grpcpp/impl/service_type.h>
13
14namespace grpc {
15class Server;
16}
17
18namespace yaze {
19
20// Forward declarations
21class CanvasAutomationServiceImpl;
22
23class Rom;
24namespace net {
25class ProposalApprovalManager;
26class RomServiceImpl;
27} // namespace net
28
29namespace test {
30class TestManager;
31class ImGuiTestHarnessServiceImpl;
32} // namespace test
33
57class YazeGRPCServer {
58 public:
62 struct Config {
63 int port = 50051;
64 bool enable_test_harness = true;
65 bool enable_rom_service = true;
66 bool enable_canvas_automation = true;
67 bool require_approval_for_rom_writes = true;
68 };
69
70 YazeGRPCServer();
71 // Destructor must be defined in .cc file to allow deletion of incomplete
72 // types
73 ~YazeGRPCServer();
74
85 absl::Status Initialize(
86 int port, test::TestManager* test_manager = nullptr, Rom* rom = nullptr,
87 net::RomVersionManager* version_mgr = nullptr,
88 net::ProposalApprovalManager* approval_mgr = nullptr,
89 CanvasAutomationServiceImpl* canvas_service = nullptr);
90
95 absl::Status Start();
96
101 absl::Status StartAsync();
102
106 void Shutdown();
107
111 bool IsRunning() const;
112
116 int Port() const { return config_.port; }
117
121 void SetConfig(const Config& config) { config_ = config; }
122
123 private:
124 Config config_;
125 std::unique_ptr<grpc::Server> server_;
126 std::unique_ptr<test::ImGuiTestHarnessServiceImpl> test_harness_service_;
127 std::unique_ptr<net::RomServiceImpl> rom_service_;
128 CanvasAutomationServiceImpl* canvas_service_ = nullptr;
129 // Store as base grpc::Service* to avoid incomplete type issues
130 std::unique_ptr<grpc::Service> canvas_grpc_service_;
131 bool is_running_;
132
133 // Build the gRPC server with all services
134 absl::Status BuildServer();
135};
136
137} // namespace yaze
138
139#endif // YAZE_WITH_GRPC
140#endif // YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_
141
142// Backwards compatibility alias
143#ifdef YAZE_WITH_GRPC
144namespace yaze {
145using UnifiedGRPCServer = YazeGRPCServer;
146}
147#endif