rippled
Loading...
Searching...
No Matches
STLedgerEntry.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_PROTOCOL_STLEDGERENTRY_H_INCLUDED
21#define RIPPLE_PROTOCOL_STLEDGERENTRY_H_INCLUDED
22
23#include <xrpl/protocol/Indexes.h>
24#include <xrpl/protocol/STObject.h>
25
26namespace ripple {
27
28class Rules;
29namespace test {
30class Invariants_test;
31}
32
33class STLedgerEntry final : public STObject, public CountedObject<STLedgerEntry>
34{
37
38public:
43
45 explicit STLedgerEntry(Keylet const& k);
47 STLedgerEntry(SerialIter& sit, uint256 const& index);
48 STLedgerEntry(SerialIter&& sit, uint256 const& index);
49 STLedgerEntry(STObject const& object, uint256 const& index);
50
52 getSType() const override;
53
55 getFullText() const override;
56
58 getText() const override;
59
61 getJson(JsonOptions options = JsonOptions::none) const override;
62
67 uint256 const&
68 key() const;
69
71 getType() const;
72
73 // is this a ledger entry that can be threaded
74 bool
75 isThreadedType(Rules const& rules) const;
76
77 bool
78 thread(
79 uint256 const& txID,
80 std::uint32_t ledgerSeq,
81 uint256& prevTxID,
82 std::uint32_t& prevLedgerID);
83
84private:
85 /* Make STObject comply with the template for this SLE type
86 Can throw
87 */
88 void
89 setSLEType();
90
91 friend test::Invariants_test; // this test wants access to the private
92 // type_
93
94 STBase*
95 copy(std::size_t n, void* buf) const override;
96 STBase*
97 move(std::size_t n, void* buf) override;
98
99 friend class detail::STVar;
100};
101
103
105 : STLedgerEntry(Keylet(type, key))
106{
107}
108
110 : STLedgerEntry(sit, index)
111{
112}
113
118inline uint256 const&
120{
121 return key_;
122}
123
124inline LedgerEntryType
126{
127 return type_;
128}
129
130} // namespace ripple
131
132#endif
Represents a JSON value.
Definition json_value.h:149
Tracks the number of instances of an object.
Rules controlling protocol behavior.
Definition Rules.h:38
A type which can be exported to a well known binary format.
Definition STBase.h:135
STBase * move(std::size_t n, void *buf) override
STLedgerEntry(Keylet const &k)
Create an empty object with the given key and type.
LedgerEntryType getType() const
SerializedTypeID getSType() const override
std::string getFullText() const override
LedgerEntryType type_
bool thread(uint256 const &txID, std::uint32_t ledgerSeq, uint256 &prevTxID, std::uint32_t &prevLedgerID)
Json::Value getJson(JsonOptions options=JsonOptions::none) const override
STBase * copy(std::size_t n, void *buf) const override
bool isThreadedType(Rules const &rules) const
uint256 const & key() const
Returns the 'key' (or 'index') of this item.
std::string getText() const override
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
SerializedTypeID
Definition SField.h:110
LedgerEntryType
Identifiers for on-ledger objects.
Note, should be treated as flags that can be | and &.
Definition STBase.h:37
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:39