Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Spec.hpp
1
2//------------------------------------------------------------------------------
3/*
4 This file is part of clio: https://github.com/XRPLF/clio
5 Copyright (c) 2024, the clio developers.
6
7 Permission to use, copy, modify, and distribute this software for any
8 purpose with or without fee is hereby granted, provided that the above
9 copyright notice and this permission notice appear in all copies.
10
11 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18*/
19//==============================================================================
20
21#pragma once
22
23#include "util/newconfig/ObjectView.hpp"
24
25#include <boost/asio/spawn.hpp>
26
27#include <memory>
28#include <string>
29
30namespace migration::impl {
31
35template <typename T, typename Backend>
36concept MigratorSpec = requires(std::shared_ptr<Backend> const& backend, util::config::ObjectView const& cfg) {
37 // Check that 'kNAME' exists and is a string
38 { T::kNAME } -> std::convertible_to<std::string>;
39
40 // Check that 'kDESCRIPTION' exists and is a string
41 { T::kDESCRIPTION } -> std::convertible_to<std::string>;
42
43 // Check that the migrator specifies the backend type it supports
44 typename T::Backend;
45
46 // Check that 'runMigration' exists and is callable
47 { T::runMigration(backend, cfg) } -> std::same_as<void>;
48};
49
53template <typename... Types>
55
56} // namespace migration::impl
Provides a view into a subset of configuration data defined by a prefix.
Definition ObjectView.hpp:40
used by variadic template to check all migrators are MigratorSpec
Definition Spec.hpp:54
The migrator specification concept.
Definition Spec.hpp:36