BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IComputation Class Referenceabstract
Inheritance diagram for IComputation:
Collaboration diagram for IComputation:

Public Member Functions

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

Protected Attributes

SimulationOptions m_sim_options
 
ProgressHandlermp_progress
 
ComputationStatus m_status
 
std::unique_ptr< ProcessedSamplemP_processed_sample
 

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 Simulation::runSingleSimulation().

Definition at line 34 of file IComputation.h.

Constructor & Destructor Documentation

◆ IComputation()

IComputation::IComputation ( const MultiLayer sample,
const SimulationOptions options,
ProgressHandler progress 
)

Definition at line 21 of file IComputation.cpp.

23  : m_sim_options(options), mp_progress(&progress),
24  mP_processed_sample(std::make_unique<ProcessedSample>(sample, options))
25 {
26 }
std::unique_ptr< ProcessedSample > mP_processed_sample
Definition: IComputation.h:50
ProgressHandler * mp_progress
Definition: IComputation.h:48
SimulationOptions m_sim_options
Definition: IComputation.h:47

◆ ~IComputation()

IComputation::~IComputation ( )
virtualdefault

Member Function Documentation

◆ run()

void IComputation::run ( )

Definition at line 30 of file IComputation.cpp.

31 {
33  try {
34  runProtected();
36  } catch (const std::exception& ex) {
37  m_status.setErrorMessage(std::string(ex.what()));
39  }
40 }
void setErrorMessage(const std::string &message)
virtual void runProtected()=0
ComputationStatus m_status
Definition: IComputation.h:49

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

Here is the call graph for this function:

◆ isCompleted()

bool IComputation::isCompleted ( ) const
inline

Definition at line 43 of file IComputation.h.

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

References ComputationStatus::isCompleted(), and m_status.

Here is the call graph for this function:

◆ errorMessage()

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

Definition at line 44 of file IComputation.h.

44 { return m_status.errorMessage(); }
std::string errorMessage() const

References ComputationStatus::errorMessage(), and m_status.

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_sim_options

SimulationOptions IComputation::m_sim_options
protected

Definition at line 47 of file IComputation.h.

Referenced by DWBAComputation::DWBAComputation().

◆ mp_progress

ProgressHandler* IComputation::mp_progress
protected

◆ m_status

ComputationStatus IComputation::m_status
protected

Definition at line 49 of file IComputation.h.

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

◆ mP_processed_sample

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

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