blob: c4c670c71ab245968df4c5f13d1b5356721d7d1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include "sqlitedatabase.h"
namespace Sqlite {
class ProgressHandler
{
public:
template<typename Callable>
ProgressHandler(Callable &&callable, int operationCount, Database &database)
: m_database{database}
{
std::unique_lock<TransactionInterface> locker{m_database};
m_database.backend().setProgressHandler(operationCount, std::forward<Callable>(callable));
}
~ProgressHandler()
{
std::unique_lock<TransactionInterface> locker{m_database};
m_database.backend().resetProgressHandler();
}
private:
Database &m_database;
};
} // namespace Sqlite
|