ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
Server.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
7// The `rux gui` HTTP + WebSocket server (#265, Phase 1).
8//
9// Implements docs/gui/openapi.yaml over one `.rux` project, serves the frontend
10// bundle as static files, and streams pipeline job progress over
11// /api/v1/events.
12//
13// Crow is an implementation detail: this header is pimpl'd so crow.h never
14// reaches the rest of the app or the tests. The handler logic itself lives in
15// gui/api.hpp, which is framework-free.
16
17#include <cstdint>
18#include <filesystem>
19#include <memory>
20#include <string>
21#include <vector>
22
23namespace rux::gui {
24
28 std::filesystem::path project;
29
33 std::string bind_address = "127.0.0.1";
34
37 uint16_t port = 8420;
38
40 unsigned threads = 0;
41
48 std::vector<std::string> allowed_origins;
49
52 std::filesystem::path asset_dir;
53
55 bool open_browser = true;
56};
57
59class Server {
60 public:
67
68 Server(const Server &) = delete;
69 Server &operator=(const Server &) = delete;
70
72 const ServerOptions &options() const noexcept;
73
75 std::string url() const;
76
79 bool has_assets() const noexcept;
80
82 int run();
83
91 void stop();
92
93 private:
94 class Impl;
95 std::unique_ptr<Impl> impl_;
96};
97
98} // namespace rux::gui
Server & operator=(const Server &)=delete
Server(const Server &)=delete
void stop()
Ask a running server to shut down, unblocking run().
bool has_assets() const noexcept
True when a frontend bundle was found; false when the placeholder page is being served instead.
Server(ServerOptions options)
Opens the project read-write once (creating/migrating it if needed), then constructs the job runner a...
const ServerOptions & options() const noexcept
The resolved options, with asset_dir filled in by the search order.
int run()
Serve until SIGINT/SIGTERM or stop(). Returns a process exit code.
std::string url() const
Where the server can be reached, e.g. "http://127.0.0.1:8420".
Everything rux gui needs to stand a server up.
Definition Server.hpp:26
unsigned threads
Crow worker threads. 0 means hardware concurrency.
Definition Server.hpp:40
std::string bind_address
Interface to bind.
Definition Server.hpp:33
uint16_t port
TCP port.
Definition Server.hpp:37
bool open_browser
Launch the system browser at the server URL once it is listening.
Definition Server.hpp:55
std::filesystem::path project
The single project this server is bound to for its lifetime.
Definition Server.hpp:28
std::vector< std::string > allowed_origins
Extra browser origins permitted to call the API, beyond loopback (which is always allowed).
Definition Server.hpp:48
std::filesystem::path asset_dir
Frontend bundle directory.
Definition Server.hpp:52