ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
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
35
namespace
reusex::pipeline
{
36
38
enum class
ParameterType
{
39
number
,
40
integer
,
41
boolean
,
42
string
,
43
integer_list
,
44
};
45
47
std::string_view
to_string
(
ParameterType
type);
48
53
using
ParameterDefault
=
54
std::variant<std::monostate, double, long long, bool, std::string>;
55
57
struct
ParameterDescriptor
{
61
std::string
key
;
62
ParameterType
type
=
ParameterType::number
;
64
std::string
label
;
66
std::string
description
;
67
ParameterDefault
default_value
;
70
std::optional<double>
minimum
;
71
std::optional<double>
maximum
;
77
bool
presence_sensitive
=
false
;
78
};
79
81
const
std::vector<ParameterDescriptor> &
stage_parameters
(
JobStage
stage);
82
86
inline
constexpr
std::string_view
kDefaultSemanticCloud
=
"labels"
;
88
inline
constexpr
std::string_view
kDefaultInstanceCloud
=
"instances"
;
89
90
}
// namespace reusex::pipeline
reusex::pipeline
Definition
JobRunner.hpp:45
reusex::pipeline::kDefaultInstanceCloud
constexpr std::string_view kDefaultInstanceCloud
Name of the cloud instances writes when the job does not say otherwise.
Definition
stage_parameters.hpp:88
reusex::pipeline::kDefaultSemanticCloud
constexpr std::string_view kDefaultSemanticCloud
Name of the semantic-label cloud instances reads when the job does not say otherwise.
Definition
stage_parameters.hpp:86
reusex::pipeline::ParameterType
ParameterType
Wire type of a stage parameter, i.e. what JSON a caller should send.
Definition
stage_parameters.hpp:38
reusex::pipeline::ParameterType::integer_list
@ integer_list
JSON array of non-negative integers.
Definition
stage_parameters.hpp:43
reusex::pipeline::ParameterType::integer
@ integer
JSON number, integral.
Definition
stage_parameters.hpp:40
reusex::pipeline::ParameterType::boolean
@ boolean
JSON true/false.
Definition
stage_parameters.hpp:41
reusex::pipeline::ParameterType::number
@ number
JSON number, fractional (float in the option struct).
Definition
stage_parameters.hpp:39
reusex::pipeline::ParameterType::string
@ string
JSON string.
Definition
stage_parameters.hpp:42
reusex::pipeline::to_string
std::string_view to_string(JobStatus status)
Canonical lower-case status name used on the wire.
reusex::pipeline::JobStage
JobStage
A pipeline stage that can be executed as a job.
Definition
stages.hpp:42
reusex::pipeline::ParameterDefault
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.
Definition
stage_parameters.hpp:53
reusex::pipeline::stage_parameters
const std::vector< ParameterDescriptor > & stage_parameters(JobStage stage)
Every parameter stage recognises, in form-display order.
reusex::pipeline::ParameterDescriptor
One knob of one stage.
Definition
stage_parameters.hpp:57
reusex::pipeline::ParameterDescriptor::key
std::string key
The JSON key run_stage() reads.
Definition
stage_parameters.hpp:61
reusex::pipeline::ParameterDescriptor::default_value
ParameterDefault default_value
Definition
stage_parameters.hpp:67
reusex::pipeline::ParameterDescriptor::presence_sensitive
bool presence_sensitive
True when the mere PRESENCE of the key changes behaviour, independently of its value (#214): sending ...
Definition
stage_parameters.hpp:77
reusex::pipeline::ParameterDescriptor::description
std::string description
One-line explanation, mirroring the CLI help for the equivalent flag.
Definition
stage_parameters.hpp:66
reusex::pipeline::ParameterDescriptor::type
ParameterType type
Definition
stage_parameters.hpp:62
reusex::pipeline::ParameterDescriptor::label
std::string label
Short human label for a form field.
Definition
stage_parameters.hpp:64
reusex::pipeline::ParameterDescriptor::maximum
std::optional< double > maximum
Definition
stage_parameters.hpp:71
reusex::pipeline::ParameterDescriptor::minimum
std::optional< double > minimum
Inclusive bounds, mirroring the CLI's CLI::Range checks where one exists.
Definition
stage_parameters.hpp:70
libs
reusex
include
pipeline
stage_parameters.hpp
Generated by
1.17.0