BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
progresshandler.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/model/mvvm/utils/progresshandler.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 
17 using namespace ModelView;
18 
20  : runner_callback(std::move(callback)), max_ticks_count(max_ticks_count)
21 {
22 }
23 
25 {
26  runner_callback = std::move(callback);
27 }
28 
29 //! Sets expected ticks count, representing progress of a computation.
30 
32 {
33  reset();
34  max_ticks_count = value;
35 }
36 
38 {
39  return interrupt_request;
40 }
41 
42 //! Increment number of completed computation steps. Performs callback to inform
43 //! subscriber about current progress (in percents) and retrieves interrupt request flag.
44 
46 {
47  std::unique_lock<std::mutex> lock(mutex);
48  completed_ticks += value;
51  int percentage_done = static_cast<int>(100.0 * completed_ticks / max_ticks_count);
53 }
54 
55 //! Resets progress.
56 
58 {
59  interrupt_request = false;
60  completed_ticks = 0;
61 }
void subscribe(callback_t callback)
std::function< bool(size_t)> callback_t
void setCompletedTicks(size_t value)
Increment number of completed computation steps.
void reset()
Resets progress.
void setMaxTicksCount(size_t value)
Sets expected ticks count, representing progress of a computation.
materialitems.h Collection of materials to populate MaterialModel.
Definition: filesystem.h:81
Defines class CLASS?