BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ISample.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Scattering/ISample.cpp
6 //! @brief Implements class ISample.
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 
16 #include "Base/Types/Exceptions.h"
18 #include <algorithm>
19 #include <sstream>
20 
21 ISample::ISample(const NodeMeta& meta, const std::vector<double>& PValues) : INode(meta, PValues) {}
22 
23 std::vector<const Material*> ISample::containedMaterials() const
24 {
25  std::vector<const Material*> result;
26  if (const Material* p_material = material())
27  result.push_back(p_material);
28  for (auto child : getChildren()) {
29  if (const ISample* sample = dynamic_cast<const ISample*>(child)) {
30  for (const Material* p_material : sample->containedMaterials())
31  result.push_back(p_material);
32  }
33  }
34  return result;
35 }
Defines many exception classes in namespace Exceptionss.
Defines interface class ISample.
Defines class ParameterPool.
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
virtual std::vector< const INode * > getChildren() const
Returns a vector of children (const).
Definition: INode.cpp:64
Pure virtual base class for sample components and properties related to scattering.
Definition: ISample.h:28
ISample()=default
virtual const Material * material() const
Returns nullptr, unless overwritten to return a specific material.
Definition: ISample.h:37
std::vector< const Material * > containedMaterials() const
Returns set of unique materials contained in this ISample.
Definition: ISample.cpp:23
A wrapper for underlying material implementation.
Definition: Material.h:29
Metadata of one model node.
Definition: INode.h:37