rippled
Loading...
Searching...
No Matches
Meter.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_METER_H_INCLUDED
21#define BEAST_INSIGHT_METER_H_INCLUDED
22
23#include <xrpl/beast/insight/MeterImpl.h>
24
25#include <memory>
26
27namespace beast {
28namespace insight {
29
37class Meter final
38{
39public:
41
46 {
47 }
48
55 {
56 }
57
60 void
61 increment(value_type amount) const
62 {
63 if (m_impl)
64 m_impl->increment(amount);
65 }
66
67 Meter const&
68 operator+=(value_type amount) const
69 {
70 increment(amount);
71 return *this;
72 }
73
74 Meter const&
75 operator++() const
76 {
77 increment(1);
78 return *this;
79 }
80
81 Meter const&
82 operator++(int) const
83 {
84 increment(1);
85 return *this;
86 }
90 impl() const
91 {
92 return m_impl;
93 }
94
95private:
97};
98
99} // namespace insight
100} // namespace beast
101
102#endif
std::uint64_t value_type
Definition: MeterImpl.h:34
A metric for measuring an integral value.
Definition: Meter.h:38
void increment(value_type amount) const
Increment the meter.
Definition: Meter.h:61
Meter()
Create a null metric.
Definition: Meter.h:45
std::shared_ptr< MeterImpl > m_impl
Definition: Meter.h:96
Meter(std::shared_ptr< MeterImpl > const &impl)
Create the metric reference the specified implementation.
Definition: Meter.h:54
Meter const & operator++(int) const
Definition: Meter.h:82
Meter const & operator+=(value_type amount) const
Definition: Meter.h:68
Meter const & operator++() const
Definition: Meter.h:75
std::shared_ptr< MeterImpl > const & impl() const
Definition: Meter.h:90