xrpld
Loading...
Searching...
No Matches
Charge.h
1#pragma once
2
3#include <compare>
4#include <ostream>
5#include <string>
6
7namespace xrpl::resource {
8
12class Charge
13{
14public:
18 using value_type = int;
19
20 // A default constructed Charge has no way to get a label. Delete
21 Charge() = delete;
22
27
31 [[nodiscard]] std::string const&
32 label() const;
33
37 [[nodiscard]] value_type
38 cost() const;
39
43 [[nodiscard]] std::string
44 toString() const;
45
46 bool
47 operator==(Charge const&) const;
48
50 operator<=>(Charge const&) const;
51
52 Charge
53 operator*(value_type m) const;
54
55private:
58};
59
61operator<<(std::ostream& os, Charge const& v);
62
63} // namespace xrpl::resource
A consumption charge.
Definition Charge.h:13
std::strong_ordering operator<=>(Charge const &) const
Definition Charge.cpp:49
bool operator==(Charge const &) const
Definition Charge.cpp:43
int value_type
The type used to hold a consumption charge.
Definition Charge.h:18
std::string const & label() const
Return the human readable label associated with the charge.
Definition Charge.cpp:16
std::string label_
Definition Charge.h:57
std::string toString() const
Converts this charge into a human readable string.
Definition Charge.cpp:28
Charge operator*(value_type m) const
Definition Charge.cpp:55
value_type cost() const
Return the cost of the charge in resource::Manager units.
Definition Charge.cpp:22
value_type cost_
Definition Charge.h:56
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition Charge.cpp:36