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