rippled
Loading...
Searching...
No Matches
Gauge.h
1#pragma once
2
3#include <xrpl/beast/insight/GaugeImpl.h>
4
5#include <memory>
6
7namespace beast {
8namespace insight {
9
19class Gauge final
20{
21public:
24
29 {
30 }
31
38 {
39 }
40
47 void
48 set(value_type value) const
49 {
50 if (m_impl)
51 m_impl->set(value);
52 }
53
54 Gauge const&
55 operator=(value_type value) const
56 {
57 set(value);
58 return *this;
59 }
64 void
66 {
67 if (m_impl)
68 m_impl->increment(amount);
69 }
70
71 Gauge const&
73 {
74 increment(amount);
75 return *this;
76 }
77
78 Gauge const&
80 {
81 increment(-amount);
82 return *this;
83 }
84
85 Gauge const&
86 operator++() const
87 {
88 increment(1);
89 return *this;
90 }
91
92 Gauge const&
93 operator++(int) const
94 {
95 increment(1);
96 return *this;
97 }
98
99 Gauge const&
101 {
102 increment(-1);
103 return *this;
104 }
105
106 Gauge const&
107 operator--(int) const
108 {
109 increment(-1);
110 return *this;
111 }
115 impl() const
116 {
117 return m_impl;
118 }
119
120private:
122};
123
124} // namespace insight
125} // namespace beast
std::uint64_t value_type
Definition GaugeImpl.h:14
std::int64_t difference_type
Definition GaugeImpl.h:15
A metric for measuring an integral value.
Definition Gauge.h:20
Gauge const & operator+=(difference_type amount) const
Definition Gauge.h:72
std::shared_ptr< GaugeImpl > const & impl() const
Definition Gauge.h:115
Gauge const & operator++() const
Definition Gauge.h:86
void set(value_type value) const
Set the value on the gauge.
Definition Gauge.h:48
Gauge(std::shared_ptr< GaugeImpl > const &impl)
Create the metric reference the specified implementation.
Definition Gauge.h:37
Gauge const & operator=(value_type value) const
Definition Gauge.h:55
Gauge const & operator--() const
Definition Gauge.h:100
Gauge const & operator++(int) const
Definition Gauge.h:93
Gauge const & operator-=(difference_type amount) const
Definition Gauge.h:79
std::shared_ptr< GaugeImpl > m_impl
Definition Gauge.h:121
void increment(difference_type amount) const
Adjust the value of the gauge.
Definition Gauge.h:65
Gauge const & operator--(int) const
Definition Gauge.h:107
Gauge()
Create a null metric.
Definition Gauge.h:28