xref: /llvm-project/lldb/source/API/SBProgress.cpp (revision 1f7eb6f403bc0e453b76d9274994d840561e96cf)
1 //===-- SBProgress.cpp --------------------------------------------------*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/API/SBProgress.h"
10 #include "lldb/Core/Progress.h"
11 #include "lldb/Utility/Instrumentation.h"
12 
13 using namespace lldb;
14 
15 SBProgress::SBProgress(const char *title, const char *details,
16                        SBDebugger &debugger) {
17   LLDB_INSTRUMENT_VA(this, title, details, debugger);
18 
19   m_opaque_up = std::make_unique<lldb_private::Progress>(
20       title, details, /*total=*/std::nullopt, debugger.get(),
21       /*minimum_report_time=*/std::nullopt,
22       lldb_private::Progress::Origin::eExternal);
23 }
24 
25 SBProgress::SBProgress(const char *title, const char *details,
26                        uint64_t total_units, SBDebugger &debugger) {
27   LLDB_INSTRUMENT_VA(this, title, details, total_units, debugger);
28 
29   m_opaque_up = std::make_unique<lldb_private::Progress>(
30       title, details, total_units, debugger.get(),
31       /*minimum_report_time=*/std::nullopt,
32       lldb_private::Progress::Origin::eExternal);
33 }
34 
35 SBProgress::SBProgress(SBProgress &&rhs)
36     : m_opaque_up(std::move(rhs.m_opaque_up)) {}
37 
38 SBProgress::~SBProgress() = default;
39 
40 void SBProgress::Increment(uint64_t amount, const char *description) {
41   LLDB_INSTRUMENT_VA(amount, description);
42 
43   m_opaque_up->Increment(amount, description);
44 }
45 
46 lldb_private::Progress &SBProgress::ref() const { return *m_opaque_up; }
47