BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleBuilderNode.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/SampleBuilderEngine/SampleBuilderNode.h
6 //! @brief Defines class SampleBuilderNode.
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_SAMPLE_SAMPLEBUILDERENGINE_SAMPLEBUILDERNODE_H
21 #define BORNAGAIN_SAMPLE_SAMPLEBUILDERENGINE_SAMPLEBUILDERNODE_H
22 
23 #include "Param/Node/INode.h"
24 #include <memory>
25 
26 class ISampleBuilder;
27 
28 //! Wraps an ISampleBuilder, and puts it in an INode tree.
29 //! Used by SampleProvider.
30 //! @ingroup simulation_internal
31 
32 class SampleBuilderNode : public INode {
33 public:
37 
38  void setSBN(const std::shared_ptr<ISampleBuilder>& sample_builder);
39 
40  void reset();
41 
42  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
43 
44  std::unique_ptr<MultiLayer> createMultiLayer();
45 
46  explicit operator bool() const;
47 
48  std::shared_ptr<ISampleBuilder> builder() const;
49 
50 private:
52 
53  std::shared_ptr<ISampleBuilder> m_sample_builder;
54 };
55 
56 #endif // BORNAGAIN_SAMPLE_SAMPLEBUILDERENGINE_SAMPLEBUILDERNODE_H
57 #endif // USER_API
Defines interface INode.
Visitor interface to visit ISampleNode objects.
Definition: INodeVisitor.h:146
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
Interface to the class capable to build samples to simulate.
Wraps an ISampleBuilder, and puts it in an INode tree.
void setSBN(const std::shared_ptr< ISampleBuilder > &sample_builder)
Sets sample builder and borrows its parameters.
std::shared_ptr< ISampleBuilder > builder() const
Returns current sample builder.
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
void borrow_builder_parameters()
Fill local parameter pool with parameters from sample builder.
std::shared_ptr< ISampleBuilder > m_sample_builder
SampleBuilderNode & operator=(const SampleBuilderNode &other)
void reset()
Resets to initial state by removing builder and its borrowed parameters.
std::unique_ptr< MultiLayer > createMultiLayer()
Creates a multilayer using sample builder.