BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
JobWorker.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/Data/JobWorker.h
6 //! @brief Defines class JobWorker
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_SUPPORT_DATA_JOBWORKER_H
16 #define BORNAGAIN_GUI_SUPPORT_DATA_JOBWORKER_H
17 
19 #include <QDateTime>
20 #include <QObject>
21 #include <memory>
22 
23 class ISimulation;
24 class SimulationResult;
25 
26 //! The JobWorker class provides running the domain simulation in a thread.
27 
28 class JobWorker : public QObject {
29  Q_OBJECT
30 public:
31  JobWorker(QString identifier, ISimulation* simulation);
33 
34  QString identifier() const;
35 
36  int progress() const;
37 
38  JobStatus status() const;
39 
40  QString failureMessage() const;
41 
42  const QDateTime& simulationStart() const;
43  const QDateTime& simulationEnd() const;
44 
45  const SimulationResult* result() const;
46 
47 signals:
48  void started();
49  void finished();
51 
52 public slots:
53  void start();
54  void terminate();
55 
56 private:
57  bool updateProgress(int percentage_done);
58 
59  QString m_identifier;
60  ISimulation* m_simulation;
65  QDateTime m_simulation_start;
66  QDateTime m_simulation_end;
67  std::unique_ptr<const SimulationResult> m_result;
68 };
69 
70 #endif // BORNAGAIN_GUI_SUPPORT_DATA_JOBWORKER_H
Defines enum JobStatus.
JobStatus
The JobStatus enum lists the possible states of a job.
Definition: JobStatus.h:22
The JobWorker class provides running the domain simulation in a thread.
Definition: JobWorker.h:28
bool updateProgress(int percentage_done)
Sets current progress. Returns true if we want to continue the simulation.
Definition: JobWorker.cpp:117
QDateTime m_simulation_end
Definition: JobWorker.h:66
int m_percentage_done
Definition: JobWorker.h:61
void progressUpdate()
const QDateTime & simulationStart() const
Definition: JobWorker.cpp:92
QString failureMessage() const
Definition: JobWorker.cpp:87
QString identifier() const
Definition: JobWorker.cpp:33
int progress() const
Definition: JobWorker.cpp:38
void start()
Definition: JobWorker.cpp:43
bool m_terminate_request_flag
Definition: JobWorker.h:63
const SimulationResult * result() const
Definition: JobWorker.cpp:102
QDateTime m_simulation_start
Definition: JobWorker.h:65
QString m_identifier
Definition: JobWorker.h:59
void finished()
JobWorker(QString identifier, ISimulation *simulation)
Definition: JobWorker.cpp:22
std::unique_ptr< const SimulationResult > m_result
Definition: JobWorker.h:67
JobStatus m_job_status
Definition: JobWorker.h:62
const QDateTime & simulationEnd() const
Definition: JobWorker.cpp:97
QString m_failure_message
Definition: JobWorker.h:64
void terminate()
Sets request for JobRunner to terminate underlying domain simulation.
Definition: JobWorker.cpp:109
ISimulation * m_simulation
Definition: JobWorker.h:60
void started()
JobStatus status() const
Definition: JobWorker.cpp:82