1#ifndef YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_
2#define YAZE_APP_CORE_SERVICE_UNIFIED_GRPC_SERVER_H_
10#include "absl/status/status.h"
15#include <grpcpp/impl/service_type.h>
16#include <grpcpp/server.h>
24class CanvasAutomationServiceImpl;
36class ProposalApprovalManager;
38class EmulatorServiceImpl;
43class ImGuiTestHarnessServiceImpl;
52 using RomGetter = std::function<Rom*()>;
53 using RomLoader = std::function<bool(
const std::string& path)>;
57 bool enable_test_harness =
true;
58 bool enable_rom_service =
true;
59 bool enable_emulator_service =
true;
60 bool enable_canvas_automation =
true;
61 bool require_approval_for_rom_writes =
true;
79 absl::Status Initialize(
80 int port, emu::IEmulator* emulator =
nullptr,
81 RomGetter rom_getter =
nullptr, RomLoader rom_loader =
nullptr,
82 test::TestManager* test_manager =
nullptr,
83 net::RomVersionManager* version_mgr =
nullptr,
84 net::ProposalApprovalManager* approval_mgr =
nullptr,
85 CanvasAutomationServiceImpl* canvas_service =
nullptr);
88 absl::Status StartAsync();
89 absl::Status AddService(std::unique_ptr<grpc::Service> service);
91 bool IsRunning()
const;
92 int Port()
const {
return config_.port; }
93 void SetConfig(
const Config& config) { config_ = config; }
97 std::unique_ptr<grpc::Server> server_;
100 std::unique_ptr<test::ImGuiTestHarnessServiceImpl> test_harness_service_;
101 std::unique_ptr<net::RomServiceImpl> rom_service_;
102 std::unique_ptr<net::EmulatorServiceImpl> emulator_service_;
103 CanvasAutomationServiceImpl* canvas_service_ =
nullptr;
106 std::unique_ptr<grpc::Service> canvas_grpc_service_;
107 std::unique_ptr<grpc::Service> test_harness_grpc_wrapper_;
108 std::vector<std::unique_ptr<grpc::Service>> extra_services_;
112 absl::Status BuildServer();
113 void ReleaseRegisteredServices();