ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
stage_parameters.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// Machine-readable description of the parameters each runnable stage accepts
8// (#305).
9//
10// `run_stage()` reads a job's `parameters` JSON object with `param_or(params,
11// "<key>", <option-struct field>)`, so the *authority* on what a knob is called
12// and what it defaults to has always been the library option struct. Until now
13// that authority was unreadable from outside: a front end wanting to render a
14// parameter form had no choice but to hard-code the keys and re-type the
15// defaults, which is exactly the duplication STANDARDS §4 forbids.
16//
17// This table closes that hole. It is built by *default-constructing the option
18// struct and reading its fields* — never by copying literals — so a default
19// that moves in `segmentation/` moves here, and in every UI, without anyone
20// remembering to. `tests/unit/pipeline/test_stage_parameters.cpp` asserts that
21// correspondence field by field.
22//
23// Layering: this lives in `pipeline` (Layer 4) because that is where the
24// option structs are already assembled from JSON; `core` could not reach
25// `segmentation` to read the defaults.
26
27#include <reusex/pipeline/stages.hpp>
28
29#include <optional>
30#include <string>
31#include <string_view>
32#include <variant>
33#include <vector>
34
35namespace reusex::pipeline {
36
45
47std::string_view to_string(ParameterType type);
48
54 std::variant<std::monostate, double, long long, bool, std::string>;
55
61 std::string key;
64 std::string label;
66 std::string description;
70 std::optional<double> minimum;
71 std::optional<double> maximum;
77 bool presence_sensitive = false;
78};
79
81const std::vector<ParameterDescriptor> &stage_parameters(JobStage stage);
82
86inline constexpr std::string_view kDefaultSemanticCloud = "labels";
88inline constexpr std::string_view kDefaultInstanceCloud = "instances";
89
90} // namespace reusex::pipeline
constexpr std::string_view kDefaultInstanceCloud
Name of the cloud instances writes when the job does not say otherwise.
constexpr std::string_view kDefaultSemanticCloud
Name of the semantic-label cloud instances reads when the job does not say otherwise.
ParameterType
Wire type of a stage parameter, i.e. what JSON a caller should send.
@ integer_list
JSON array of non-negative integers.
@ integer
JSON number, integral.
@ number
JSON number, fractional (float in the option struct).
std::string_view to_string(JobStatus status)
Canonical lower-case status name used on the wire.
JobStage
A pipeline stage that can be executed as a job.
Definition stages.hpp:42
std::variant< std::monostate, double, long long, bool, std::string > ParameterDefault
The default a parameter takes when the key is absent from the job's parameters object.
const std::vector< ParameterDescriptor > & stage_parameters(JobStage stage)
Every parameter stage recognises, in form-display order.
std::string key
The JSON key run_stage() reads.
bool presence_sensitive
True when the mere PRESENCE of the key changes behaviour, independently of its value (#214): sending ...
std::string description
One-line explanation, mirroring the CLI help for the equivalent flag.
std::string label
Short human label for a form field.
std::optional< double > minimum
Inclusive bounds, mirroring the CLI's CLI::Range checks where one exists.