BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleProvider.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/SampleBuilderEngine/SampleProvider.h
6 //! @brief Defines class SampleProvider.
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_SAMPLEPROVIDER_H
21 #define BORNAGAIN_SAMPLE_SAMPLEBUILDERENGINE_SAMPLEPROVIDER_H
22 
24 
25 class MultiLayer;
26 
27 //! Holds either a Sample, or a SampleBuilderNode (which holds an ISampleBuilder).
28 //! Used in ISimulation, which holds a SampleProvider member.
29 
30 //! @ingroup simulation_internal
31 
32 class SampleProvider : public INode {
33 public:
35  SampleProvider(const SampleProvider& other); // TODO ASAP can't we clone?
38 
39  void setSample(const MultiLayer& multilayer);
40 
41  void setBuilder(const std::shared_ptr<ISampleBuilder>& sample_builder);
42 
43  const MultiLayer* sample() const;
44 
45  void updateSample();
46 
47  std::vector<const INode*> getChildren() const override;
48 
49  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
50 
51  void setParent(const INode* newParent) override;
52 
53 private:
54  std::unique_ptr<MultiLayer> m_multilayer;
56 };
57 
58 #endif // BORNAGAIN_SAMPLE_SAMPLEBUILDERENGINE_SAMPLEPROVIDER_H
59 #endif // USER_API
Defines class SampleBuilderNode.
Visitor interface to visit ISampleNode objects.
Definition: INodeVisitor.h:146
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
Wraps an ISampleBuilder, and puts it in an INode tree.
Holds either a Sample, or a SampleBuilderNode (which holds an ISampleBuilder).
void setSample(const MultiLayer &multilayer)
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
void updateSample()
Generates new sample if sample builder defined.
std::unique_ptr< MultiLayer > m_multilayer
const MultiLayer * sample() const
Returns current sample.
void setParent(const INode *newParent) override
SampleProvider & operator=(const SampleProvider &other)
SampleBuilderNode m_sample_builder
std::vector< const INode * > getChildren() const override
Returns a vector of children.
void setBuilder(const std::shared_ptr< ISampleBuilder > &sample_builder)