xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
beast
insight
Gauge.h
1
#pragma once
2
3
#include <xrpl/beast/insight/GaugeImpl.h>
4
5
#include <
memory
>
6
#include <
utility
>
7
8
namespace
beast::insight
{
9
20
class
Gauge
final
21
{
22
public
:
23
using
value_type
=
GaugeImpl::value_type
;
24
using
difference_type
=
GaugeImpl::difference_type
;
25
30
Gauge
() =
default
;
31
38
explicit
Gauge
(
std::shared_ptr<GaugeImpl>
impl
) :
impl_
(
std
::move(
impl
))
39
{
40
}
41
49
void
50
set
(
value_type
value)
const
51
{
52
if
(
impl_
)
53
impl_
->set(value);
54
}
55
56
// This is a write-through handle: assignment sets the value of the
57
// referenced metric. It is const-qualified and returns Gauge const&
58
// (a non-const Gauge& would require a const_cast), so it does not follow
59
// the conventional assignment-operator signature.
60
// NOLINTNEXTLINE(misc-unconventional-assign-operator)
61
Gauge
const
&
62
operator=
(
value_type
value)
const
63
{
64
set
(value);
65
return
*
this
;
66
}
67
68
73
void
74
increment
(
difference_type
amount)
const
75
{
76
if
(
impl_
)
77
impl_
->increment(amount);
78
}
79
80
Gauge
const
&
81
operator+=
(
difference_type
amount)
const
82
{
83
increment
(amount);
84
return
*
this
;
85
}
86
87
Gauge
const
&
88
operator-=
(
difference_type
amount)
const
89
{
90
increment
(-amount);
91
return
*
this
;
92
}
93
94
Gauge
const
&
95
operator++
()
const
96
{
97
increment
(1);
98
return
*
this
;
99
}
100
101
Gauge
const
&
102
operator++
(
int
)
const
103
{
104
increment
(1);
105
return
*
this
;
106
}
107
108
Gauge
const
&
109
operator--
()
const
110
{
111
increment
(-1);
112
return
*
this
;
113
}
114
115
Gauge
const
&
116
operator--
(
int
)
const
117
{
118
increment
(-1);
119
return
*
this
;
120
}
121
122
123
[[nodiscard]]
std::shared_ptr<GaugeImpl>
const
&
124
impl
()
const
125
{
126
return
impl_
;
127
}
128
129
private
:
130
std::shared_ptr<GaugeImpl>
impl_
;
131
};
132
133
}
// namespace beast::insight
beast::insight::GaugeImpl::value_type
std::uint64_t value_type
Definition
GaugeImpl.h:13
beast::insight::GaugeImpl::difference_type
std::int64_t difference_type
Definition
GaugeImpl.h:14
beast::insight::Gauge
A metric for measuring an integral value.
Definition
Gauge.h:21
beast::insight::Gauge::operator+=
Gauge const & operator+=(difference_type amount) const
Definition
Gauge.h:81
beast::insight::Gauge::impl
std::shared_ptr< GaugeImpl > const & impl() const
Definition
Gauge.h:124
beast::insight::Gauge::Gauge
Gauge()=default
Create a null metric.
beast::insight::Gauge::operator++
Gauge const & operator++() const
Definition
Gauge.h:95
beast::insight::Gauge::set
void set(value_type value) const
Set the value on the gauge.
Definition
Gauge.h:50
beast::insight::Gauge::Gauge
Gauge(std::shared_ptr< GaugeImpl > impl)
Create the metric reference the specified implementation.
Definition
Gauge.h:38
beast::insight::Gauge::value_type
GaugeImpl::value_type value_type
Definition
Gauge.h:23
beast::insight::Gauge::operator=
Gauge const & operator=(value_type value) const
Definition
Gauge.h:62
beast::insight::Gauge::difference_type
GaugeImpl::difference_type difference_type
Definition
Gauge.h:24
beast::insight::Gauge::impl_
std::shared_ptr< GaugeImpl > impl_
Definition
Gauge.h:130
beast::insight::Gauge::operator--
Gauge const & operator--() const
Definition
Gauge.h:109
beast::insight::Gauge::operator++
Gauge const & operator++(int) const
Definition
Gauge.h:102
beast::insight::Gauge::operator-=
Gauge const & operator-=(difference_type amount) const
Definition
Gauge.h:88
beast::insight::Gauge::increment
void increment(difference_type amount) const
Adjust the value of the gauge.
Definition
Gauge.h:74
beast::insight::Gauge::operator--
Gauge const & operator--(int) const
Definition
Gauge.h:116
memory
beast::insight
Definition
Collector.h:13
std
STL namespace.
std::shared_ptr
utility
Generated by
1.17.0