options.h
Go to the documentation of this file.
#ifndef WREPORT_OPTIONS_H
#define WREPORT_OPTIONS_H
#include <cstdint>
#define WREPORT_OPTIONS_HAS_VAR_CLAMP_DOMAIN_ERRORS
#define WREPORT_OPTIONS_HAS_VAR_HOOK_DOMAIN_ERRORS
namespace wreport {
class Var;
namespace options {
extern thread_local bool var_silent_domain_errors;
extern thread_local bool var_clamp_domain_errors;
struct DomainErrorHook
{
virtual ~DomainErrorHook();
virtual void handle_domain_error_int(Var& var, int32_t val) = 0;
virtual void handle_domain_error_double(Var& var, double val) = 0;
};
extern thread_local DomainErrorHook* var_hook_domain_errors;
template<typename T, typename T1 = T>
struct LocalOverride
{
T old_value;
T& param;
LocalOverride(T& param, T1 new_value)
: old_value(param), param(param)
{
param = new_value;
}
~LocalOverride()
{
param = old_value;
}
};
template<typename T, typename T1 = T> static inline LocalOverride<T> local_override(T& param, T1 new_value)
{
return LocalOverride<T>(param, new_value);
}
}
}
#endif
wreport::Var
A physical variable.
Definition var.h:25
wreport
String functions.
Definition benchmark.h:13
wreport::options::var_hook_domain_errors
DomainErrorHook * var_hook_domain_errors
If set, delegate handling domain errors to this object.
wreport::options::DomainErrorHook
Interface for a callback hook system to delegate handling domain errors to the code using wreport.
Definition options.h:53
wreport::options::LocalOverride
Temporarily override a variable while this object is in scope.
Definition options.h:85