Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
ObjectsAdapter.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, the clio developers.
5
6 Permission to use, copy, modify, and 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#pragma once
21
22#include "data/Types.hpp"
23#include "migration/cassandra/CassandraMigrationBackend.hpp"
24#include "migration/cassandra/impl/FullTableScannerAdapterBase.hpp"
25
26#include <boost/asio/spawn.hpp>
27#include <xrpl/basics/base_uint.h>
28#include <xrpl/protocol/STLedgerEntry.h>
29#include <xrpl/protocol/STObject.h>
30
31#include <cstdint>
32#include <functional>
33#include <memory>
34#include <optional>
35#include <tuple>
36#include <utility>
37
38namespace migration::cassandra::impl {
39
44 using Row = std::tuple<ripple::uint256, std::uint32_t, data::Blob>;
45 static constexpr char const* kPARTITION_KEY = "key";
46 static constexpr char const* kTABLE_NAME = "objects";
47};
48
53class ObjectsAdapter : public impl::FullTableScannerAdapterBase<TableObjectsDesc> {
54public:
55 using OnStateRead = std::function<void(std::uint32_t, std::optional<ripple::SLE>)>;
56
63 explicit ObjectsAdapter(std::shared_ptr<CassandraMigrationBackend> backend, OnStateRead onStateRead)
64 : FullTableScannerAdapterBase<TableObjectsDesc>(backend), onStateRead_{std::move(onStateRead)}
65 {
66 }
67
73 void
74 onRowRead(TableObjectsDesc::Row const& row) override;
75
76private:
77 OnStateRead onStateRead_;
78};
79
80} // namespace migration::cassandra::impl
The adapter for the objects table. This class is responsible for reading the objects from the FullTab...
Definition ObjectsAdapter.hpp:53
ObjectsAdapter(std::shared_ptr< CassandraMigrationBackend > backend, OnStateRead onStateRead)
Construct a new Objects Adapter object.
Definition ObjectsAdapter.hpp:63
void onRowRead(TableObjectsDesc::Row const &row) override
Called when a row is read.
Definition ObjectsAdapter.cpp:31
The base class for the full table scanner adapter. It is responsible for reading the rows from the fu...
Definition FullTableScannerAdapterBase.hpp:40
The description of the objects table. It has to be a TableSpec.
Definition ObjectsAdapter.hpp:43