rippled
Loading...
Searching...
No Matches
Consumer.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_CONSUMER_H_INCLUDED
21#define RIPPLE_RESOURCE_CONSUMER_H_INCLUDED
22
23#include <xrpl/basics/Log.h>
24#include <xrpl/protocol/PublicKey.h>
25#include <xrpl/resource/Charge.h>
26#include <xrpl/resource/Disposition.h>
27
28namespace ripple {
29namespace Resource {
30
31struct Entry;
32class Logic;
33
36{
37private:
38 friend class Logic;
39 Consumer(Logic& logic, Entry& entry);
40
41public:
42 Consumer();
43 ~Consumer();
44 Consumer(Consumer const& other);
46 operator=(Consumer const& other);
47
50 to_string() const;
51
53 bool
54 isUnlimited() const;
55
59 void
60 elevate(std::string const& name);
61
67 disposition() const;
68
71 charge(Charge const& fee, std::string const& context = {});
72
76 bool
77 warn();
78
80 bool
81 disconnect(beast::Journal const& j);
82
84 int
85 balance();
86
87 // Private: Retrieve the entry associated with the consumer
88 Entry&
89 entry();
90
91 void
92 setPublicKey(PublicKey const& publicKey);
93
94private:
97};
98
100operator<<(std::ostream& os, Consumer const& v);
101
102} // namespace Resource
103} // namespace ripple
104
105#endif
A generic endpoint for log messages.
Definition Journal.h:60
A public key.
Definition PublicKey.h:62
A consumption charge.
Definition Charge.h:30
An endpoint that consumes resources.
Definition Consumer.h:36
bool warn()
Returns true if the consumer should be warned.
Definition Consumer.cpp:117
Consumer & operator=(Consumer const &other)
Definition Consumer.cpp:61
int balance()
Returns the credit balance representing consumption.
Definition Consumer.cpp:137
std::string to_string() const
Return a human readable string uniquely identifying this consumer.
Definition Consumer.cpp:78
bool disconnect(beast::Journal const &j)
Returns true if the consumer should be disconnected.
Definition Consumer.cpp:124
Disposition charge(Charge const &fee, std::string const &context={})
Apply a load charge to the consumer.
Definition Consumer.cpp:106
void setPublicKey(PublicKey const &publicKey)
Definition Consumer.cpp:152
bool isUnlimited() const
Returns true if this is a privileged endpoint.
Definition Consumer.cpp:87
Disposition disposition() const
Returns the current disposition of this consumer.
Definition Consumer.cpp:96
void elevate(std::string const &name)
Raise the Consumer's privilege level to a Named endpoint.
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition Charge.cpp:56
Disposition
The disposition of a consumer after applying a load charge.
Definition Disposition.h:27
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25