BornAgain  1.19.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 reflection and scattering
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_CORE_COMPUTATION_ICOMPUTATION_H
21 #define BORNAGAIN_CORE_COMPUTATION_ICOMPUTATION_H
22 
25 #include <memory>
26 #include <vector>
27 
28 class MultiLayer;
29 class ProcessedSample;
30 class ProgressHandler;
31 
32 //! Interface for a single-threaded computation with given range of SimulationElements
33 //! and ProgressHandler.
34 //!
35 //! Controlled by the multi-threading machinery in ISimulation::runSingleSimulation().
36 //!
37 //! @ingroup algorithms_internal
38 
39 class IComputation {
40 public:
41  IComputation(const MultiLayer& sample, const SimulationOptions& options,
42  ProgressHandler& progress, bool forcePolarized=false);
43  virtual ~IComputation();
44 
45  void run();
46 
47  bool isCompleted() const { return m_status.isCompleted(); }
48  std::string errorMessage() const { return m_status.errorMessage(); }
49 
50 protected:
54  std::unique_ptr<ProcessedSample> m_processed_sample;
55 
56 private:
57  virtual void runProtected() = 0;
58 };
59 
60 #endif // BORNAGAIN_CORE_COMPUTATION_ICOMPUTATION_H
61 #endif // USER_API
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:39
virtual ~IComputation()
ProgressHandler * m_progress
Definition: IComputation.h:52
bool isCompleted() const
Definition: IComputation.h:47
virtual void runProtected()=0
IComputation(const MultiLayer &sample, const SimulationOptions &options, ProgressHandler &progress, bool forcePolarized=false)
std::unique_ptr< ProcessedSample > m_processed_sample
Definition: IComputation.h:54
SimulationOptions m_sim_options
Definition: IComputation.h:51
ComputationStatus m_status
Definition: IComputation.h:53
std::string errorMessage() const
Definition: IComputation.h:48
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
Data structure that contains all the necessary data for scattering calculations.
Maintains information about progress of a computation.
Collect the different options for simulation.