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