rippled
Loading...
Searching...
No Matches
BookDirs.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2015 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_LEDGER_BOOK_DIRS_H_INCLUDED
21#define RIPPLE_LEDGER_BOOK_DIRS_H_INCLUDED
22
23#include <xrpl/beast/utility/Journal.h>
24#include <xrpl/ledger/ReadView.h>
25
26namespace ripple {
27
29{
30private:
31 ReadView const* view_ = nullptr;
36 unsigned int entry_ = 0;
38
39public:
40 class const_iterator;
42
43 BookDirs(ReadView const&, Book const&);
44
46 begin() const;
47
49 end() const;
50};
51
53{
54public:
56 using pointer = value_type const*;
57 using reference = value_type const&;
60
61 const_iterator() = default;
62
63 bool
64 operator==(const_iterator const& other) const;
65
66 bool
67 operator!=(const_iterator const& other) const
68 {
69 return !(*this == other);
70 }
71
73 operator*() const;
74
76 operator->() const
77 {
78 return &**this;
79 }
80
82 operator++();
83
85 operator++(int);
86
87private:
88 friend class BookDirs;
89
91 ReadView const& view,
92 uint256 const& root,
93 uint256 const& dir_key)
94 : view_(&view), root_(root), key_(dir_key), cur_key_(dir_key)
95 {
96 }
97
98 ReadView const* view_ = nullptr;
104 unsigned int entry_ = 0;
107
109};
110
111} // namespace ripple
112
113#endif
A generic endpoint for log messages.
Definition Journal.h:60
bool operator==(const_iterator const &other) const
Definition BookDirs.cpp:68
const_iterator & operator++()
Definition BookDirs.cpp:94
const_iterator(ReadView const &view, uint256 const &root, uint256 const &dir_key)
Definition BookDirs.h:90
std::optional< value_type > cache_
Definition BookDirs.h:106
value_type const & reference
Definition BookDirs.h:57
static beast::Journal j_
Definition BookDirs.h:108
bool operator!=(const_iterator const &other) const
Definition BookDirs.h:67
value_type const * pointer
Definition BookDirs.h:56
std::shared_ptr< SLE const > sle_
Definition BookDirs.h:103
uint256 const next_quality_
Definition BookDirs.h:33
unsigned int entry_
Definition BookDirs.h:36
ReadView const * view_
Definition BookDirs.h:31
uint256 const root_
Definition BookDirs.h:32
std::shared_ptr< SLE const > sle_
Definition BookDirs.h:35
const_iterator begin() const
Definition BookDirs.cpp:45
std::shared_ptr< SLE const > value_type
Definition BookDirs.h:41
const_iterator end() const
Definition BookDirs.cpp:59
uint256 index_
Definition BookDirs.h:37
uint256 const key_
Definition BookDirs.h:34
Specifies an order book.
Definition Book.h:36
A view into a ledger.
Definition ReadView.h:51
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
Number root(Number f, unsigned d)
Definition Number.cpp:636