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 <functional>
7#include <memory>
8#include <vector>
9
10#include "absl/status/status.h"
13
14// gRPC types used by the server interface.
15#include <grpcpp/impl/service_type.h>
16#include <grpcpp/server.h>
17
18namespace yaze {
19
20// Forward declarations
21class CanvasAutomationServiceImpl;
22class Rom;
23
24namespace editor {
25class EditorManager;
26}
27
28namespace net {
29class ProposalApprovalManager;
30class RomServiceImpl;
31} // namespace net
32
33namespace test {
34class TestManager;
35class ImGuiTestHarnessServiceImpl;
36} // namespace test
37
42class YazeGRPCServer {
43 public:
44 using RomGetter = std::function<Rom*()>;
45
46 struct Config {
47 int port = 50052; // GUI automation server (AgentControlServer uses 50051)
48 bool enable_test_harness = true;
49 bool enable_rom_service = true;
50 bool enable_canvas_automation = true;
51 bool require_approval_for_rom_writes = true;
52 };
53
54 YazeGRPCServer();
55 ~YazeGRPCServer();
56
67 absl::Status Initialize(
68 int port, test::TestManager* test_manager = nullptr,
69 RomGetter rom_getter = nullptr,
70 net::RomVersionManager* version_mgr = nullptr,
71 net::ProposalApprovalManager* approval_mgr = nullptr,
72 CanvasAutomationServiceImpl* canvas_service = nullptr);
73
74 absl::Status Start();
75 absl::Status StartAsync();
76 absl::Status AddService(std::unique_ptr<grpc::Service> service);
77 void Shutdown();
78 bool IsRunning() const;
79 int Port() const { return config_.port; }
80 void SetConfig(const Config& config) { config_ = config; }
81
82 private:
83 Config config_;
84 std::unique_ptr<grpc::Server> server_;
85 std::unique_ptr<test::ImGuiTestHarnessServiceImpl> test_harness_service_;
86 std::unique_ptr<net::RomServiceImpl> rom_service_;
87 CanvasAutomationServiceImpl* canvas_service_ = nullptr;
88 std::unique_ptr<grpc::Service> canvas_grpc_service_;
89 std::unique_ptr<grpc::Service> test_harness_grpc_wrapper_;
90 std::vector<std::unique_ptr<grpc::Service>> extra_services_;
91 bool is_running_;
92
93 absl::Status BuildServer();
94};
95
96} // namespace yaze
97
98#endif // YAZE_WITH_GRPC
99#endif // YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_