xref: /freebsd/contrib/llvm-project/lldb/include/lldb/API/SBProgress.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===-- SBProgress.h --------------------------------------------*- C++ -*-===//
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 #ifndef LLDB_API_SBPROGRESS_H
10 #define LLDB_API_SBPROGRESS_H
11 
12 #include "lldb/API/SBDebugger.h"
13 #include "lldb/API/SBDefines.h"
14 
15 namespace lldb {
16 
17 /// A Progress indicator helper class.
18 ///
19 /// Any potentially long running sections of code in LLDB should report
20 /// progress so that clients are aware of delays that might appear during
21 /// debugging. Delays commonly include indexing debug information, parsing
22 /// symbol tables for object files, downloading symbols from remote
23 /// repositories, and many more things.
24 ///
25 /// The Progress class helps make sure that progress is correctly reported
26 /// and will always send an initial progress update, updates when
27 /// Progress::Increment() is called, and also will make sure that a progress
28 /// completed update is reported even if the user doesn't explicitly cause one
29 /// to be sent.
30 class LLDB_API SBProgress {
31 public:
32   /// Construct a progress object with a title, details and a given debugger.
33   /// \param title
34   ///   The title of the progress object.
35   /// \param details
36   ///   The details of the progress object.
37   /// \param debugger
38   ///   The debugger for this progress object to report to.
39   SBProgress(const char *title, const char *details, SBDebugger &debugger);
40 
41   /// Construct a progress object with a title, details, the total units of work
42   /// to be done, and a given debugger.
43   /// \param title
44   ///   The title of the progress object.
45   /// \param details
46   ///   The details of the progress object.
47   /// \param total_units
48   ///   The total number of units of work to be done.
49   /// \param debugger
50   ///   The debugger for this progress object to report to.
51   SBProgress(const char *title, const char *details, uint64_t total_units,
52              SBDebugger &debugger);
53 
54 #ifndef SWIG
55   SBProgress(SBProgress &&rhs);
56 #endif
57 
58   ~SBProgress();
59 
60   void Increment(uint64_t amount, const char *description = nullptr);
61 
62   /// Explicitly finalize an SBProgress, this can be used to terminate a
63   /// progress on command instead of waiting for a garbage collection or other
64   /// RAII to destroy the contained progress object.
65   void Finalize();
66 
67 protected:
68   lldb_private::Progress &ref() const;
69 
70 private:
71   SBProgress(const SBProgress &rhs) = delete;
72   const SBProgress &operator=(const SBProgress &rhs) = delete;
73 
74   std::unique_ptr<lldb_private::Progress> m_opaque_up;
75 }; // SBProgress
76 } // namespace lldb
77 
78 #endif // LLDB_API_SBPROGRESS_H
79