rippled
Loading...
Searching...
No Matches
Gauge.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of Beast: https://github.com/vinniefalco/Beast
4 Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef BEAST_INSIGHT_GAUGE_H_INCLUDED
21#define BEAST_INSIGHT_GAUGE_H_INCLUDED
22
23#include <xrpl/beast/insight/GaugeImpl.h>
24
25#include <memory>
26
27namespace beast {
28namespace insight {
29
39class Gauge final
40{
41public:
44
49 {
50 }
51
58 {
59 }
60
67 void
68 set(value_type value) const
69 {
70 if (m_impl)
71 m_impl->set(value);
72 }
73
74 Gauge const&
75 operator=(value_type value) const
76 {
77 set(value);
78 return *this;
79 }
84 void
86 {
87 if (m_impl)
88 m_impl->increment(amount);
89 }
90
91 Gauge const&
93 {
94 increment(amount);
95 return *this;
96 }
97
98 Gauge const&
100 {
101 increment(-amount);
102 return *this;
103 }
104
105 Gauge const&
107 {
108 increment(1);
109 return *this;
110 }
111
112 Gauge const&
113 operator++(int) const
114 {
115 increment(1);
116 return *this;
117 }
118
119 Gauge const&
121 {
122 increment(-1);
123 return *this;
124 }
125
126 Gauge const&
127 operator--(int) const
128 {
129 increment(-1);
130 return *this;
131 }
135 impl() const
136 {
137 return m_impl;
138 }
139
140private:
142};
143
144} // namespace insight
145} // namespace beast
146
147#endif
std::uint64_t value_type
Definition GaugeImpl.h:34
std::int64_t difference_type
Definition GaugeImpl.h:35
A metric for measuring an integral value.
Definition Gauge.h:40
Gauge const & operator+=(difference_type amount) const
Definition Gauge.h:92
std::shared_ptr< GaugeImpl > const & impl() const
Definition Gauge.h:135
Gauge const & operator++() const
Definition Gauge.h:106
void set(value_type value) const
Set the value on the gauge.
Definition Gauge.h:68
Gauge(std::shared_ptr< GaugeImpl > const &impl)
Create the metric reference the specified implementation.
Definition Gauge.h:57
Gauge const & operator=(value_type value) const
Definition Gauge.h:75
Gauge const & operator--() const
Definition Gauge.h:120
Gauge const & operator++(int) const
Definition Gauge.h:113
Gauge const & operator-=(difference_type amount) const
Definition Gauge.h:99
std::shared_ptr< GaugeImpl > m_impl
Definition Gauge.h:141
void increment(difference_type amount) const
Adjust the value of the gauge.
Definition Gauge.h:85
Gauge const & operator--(int) const
Definition Gauge.h:127
Gauge()
Create a null metric.
Definition Gauge.h:48