Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Bool.hpp
1
#pragma once
2
3
#include "util/Assert.hpp"
4
#include "util/prometheus/Gauge.hpp"
5
6
#include <cstdint>
7
#include <functional>
8
12
namespace
util::prometheus
{
13
19
template
<
typename
T>
20
concept
SomeBoolImpl
=
requires
(T a) {
21
{ a.set(0) } -> std::same_as<void>;
22
{ a.value() } -> std::same_as<int64_t>;
23
};
24
31
template
<SomeBoolImpl ImplType>
32
class
AnyBool
{
33
std::reference_wrapper<ImplType> impl_;
34
35
public
:
41
explicit
AnyBool
(ImplType& impl) : impl_(impl)
42
{
43
}
44
51
AnyBool
&
52
operator=
(
bool
value)
53
{
54
impl_.get().set(value ? 1 : 0);
55
return
*
this
;
56
}
57
63
operator
bool()
const
64
{
65
auto
const
value = impl_.get().value();
66
ASSERT(value == 0 || value == 1,
"Invalid value for bool: {}"
, value);
67
return
value == 1;
68
}
69
};
70
74
using
Bool
=
AnyBool<GaugeInt>
;
75
76
}
// namespace util::prometheus
util::prometheus::AnyBool
A wrapped to provide bool interface for a Prometheus metric.
Definition
Bool.hpp:32
util::prometheus::AnyBool::AnyBool
AnyBool(ImplType &impl)
Construct a bool metric.
Definition
Bool.hpp:41
util::prometheus::AnyBool::operator=
AnyBool & operator=(bool value)
Set the value of the bool metric.
Definition
Bool.hpp:52
util::prometheus::SomeBoolImpl
Specifies an integer metric implementation that can back AnyBool (e.g. GaugeInt).
Definition
Bool.hpp:20
util::prometheus
Prometheus metrics: counters, gauges, histograms and their registry and serialization.
Definition
Bool.hpp:12
util::prometheus::Bool
AnyBool< GaugeInt > Bool
Alias for Prometheus bool metric with GaugeInt implementation.
Definition
Bool.hpp:74
src
util
prometheus
Bool.hpp
Generated by
1.17.0