yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
http_server.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_SERVICE_API_HTTP_SERVER_H_
2#define YAZE_SRC_CLI_SERVICE_API_HTTP_SERVER_H_
3
4#include <atomic>
5#include <functional>
6#include <memory>
7#include <string>
8#include <thread>
9
10#include "absl/status/status.h"
12
13namespace httplib {
14class Server;
15}
16
17namespace yaze {
18namespace emu {
19namespace debug {
20class SymbolProvider;
21}
22} // namespace emu
23
24namespace app {
25namespace service {
26class RenderService;
27}
28} // namespace app
29
30class Rom;
31} // namespace yaze
32
33namespace yaze {
34namespace cli {
35namespace api {
36
38 public:
41 using RomSource = std::function<Rom*()>;
42 using ProjectPathSource = std::function<std::string()>;
43 using WindowAction = std::function<bool()>;
44
45 HttpServer();
47
48 // Start the server on the specified port in a background thread.
49 absl::Status Start(int port);
50
51 // Stop the server.
52 void Stop();
53
54 // Check if server is running
55 bool IsRunning() const;
56
57 // Set the source for symbols
59 symbol_source_ = std::move(source);
60 }
61
62 // Set the source for the render service (headless dungeon rendering).
64 render_source_ = std::move(source);
65 }
66
67 // Set the source for ROM context (used by command execution).
68 void SetRomSource(RomSource source) { rom_source_ = std::move(source); }
69
70 // Set the source for project path (used by annotation endpoints).
72 project_path_source_ = std::move(source);
73 }
74
75 // Get current port.
76 int port() const { return port_; }
77
78 // Optional window control hooks (GUI builds only)
80 window_show_ = std::move(show);
81 window_hide_ = std::move(hide);
82 }
83
84 // Get current symbol source
86
87 // Access the Bonjour publisher (e.g. to update ROM title).
89
90 private:
91 void RunServer(int port);
92 void RegisterRoutes();
93
94 std::unique_ptr<httplib::Server> server_;
95 std::unique_ptr<std::thread> server_thread_;
96 std::atomic<bool> is_running_{false};
97 int port_ = 0;
105};
106
107} // namespace api
108} // namespace cli
109} // namespace yaze
110
111#endif // YAZE_SRC_CLI_SERVICE_API_HTTP_SERVER_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
void SetProjectPathSource(ProjectPathSource source)
Definition http_server.h:71
std::unique_ptr< httplib::Server > server_
Definition http_server.h:94
std::function< std::string()> ProjectPathSource
Definition http_server.h:42
BonjourPublisher bonjour_
Definition http_server.h:98
RenderServiceSource render_source_
SymbolProviderSource symbol_source_
Definition http_server.h:99
BonjourPublisher & GetBonjourPublisher()
Definition http_server.h:88
std::function< Rom *()> RomSource
Definition http_server.h:41
SymbolProviderSource GetSymbolSource() const
Definition http_server.h:85
void SetRomSource(RomSource source)
Definition http_server.h:68
std::function< app::service::RenderService *()> RenderServiceSource
Definition http_server.h:40
void SetRenderServiceSource(RenderServiceSource source)
Definition http_server.h:63
absl::Status Start(int port)
ProjectPathSource project_path_source_
std::function< bool()> WindowAction
Definition http_server.h:43
void SetWindowActions(WindowAction show, WindowAction hide)
Definition http_server.h:79
std::function< emu::debug::SymbolProvider *()> SymbolProviderSource
Definition http_server.h:39
void SetSymbolProviderSource(SymbolProviderSource source)
Definition http_server.h:58
std::unique_ptr< std::thread > server_thread_
Definition http_server.h:95
std::atomic< bool > is_running_
Definition http_server.h:96
Provider for symbol (label) resolution in disassembly.