LeechCraft 0.6.70-17335-ge406ffdcaf
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
consistencychecker.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <memory>
12#include <variant>
13#include <QObject>
14#include "dbconfig.h"
15
16template<typename>
17class QFuture;
18
19template<typename>
21
22namespace LC::Util
23{
24 class UTIL_DB_API ConsistencyChecker : public QObject
25 , public std::enable_shared_from_this<ConsistencyChecker>
26 {
27 const QString DBPath_;
28 const QString DialogContext_;
29
30 friend class FailedImpl;
31
32 ConsistencyChecker (QString dbPath, QString dialogContext, QObject* = nullptr);
33 public:
34 static std::shared_ptr<ConsistencyChecker> Create (QString dbPath, QString dialogContext);
35
37 {
40 };
41 struct DumpError
42 {
43 QString Error_;
44 };
45 using DumpResult_t = std::variant<DumpFinished, DumpError>;
46
47 struct Succeeded {};
48 struct IFailed
49 {
51
52 // Not having a virtual dtor here is fine, since its subclasses will
53 // only be deleted through a shared_ptr, which remembers the exact
54 // type of the constructed object.
55 };
56 using Failed = std::shared_ptr<IFailed>;
57
58 using CheckResult_t = std::variant<Succeeded, Failed>;
59
61 private:
62 CheckResult_t CheckDB ();
63
64 QFuture<DumpResult_t> DumpReinit ();
65 void DumpReinitImpl (QFutureInterface<DumpResult_t>);
66
67 void HandleDumperFinished (QFutureInterface<DumpResult_t>, const QString&);
68 };
69}
QFuture< CheckResult_t > StartCheck()
std::variant< Succeeded, Failed > CheckResult_t
static std::shared_ptr< ConsistencyChecker > Create(QString dbPath, QString dialogContext)
std::variant< DumpFinished, DumpError > DumpResult_t
std::shared_ptr< IFailed > Failed
#define UTIL_DB_API
Definition dbconfig.h:16
virtual QFuture< DumpResult_t > DumpReinit()=0