1#ifndef YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_
2#define YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_
11#include "absl/status/status.h"
12#include "absl/status/statusor.h"
17#include <grpcpp/impl/service_type.h>
18#include <grpcpp/server.h>
26class CanvasAutomationServiceImpl;
38class ProposalApprovalManager;
40class EmulatorServiceImpl;
45class ImGuiTestHarnessServiceImpl;
46struct ScreenshotArtifact;
55 using RomGetter = std::function<Rom*()>;
56 using RomLoader = std::function<bool(
const std::string& path)>;
60 bool enable_test_harness =
true;
61 bool enable_rom_service =
true;
62 bool enable_emulator_service =
true;
63 bool enable_canvas_automation =
true;
64 bool require_approval_for_rom_writes =
true;
67 std::string bind_address =
"0.0.0.0";
70 void SetBindAddress(
const std::string& address) {
71 config_.bind_address = address;
89 absl::Status Initialize(
90 int port, emu::IEmulator* emulator =
nullptr,
91 RomGetter rom_getter =
nullptr, RomLoader rom_loader =
nullptr,
92 test::TestManager* test_manager =
nullptr,
93 net::RomVersionManager* version_mgr =
nullptr,
94 net::ProposalApprovalManager* approval_mgr =
nullptr,
95 CanvasAutomationServiceImpl* canvas_service =
nullptr);
98 void SetEmulatorScreenshotCapturer(
99 std::function<absl::StatusOr<test::ScreenshotArtifact>()> capturer);
101 absl::Status Start();
102 absl::Status StartAsync();
103 absl::Status AddService(std::unique_ptr<grpc::Service> service);
105 bool IsRunning()
const;
106 int Port()
const {
return config_.port; }
107 void SetConfig(
const Config& config) { config_ = config; }
111 std::unique_ptr<grpc::Server> server_;
114 std::unique_ptr<test::ImGuiTestHarnessServiceImpl> test_harness_service_;
115 std::unique_ptr<net::RomServiceImpl> rom_service_;
116 std::unique_ptr<net::EmulatorServiceImpl> emulator_service_;
117 CanvasAutomationServiceImpl* canvas_service_ =
nullptr;
120 std::unique_ptr<grpc::Service> canvas_grpc_service_;
121 std::unique_ptr<grpc::Service> test_harness_grpc_wrapper_;
122 std::vector<std::unique_ptr<grpc::Service>> extra_services_;
126 absl::Status BuildServer();
127 void ReleaseRegisteredServices();