//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Multilayer/Layer.h
//! @brief     Defines class Layer.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_SAMPLE_MULTILAYER_LAYER_H
#define BORNAGAIN_SAMPLE_MULTILAYER_LAYER_H

#include "Base/Types/OwningVector.h"
#include "Sample/Material/Material.h"
#include "Sample/Scattering/ISampleNode.h"

class ParticleLayout;

//! A layer in a MultiLayer sample.

class Layer : public ISampleNode {
public:
    Layer(Material material, double thickness = 0);
    ~Layer() override;

    Layer* clone() const override;
    std::string className() const final { return "Layer"; }
    std::vector<const INode*> nodeChildren() const override;

    void addLayout(const ParticleLayout& layout);

    void setNumberOfSlices(unsigned int n_slices) { m_n_slices = n_slices; }

#ifndef SWIG
    std::string validate() const override;

    std::vector<ParaMeta> parDefs() const final
    {
        return {{"Thickness", "nm"}};
    }

    const Material* material() const override
    {
        return &m_material;
    }
    double thickness() const
    {
        return m_thickness;
    }
    size_t numberOfLayouts() const
    {
        return m_layouts.size();
    }
    std::vector<const ParticleLayout*> layouts() const;
    unsigned int numberOfSlices() const
    {
        return m_n_slices;
    }

private:
    Material m_material;                    //!< material
    R3 m_B_field;                           //!< cached value of magnetic induction
    double m_thickness;                     //!< layer thickness in nanometers
    OwningVector<ParticleLayout> m_layouts; //!< independent layouts in this layer
    unsigned int m_n_slices = 1; //!< number of slices to create for graded layer approach
#endif                           // SWIG
};

#endif // BORNAGAIN_SAMPLE_MULTILAYER_LAYER_H
