BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IComputation Class Referenceabstract

Interface for a single-threaded computation with given range of SimulationElements and ProgressHandler. More...

Inheritance diagram for IComputation:
[legend]
Collaboration diagram for IComputation:
[legend]

Public Member Functions

 IComputation (const MultiLayer &sample, const SimulationOptions &options, ProgressHandler &progress, bool forcePolarized=false)
 
virtual ~IComputation ()
 
std::string errorMessage () const
 
bool isCompleted () const
 
void run ()
 

Protected Attributes

std::unique_ptr< ProcessedSamplem_processed_sample
 
ProgressHandlerm_progress
 
SimulationOptions m_sim_options
 
ComputationStatus m_status
 

Private Member Functions

virtual void runProtected ()=0
 

Detailed Description

Interface for a single-threaded computation with given range of SimulationElements and ProgressHandler.

Controlled by the multi-threading machinery in ISimulation::runSingleSimulation().

Definition at line 39 of file IComputation.h.

Constructor & Destructor Documentation

◆ IComputation()

IComputation::IComputation ( const MultiLayer sample,
const SimulationOptions options,
ProgressHandler progress,
bool  forcePolarized = false 
)

Definition at line 21 of file IComputation.cpp.

23  : m_sim_options(options)
24  , m_progress(&progress)
25  , m_processed_sample(std::make_unique<ProcessedSample>(sample, options, forcePolarized))
26 {
27 }
ProgressHandler * m_progress
Definition: IComputation.h:52
std::unique_ptr< ProcessedSample > m_processed_sample
Definition: IComputation.h:54
SimulationOptions m_sim_options
Definition: IComputation.h:51

◆ ~IComputation()

IComputation::~IComputation ( )
virtualdefault

Member Function Documentation

◆ errorMessage()

std::string IComputation::errorMessage ( ) const
inline

Definition at line 48 of file IComputation.h.

48 { return m_status.errorMessage(); }
std::string errorMessage() const
ComputationStatus m_status
Definition: IComputation.h:53

References ComputationStatus::errorMessage(), and m_status.

Here is the call graph for this function:

◆ isCompleted()

bool IComputation::isCompleted ( ) const
inline

Definition at line 47 of file IComputation.h.

47 { return m_status.isCompleted(); }
bool isCompleted() const

References ComputationStatus::isCompleted(), and m_status.

Here is the call graph for this function:

◆ run()

void IComputation::run ( )

Definition at line 31 of file IComputation.cpp.

32 {
34  try {
35  runProtected();
37  } catch (const std::exception& ex) {
38  m_status.setFailed(ex.what());
39  }
40 }
void setFailed(const std::string &message)
virtual void runProtected()=0

References m_status, runProtected(), ComputationStatus::setCompleted(), ComputationStatus::setFailed(), and ComputationStatus::setRunning().

Here is the call graph for this function:

◆ runProtected()

virtual void IComputation::runProtected ( )
privatepure virtual

Implemented in SpecularComputation, DWBAComputation, and DepthProbeComputation.

Referenced by run().

Member Data Documentation

◆ m_processed_sample

std::unique_ptr<ProcessedSample> IComputation::m_processed_sample
protected

◆ m_progress

ProgressHandler* IComputation::m_progress
protected

◆ m_sim_options

SimulationOptions IComputation::m_sim_options
protected

Definition at line 51 of file IComputation.h.

Referenced by DWBAComputation::DWBAComputation().

◆ m_status

ComputationStatus IComputation::m_status
protected

Definition at line 53 of file IComputation.h.

Referenced by errorMessage(), isCompleted(), and run().


The documentation for this class was generated from the following files: