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
string_list
,
45
};
46
48
std::string_view
to_string
(
ParameterType
type);
49
54
using
ParameterDefault
=
55
std::variant<std::monostate, double, long long, bool, std::string>;
56
58
struct
ParameterDescriptor
{
62
std::string
key
;
63
ParameterType
type
=
ParameterType::number
;
65
std::string
label
;
67
std::string
description
;
68
ParameterDefault
default_value
;
71
std::optional<double>
minimum
;
72
std::optional<double>
maximum
;
78
bool
presence_sensitive
=
false
;
82
bool
required
=
false
;
83
};
84
86
const
std::vector<ParameterDescriptor> &
stage_parameters
(
JobStage
stage);
87
91
inline
constexpr
std::string_view
kDefaultSemanticCloud
=
"labels"
;
93
inline
constexpr
std::string_view
kDefaultInstanceCloud
=
"instances"
;
94
95
}
// namespace reusex::pipeline
reusex::pipeline
Definition
job_types.hpp:24
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:93
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:91
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::ParameterType::string_list
@ string_list
JSON array of strings.
Definition
stage_parameters.hpp:44
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:43
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:54
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:58
reusex::pipeline::ParameterDescriptor::key
std::string key
The JSON key run_stage() reads.
Definition
stage_parameters.hpp:62
reusex::pipeline::ParameterDescriptor::required
bool required
True when a job without this key (or, for a list, with an empty one) is refused as invalid: there is ...
Definition
stage_parameters.hpp:82
reusex::pipeline::ParameterDescriptor::default_value
ParameterDefault default_value
Definition
stage_parameters.hpp:68
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:78
reusex::pipeline::ParameterDescriptor::description
std::string description
One-line explanation, mirroring the CLI help for the equivalent flag.
Definition
stage_parameters.hpp:67
reusex::pipeline::ParameterDescriptor::type
ParameterType type
Definition
stage_parameters.hpp:63
reusex::pipeline::ParameterDescriptor::label
std::string label
Short human label for a form field.
Definition
stage_parameters.hpp:65
reusex::pipeline::ParameterDescriptor::maximum
std::optional< double > maximum
Definition
stage_parameters.hpp:72
reusex::pipeline::ParameterDescriptor::minimum
std::optional< double > minimum
Inclusive bounds, mirroring the CLI's CLI::Range checks where one exists.
Definition
stage_parameters.hpp:71
libs
reusex
include
pipeline
stage_parameters.hpp
Generated by
1.18.0