FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
rotation_warning_utils.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2026-present FERS Contributors (see AUTHORS.md).
4//
5// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
6
7#pragma once
8
9#include <cstdint>
10#include <string>
11#include <string_view>
12#include <vector>
13
14#include "core/config.h"
15#include "core/parameters.h"
16
18{
19 /// Kind of rotation value being inspected for unit mistakes.
20 enum class ValueKind : std::uint8_t
21 {
22 Angle, ///< Absolute rotation angle.
23 Rate ///< Rotation rate.
24 };
25
26 /// Confidence level for an inferred rotation unit.
27 enum class Confidence : std::uint8_t
28 {
29 None, ///< No useful inference could be made.
30 Low, ///< Weak evidence for the inferred unit.
31 Medium, ///< Moderate evidence for the inferred unit.
32 High ///< Strong evidence for the inferred unit.
33 };
34
35 /// Minimum confidence threshold for emitting rotation-unit warnings.
36 enum class WarningSensitivity : std::uint8_t
37 {
38 HighConfidence, ///< Warn only on high-confidence mismatches.
39 MediumOrHigh, ///< Warn on medium or high-confidence mismatches.
40 Aggressive ///< Warn on any non-low mismatch.
41 };
42
43 /// Result of inferring likely units from a rotation value.
45 {
47 Confidence confidence = Confidence::None; ///< Confidence for the inferred unit.
48 int degree_score = 0; ///< Heuristic score for degree-like values.
49 int radian_score = 0; ///< Heuristic score for radian-like values.
50 };
51
52 /// Default warning sensitivity used by parser and serializer warnings.
54
55 /// Infers the likely unit of a rotation value.
57
58 /// Returns true when a warning should be emitted for the confidence and sensitivity.
59 bool should_warn(Confidence confidence, WarningSensitivity sensitivity) noexcept;
60
61 /// Clears the thread-local captured rotation warnings.
63
64 /// Returns and clears the thread-local captured rotation warnings.
65 std::vector<std::string> take_captured_warnings();
66
67 /// Emits or captures a warning when a rotation value likely uses the wrong unit.
68 void maybe_warn_about_rotation_value(RealType value, params::RotationAngleUnit declared_unit, ValueKind kind,
69 std::string_view source, std::string_view owner, std::string_view field);
70}
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
RotationAngleUnit
Defines the units used at external rotation-path boundaries.
Definition parameters.h:42
@ Degrees
Compass azimuth and elevation expressed in degrees.
std::vector< std::string > take_captured_warnings()
Returns and clears the thread-local captured rotation warnings.
Confidence
Confidence level for an inferred rotation unit.
@ Low
Weak evidence for the inferred unit.
@ High
Strong evidence for the inferred unit.
@ None
No useful inference could be made.
@ Medium
Moderate evidence for the inferred unit.
InferenceResult infer_unit_from_value(const RealType value, const ValueKind kind) noexcept
Infers the likely unit of a rotation value.
void maybe_warn_about_rotation_value(const RealType value, const params::RotationAngleUnit declared_unit, const ValueKind kind, const std::string_view source, const std::string_view owner, const std::string_view field)
Emits or captures a warning when a rotation value likely uses the wrong unit.
WarningSensitivity
Minimum confidence threshold for emitting rotation-unit warnings.
@ HighConfidence
Warn only on high-confidence mismatches.
@ MediumOrHigh
Warn on medium or high-confidence mismatches.
bool should_warn(const Confidence confidence, const WarningSensitivity sensitivity) noexcept
Returns true when a warning should be emitted for the confidence and sensitivity.
ValueKind
Kind of rotation value being inspected for unit mistakes.
void clear_captured_warnings() noexcept
Clears the thread-local captured rotation warnings.
constexpr WarningSensitivity kWarningSensitivity
Default warning sensitivity used by parser and serializer warnings.
Defines the Parameters struct and provides methods for managing simulation parameters.
math::Vec3 max
Result of inferring likely units from a rotation value.
int degree_score
Heuristic score for degree-like values.
params::RotationAngleUnit inferred_unit
Likely unit for the value.
Confidence confidence
Confidence for the inferred unit.
int radian_score
Heuristic score for radian-like values.