rippled
ripple
resource
impl
Key.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_KEY_H_INCLUDED
21
#define RIPPLE_RESOURCE_KEY_H_INCLUDED
22
23
#include <ripple/beast/net/IPEndpoint.h>
24
#include <ripple/resource/impl/Kind.h>
25
#include <
cassert
>
26
27
namespace
ripple
{
28
namespace
Resource {
29
30
// The consumer key
31
struct
Key
32
{
33
Kind
kind
;
34
beast::IP::Endpoint
address
;
35
36
Key
() =
delete
;
37
38
Key
(
Kind
k,
beast::IP::Endpoint
const
& addr) :
kind
(k),
address
(addr)
39
{
40
}
41
42
struct
hasher
43
{
44
std::size_t
45
operator()
(
Key
const
& v)
const
46
{
47
return
m_addr_hash
(v.
address
);
48
}
49
50
private
:
51
beast::uhash<>
m_addr_hash
;
52
};
53
54
struct
key_equal
55
{
56
explicit
key_equal
() =
default
;
57
58
bool
59
operator()
(
Key
const
& lhs,
Key
const
& rhs)
const
60
{
61
return
lhs.
kind
== rhs.
kind
&& lhs.
address
== rhs.
address
;
62
}
63
64
private
:
65
};
66
};
67
68
}
// namespace Resource
69
}
// namespace ripple
70
71
#endif
ripple::Resource::Key::Key
Key(Kind k, beast::IP::Endpoint const &addr)
Definition:
Key.h:38
ripple::Resource::Kind
Kind
Kind of consumer.
Definition:
Kind.h:34
ripple::Resource::Key::key_equal::operator()
bool operator()(Key const &lhs, Key const &rhs) const
Definition:
Key.h:59
ripple::Resource::Key::kind
Kind kind
Definition:
Key.h:33
ripple::Resource::Key::key_equal
Definition:
Key.h:54
ripple::Resource::Key
Definition:
Key.h:31
ripple::Resource::Key::hasher
Definition:
Key.h:42
ripple::Resource::Key::hasher::operator()
std::size_t operator()(Key const &v) const
Definition:
Key.h:45
ripple::Resource::Key::address
beast::IP::Endpoint address
Definition:
Key.h:34
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::Resource::Key::hasher::m_addr_hash
beast::uhash m_addr_hash
Definition:
Key.h:51
ripple::Resource::Key::Key
Key()=delete
cassert
std::size_t
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition:
IPEndpoint.h:38
beast::uhash<>
ripple::Resource::Key::key_equal::key_equal
key_equal()=default
Generated by
1.8.17