R3BROOT
R3B analysis software
Toggle main menu visibility
Loading...
Searching...
No Matches
R3BMinMaxValue.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <fmt/core.h>
4
#include <nlohmann/json.hpp>
5
#include <nlohmann/json_fwd.hpp>
6
7
namespace
R3B
8
{
9
template
<
typename
DataType>
10
struct
MinMaxValue
11
{
12
MinMaxValue
() =
default
;
13
constexpr
MinMaxValue
(DataType min_val, DataType max_val)
14
:
min
{ min_val }
15
,
max
{ max_val }
16
{
17
}
18
19
DataType
min
{};
20
DataType
max
{};
21
};
22
23
using
MinMaxValueD
=
MinMaxValue<double>
;
24
using
MinMaxValueF
=
MinMaxValue<float>
;
25
using
MinMaxValueI
=
MinMaxValue<int>
;
26
27
template
<
typename
DataType>
28
void
to_json
(nlohmann::ordered_json& json_obj,
const
MinMaxValue<DataType>
& value)
29
{
30
json_obj = nlohmann::ordered_json{ {
"min"
, value.
min
}, {
"max"
, value.
max
} };
31
}
32
33
template
<
typename
DataType>
34
void
from_json
(
const
nlohmann::ordered_json& json_obj,
MinMaxValue<DataType>
& value)
35
{
36
json_obj.at(
"min"
).get_to(value.
min
);
37
json_obj.at(
"max"
).get_to(value.
max
);
38
}
39
40
}
// namespace R3B
41
42
template
<
typename
DataType>
43
class
fmt::formatter<
R3B
::MinMaxValue<DataType>>
44
{
45
public
:
46
static
constexpr
auto
parse
(format_parse_context& ctx) {
return
ctx.end(); }
47
template
<
typename
FmtContent>
48
constexpr
auto
format
(
const
R3B::MinMaxValue<DataType>
& value, FmtContent& ctn)
const
49
{
50
return
fmt::format_to(ctn.out(),
"{{min: {}, max: {}}}"
, value.
min
, value.
max
);
51
}
52
};
fmt::formatter< R3B::MinMaxValue< DataType > >::format
constexpr auto format(const R3B::MinMaxValue< DataType > &value, FmtContent &ctn) const
Definition
R3BMinMaxValue.h:48
fmt::formatter< R3B::MinMaxValue< DataType > >::parse
static constexpr auto parse(format_parse_context &ctx)
Definition
R3BMinMaxValue.h:46
R3B
Definition
R3BNeulandAnalysisApp.cxx:44
R3B::MinMaxValueD
MinMaxValue< double > MinMaxValueD
Definition
R3BMinMaxValue.h:23
R3B::MinMaxValueF
MinMaxValue< float > MinMaxValueF
Definition
R3BMinMaxValue.h:24
R3B::from_json
void from_json(const nlohmann::ordered_json &json_obj, MinMaxValue< DataType > &value)
Definition
R3BMinMaxValue.h:34
R3B::MinMaxValueI
MinMaxValue< int > MinMaxValueI
Definition
R3BMinMaxValue.h:25
R3B::to_json
void to_json(nlohmann::ordered_json &json_obj, const MinMaxValue< DataType > &value)
Definition
R3BMinMaxValue.h:28
R3B::MinMaxValue
Definition
R3BMinMaxValue.h:11
R3B::MinMaxValue::MinMaxValue
constexpr MinMaxValue(DataType min_val, DataType max_val)
Definition
R3BMinMaxValue.h:13
R3B::MinMaxValue::MinMaxValue
MinMaxValue()=default
R3B::MinMaxValue< double >::min
double min
Definition
R3BMinMaxValue.h:19
R3B::MinMaxValue< double >::max
double max
Definition
R3BMinMaxValue.h:20
neuland
shared
R3BMinMaxValue.h
Generated by
1.18.0