rippled
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 <ripple/beast/insight/GaugeImpl.h>
24 
25 #include <memory>
26 
27 namespace beast {
28 namespace insight {
29 
39 class Gauge final
40 {
41 public:
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
85  increment(difference_type amount) const
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&
106  operator++() 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&
120  operator--() 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 
140 private:
142 };
143 
144 } // namespace insight
145 } // namespace beast
146 
147 #endif
std::shared_ptr
STL class.
beast::insight::Gauge::Gauge
Gauge()
Create a null metric.
Definition: Gauge.h:48
beast::insight::Gauge::increment
void increment(difference_type amount) const
Adjust the value of the gauge.
Definition: Gauge.h:85
beast::insight::Gauge::operator--
Gauge const & operator--() const
Definition: Gauge.h:120
beast::insight::GaugeImpl::value_type
std::uint64_t value_type
Definition: GaugeImpl.h:34
beast::insight::Gauge::operator++
Gauge const & operator++(int) const
Definition: Gauge.h:113
beast::insight::Gauge::m_impl
std::shared_ptr< GaugeImpl > m_impl
Definition: Gauge.h:141
beast::insight::Gauge::operator-=
Gauge const & operator-=(difference_type amount) const
Definition: Gauge.h:99
beast::insight::Gauge::operator++
Gauge const & operator++() const
Definition: Gauge.h:106
std::uint64_t
memory
beast::insight::Gauge
A metric for measuring an integral value.
Definition: Gauge.h:39
beast::insight::Gauge::operator=
Gauge const & operator=(value_type value) const
Definition: Gauge.h:75
beast::insight::Gauge::operator+=
Gauge const & operator+=(difference_type amount) const
Definition: Gauge.h:92
beast::insight::Gauge::operator--
Gauge const & operator--(int) const
Definition: Gauge.h:127
beast::insight::Gauge::Gauge
Gauge(std::shared_ptr< GaugeImpl > const &impl)
Create the metric reference the specified implementation.
Definition: Gauge.h:57
beast::insight::Gauge::impl
std::shared_ptr< GaugeImpl > const & impl() const
Definition: Gauge.h:135
beast::insight::GaugeImpl::difference_type
std::int64_t difference_type
Definition: GaugeImpl.h:35
beast::insight::Gauge::set
void set(value_type value) const
Set the value on the gauge.
Definition: Gauge.h:68
beast
Definition: base_uint.h:641