libwreport 3.40
options.h
Go to the documentation of this file.
1#ifndef WREPORT_OPTIONS_H
2#define WREPORT_OPTIONS_H
3
4#include <cstdint>
5#include <wreport/fwd.h>
6
24#define WREPORT_OPTIONS_HAS_VAR_CLAMP_DOMAIN_ERRORS
25#define WREPORT_OPTIONS_HAS_VAR_HOOK_DOMAIN_ERRORS
26
27namespace wreport {
28namespace options {
29
36extern thread_local bool var_silent_domain_errors;
37
45extern thread_local bool var_clamp_domain_errors;
46
52{
53 virtual ~DomainErrorHook();
54 virtual void handle_domain_error_int(Var& var, int32_t val) = 0;
55 virtual void handle_domain_error_double(Var& var, double val) = 0;
56};
57
65extern thread_local DomainErrorHook* var_hook_domain_errors;
66
68{
69 int value;
70
71public:
73 static const int NONE = 0;
75 static const int NEWEST = -1;
76
79
81 // cppcheck-suppress noExplicitConstructor; This is intending to pose as an
82 // integer value
84
89 operator=(const MasterTableVersionOverride&) = default;
91 operator=(MasterTableVersionOverride&&) = default;
92
94 operator int() const { return value; }
95};
96
101extern thread_local MasterTableVersionOverride
102 var_master_table_version_override;
103
119template <typename T, typename T1 = T> struct LocalOverride
120{
121 T old_value;
122 T& param;
123
124 LocalOverride(T& param, T1 new_value) : old_value(param), param(param)
125 {
126 param = new_value;
127 }
128 ~LocalOverride() { param = old_value; }
129};
130
131template <typename T, typename T1 = T>
132static inline LocalOverride<T> local_override(T& param, T1 new_value)
133{
134 return LocalOverride<T>(param, new_value);
135}
136
137} // namespace options
138} // namespace wreport
139
140#endif
A physical variable.
Definition var.h:25
MasterTableVersionOverride(int value)
Initialize from a value.
static const int NEWEST
Use the latest available master table number.
Definition options.h:75
MasterTableVersionOverride()
Initialize from environment.
static const int NONE
No override.
Definition options.h:73
String functions.
Definition benchmark.h:13
thread_local DomainErrorHook * var_hook_domain_errors
If set, delegate handling domain errors to this object.
Interface for a callback hook system to delegate handling domain errors to the code using wreport.
Definition options.h:52
Temporarily override a variable while this object is in scope.
Definition options.h:120