rippled
SHAMapLeafNode.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_SHAMAP_SHAMAPLEAFNODE_H_INCLUDED
21 #define RIPPLE_SHAMAP_SHAMAPLEAFNODE_H_INCLUDED
22 
23 #include <ripple/shamap/SHAMapItem.h>
24 #include <ripple/shamap/SHAMapNodeID.h>
25 #include <ripple/shamap/SHAMapTreeNode.h>
26 
27 #include <cstdint>
28 #include <memory>
29 
30 namespace ripple {
31 
33 {
34 protected:
35  boost::intrusive_ptr<SHAMapItem const> item_;
36 
38  boost::intrusive_ptr<SHAMapItem const> item,
40 
42  boost::intrusive_ptr<SHAMapItem const> item,
44  SHAMapHash const& hash);
45 
46 public:
47  SHAMapLeafNode(const SHAMapLeafNode&) = delete;
49  operator=(const SHAMapLeafNode&) = delete;
50 
51  bool
52  isLeaf() const final override
53  {
54  return true;
55  }
56 
57  bool
58  isInner() const final override
59  {
60  return false;
61  }
62 
63  void
64  invariants(bool is_root = false) const final override;
65 
66 public:
67  boost::intrusive_ptr<SHAMapItem const> const&
68  peekItem() const;
69 
76  bool
77  setItem(boost::intrusive_ptr<SHAMapItem const> i);
78 
79  std::string
80  getString(SHAMapNodeID const&) const final override;
81 };
82 
83 } // namespace ripple
84 
85 #endif
ripple::SHAMapTreeNode::cowid
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
Definition: SHAMapTreeNode.h:116
ripple::SHAMapLeafNode::isLeaf
bool isLeaf() const final override
Determines if this is a leaf node.
Definition: SHAMapLeafNode.h:52
ripple::SHAMapLeafNode::peekItem
boost::intrusive_ptr< SHAMapItem const > const & peekItem() const
Definition: SHAMapLeafNode.cpp:44
ripple::SHAMapLeafNode::getString
std::string getString(SHAMapNodeID const &) const final override
Definition: SHAMapLeafNode.cpp:63
ripple::SHAMapLeafNode::SHAMapLeafNode
SHAMapLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
Definition: SHAMapLeafNode.cpp:26
boost
Definition: IPAddress.h:103
ripple::SHAMapNodeID
Identifies a node inside a SHAMap.
Definition: SHAMapNodeID.h:33
ripple::SHAMapLeafNode
Definition: SHAMapLeafNode.h:32
ripple::SHAMapHash
Definition: SHAMapHash.h:32
ripple::SHAMapLeafNode::invariants
void invariants(bool is_root=false) const final override
Definition: SHAMapLeafNode.cpp:88
ripple::SHAMapItem
Definition: SHAMapItem.h:34
ripple::SHAMapLeafNode::isInner
bool isInner() const final override
Determines if this is an inner node.
Definition: SHAMapLeafNode.h:58
ripple::SHAMapTreeNode
Definition: SHAMapTreeNode.h:53
cstdint
std::uint32_t
memory
ripple::SHAMapLeafNode::item_
boost::intrusive_ptr< SHAMapItem const > item_
Definition: SHAMapLeafNode.h:35
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
std
STL namespace.
ripple::SHAMapLeafNode::setItem
bool setItem(boost::intrusive_ptr< SHAMapItem const > i)
Set the item that this node points to and update the node's hash.
Definition: SHAMapLeafNode.cpp:50
ripple::SHAMapLeafNode::operator=
SHAMapLeafNode & operator=(const SHAMapLeafNode &)=delete