ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
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
23
namespace
rux::gui
{
24
26
struct
ServerOptions
{
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
59
class
Server
{
60
public
:
65
explicit
Server
(
ServerOptions
options
);
66
~Server
();
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
rux::gui::Server::operator=
Server & operator=(const Server &)=delete
rux::gui::Server::Server
Server(const Server &)=delete
rux::gui::Server::stop
void stop()
Ask a running server to shut down, unblocking run().
rux::gui::Server::has_assets
bool has_assets() const noexcept
True when a frontend bundle was found; false when the placeholder page is being served instead.
rux::gui::Server::Server
Server(ServerOptions options)
Opens the project read-write once (creating/migrating it if needed), then constructs the job runner a...
rux::gui::Server::options
const ServerOptions & options() const noexcept
The resolved options, with asset_dir filled in by the search order.
rux::gui::Server::run
int run()
Serve until SIGINT/SIGTERM or stop(). Returns a process exit code.
rux::gui::Server::~Server
~Server()
rux::gui::Server::url
std::string url() const
Where the server can be reached, e.g. "http://127.0.0.1:8420".
rux::gui
Definition
api.hpp:38
rux::gui::ServerOptions
Everything rux gui needs to stand a server up.
Definition
Server.hpp:26
rux::gui::ServerOptions::threads
unsigned threads
Crow worker threads. 0 means hardware concurrency.
Definition
Server.hpp:40
rux::gui::ServerOptions::bind_address
std::string bind_address
Interface to bind.
Definition
Server.hpp:33
rux::gui::ServerOptions::port
uint16_t port
TCP port.
Definition
Server.hpp:37
rux::gui::ServerOptions::open_browser
bool open_browser
Launch the system browser at the server URL once it is listening.
Definition
Server.hpp:55
rux::gui::ServerOptions::project
std::filesystem::path project
The single project this server is bound to for its lifetime.
Definition
Server.hpp:28
rux::gui::ServerOptions::allowed_origins
std::vector< std::string > allowed_origins
Extra browser origins permitted to call the API, beyond loopback (which is always allowed).
Definition
Server.hpp:48
rux::gui::ServerOptions::asset_dir
std::filesystem::path asset_dir
Frontend bundle directory.
Definition
Server.hpp:52
apps
rux
include
gui
Server.hpp
Generated by
1.17.0