BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IComputation.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Computation/IComputation.h
6 //! @brief Defines interface IComputation.
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_CORE_COMPUTATION_ICOMPUTATION_H
16 #define BORNAGAIN_CORE_COMPUTATION_ICOMPUTATION_H
17 
20 #include <memory>
21 #include <vector>
22 
23 class MultiLayer;
24 class ProcessedSample;
25 class ProgressHandler;
26 
27 //! Interface for a single-threaded computation with given range of SimulationElements
28 //! and ProgressHandler.
29 //!
30 //! Controlled by the multi-threading machinery in Simulation::runSingleSimulation().
31 //!
32 //! @ingroup algorithms_internal
33 
35 {
36 public:
37  IComputation(const MultiLayer& sample, const SimulationOptions& options,
38  ProgressHandler& progress);
39  virtual ~IComputation();
40 
41  void run();
42 
43  bool isCompleted() const { return m_status.isCompleted(); }
44  std::string errorMessage() const { return m_status.errorMessage(); }
45 
46 protected:
50  std::unique_ptr<ProcessedSample> mP_processed_sample;
51 
52 private:
53  virtual void runProtected() = 0;
54 };
55 
56 #endif // BORNAGAIN_CORE_COMPUTATION_ICOMPUTATION_H
Defines and implements interface class ComputationStatus.
Defines class SimulationOptions.
Completion status (flag and text) of a numeric computation.
std::string errorMessage() const
bool isCompleted() const
Interface for a single-threaded computation with given range of SimulationElements and ProgressHandle...
Definition: IComputation.h:35
std::unique_ptr< ProcessedSample > mP_processed_sample
Definition: IComputation.h:50
virtual ~IComputation()
bool isCompleted() const
Definition: IComputation.h:43
IComputation(const MultiLayer &sample, const SimulationOptions &options, ProgressHandler &progress)
ProgressHandler * mp_progress
Definition: IComputation.h:48
virtual void runProtected()=0
SimulationOptions m_sim_options
Definition: IComputation.h:47
ComputationStatus m_status
Definition: IComputation.h:49
std::string errorMessage() const
Definition: IComputation.h:44
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:42
Data structure that contains all the necessary data for scattering calculations.
Maintains information about progress of a computation.
Collect the different options for simulation.