rippled
Loading...
Searching...
No Matches
Charge.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
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 RIPPLE_RESOURCE_CHARGE_H_INCLUDED
21#define RIPPLE_RESOURCE_CHARGE_H_INCLUDED
22
23#include <ios>
24#include <string>
25
26namespace ripple {
27namespace Resource {
28
30class Charge
31{
32public:
34 using value_type = int;
35
36 // A default constructed Charge has no way to get a label. Delete
37 Charge() = delete;
38
41
43 std::string const&
44 label() const;
45
48 cost() const;
49
52 to_string() const;
53
54 bool
55 operator==(Charge const&) const;
56
58 operator<=>(Charge const&) const;
59
60 Charge
61 operator*(value_type m) const;
62
63private:
66};
67
69operator<<(std::ostream& os, Charge const& v);
70
71} // namespace Resource
72} // namespace ripple
73
74#endif
A consumption charge.
Definition: Charge.h:31
int value_type
The type used to hold a consumption charge.
Definition: Charge.h:34
Charge operator*(value_type m) const
Definition: Charge.cpp:75
std::string m_label
Definition: Charge.h:65
value_type m_cost
Definition: Charge.h:64
std::string to_string() const
Converts this charge into a human readable string.
Definition: Charge.cpp:48
bool operator==(Charge const &) const
Definition: Charge.cpp:63
value_type cost() const
Return the cost of the charge in Resource::Manager units.
Definition: Charge.cpp:42
std::strong_ordering operator<=>(Charge const &) const
Definition: Charge.cpp:69
std::string const & label() const
Return the human readable label associated with the charge.
Definition: Charge.cpp:36
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition: Charge.cpp:56
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26