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
23
24class Rom;
25namespace net {
26class ProposalApprovalManager;
27class RomServiceImpl;
28}
29
30
31namespace test {
32class TestManager;
33class ImGuiTestHarnessServiceImpl;
34}
35
58class YazeGRPCServer {
59 public:
63 struct Config {
64 int port = 50051;
65 bool enable_test_harness = true;
66 bool enable_rom_service = true;
67 bool enable_canvas_automation = true;
68 bool require_approval_for_rom_writes = true;
69 };
70
71 YazeGRPCServer();
72 // Destructor must be defined in .cc file to allow deletion of incomplete types
73 ~YazeGRPCServer();
74
85 absl::Status Initialize(
86 int port,
87 test::TestManager* test_manager = nullptr,
88 Rom* rom = nullptr,
89 net::RomVersionManager* version_mgr = nullptr,
90 net::ProposalApprovalManager* approval_mgr = nullptr,
91 CanvasAutomationServiceImpl* canvas_service = nullptr);
92
97 absl::Status Start();
98
103 absl::Status StartAsync();
104
108 void Shutdown();
109
113 bool IsRunning() const;
114
118 int Port() const { return config_.port; }
119
123 void SetConfig(const Config& config) { config_ = config; }
124
125 private:
126 Config config_;
127 std::unique_ptr<grpc::Server> server_;
128 std::unique_ptr<test::ImGuiTestHarnessServiceImpl> test_harness_service_;
129 std::unique_ptr<net::RomServiceImpl> rom_service_;
130 std::unique_ptr<CanvasAutomationServiceImpl> canvas_service_;
131 // Store as base grpc::Service* to avoid incomplete type issues
132 std::unique_ptr<grpc::Service> canvas_grpc_service_;
133 bool is_running_;
134
135 // Build the gRPC server with all services
136 absl::Status BuildServer();
137};
138
139} // namespace yaze
140
141#endif // YAZE_WITH_GRPC
142#endif // YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_
143
144// Backwards compatibility alias
145#ifdef YAZE_WITH_GRPC
146namespace yaze {
147using UnifiedGRPCServer = YazeGRPCServer;
148}
149#endif
Main namespace for the application.
Definition controller.cc:20