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;
29class Invariants_test;
30
31class STLedgerEntry final : public STObject, public CountedObject<STLedgerEntry>
32{
35
36public:
39
41 explicit STLedgerEntry(Keylet const& k);
43 STLedgerEntry(SerialIter& sit, uint256 const& index);
44 STLedgerEntry(SerialIter&& sit, uint256 const& index);
45 STLedgerEntry(STObject const& object, uint256 const& index);
46
48 getSType() const override;
49
51 getFullText() const override;
52
54 getText() const override;
55
57 getJson(JsonOptions options) const override;
58
63 uint256 const&
64 key() const;
65
67 getType() const;
68
69 // is this a ledger entry that can be threaded
70 bool
71 isThreadedType(Rules const& rules) const;
72
73 bool
74 thread(
75 uint256 const& txID,
76 std::uint32_t ledgerSeq,
77 uint256& prevTxID,
78 std::uint32_t& prevLedgerID);
79
80private:
81 /* Make STObject comply with the template for this SLE type
82 Can throw
83 */
84 void
85 setSLEType();
86
87 friend Invariants_test; // this test wants access to the private type_
88
89 STBase*
90 copy(std::size_t n, void* buf) const override;
91 STBase*
92 move(std::size_t n, void* buf) override;
93
94 friend class detail::STVar;
95};
96
98
100 : STLedgerEntry(Keylet(type, key))
101{
102}
103
105 : STLedgerEntry(sit, index)
106{
107}
108
113inline uint256 const&
115{
116 return key_;
117}
118
119inline LedgerEntryType
121{
122 return type_;
123}
124
125} // namespace ripple
126
127#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) 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:107
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