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:
36 
41  SHAMapHash const& hash);
42 
43 public:
44  SHAMapLeafNode(const SHAMapLeafNode&) = delete;
46  operator=(const SHAMapLeafNode&) = delete;
47 
48  bool
49  isLeaf() const final override
50  {
51  return true;
52  }
53 
54  bool
55  isInner() const final override
56  {
57  return false;
58  }
59 
60  void
61  invariants(bool is_root = false) const final override;
62 
63 public:
64  std::shared_ptr<SHAMapItem const> const&
65  peekItem() const;
66 
73  bool
74  setItem(std::shared_ptr<SHAMapItem const> i);
75 
76  std::string
77  getString(SHAMapNodeID const&) const final override;
78 };
79 
80 } // namespace ripple
81 
82 #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:49
std::shared_ptr
STL class.
ripple::SHAMapLeafNode::SHAMapLeafNode
SHAMapLeafNode(std::shared_ptr< SHAMapItem const > item, std::uint32_t cowid)
Definition: SHAMapLeafNode.cpp:26
ripple::SHAMapLeafNode::getString
std::string getString(SHAMapNodeID const &) const final override
Definition: SHAMapLeafNode.cpp:63
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::SHAMapLeafNode::item_
std::shared_ptr< SHAMapItem const > item_
Definition: SHAMapLeafNode.h:35
ripple::SHAMapItem
Definition: SHAMapItem.h:31
ripple::SHAMapLeafNode::isInner
bool isInner() const final override
Determines if this is an inner node.
Definition: SHAMapLeafNode.h:55
ripple::SHAMapTreeNode
Definition: SHAMapTreeNode.h:53
cstdint
std::uint32_t
memory
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
std
STL namespace.
ripple::SHAMapLeafNode::peekItem
std::shared_ptr< SHAMapItem const > const & peekItem() const
Definition: SHAMapLeafNode.cpp:44
ripple::SHAMapLeafNode::setItem
bool setItem(std::shared_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