//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Aggregate/Struct.h
//! @brief     Defines class Struct.
//!
//! @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_AGGREGATE_STRUCT_H
#define BORNAGAIN_SAMPLE_AGGREGATE_STRUCT_H

#include "Base/Type/Cloneable.h"
#include <memory>
#include <string>
#include <vector>

class DiffuseElement;
class IParticle;

class Struct : public Cloneable {
public:
    virtual std::string className() const = 0;

#ifndef SWIG
    Struct(double coverage, const IParticle& particle);
    ~Struct() override;

    Struct* clone() const override = 0;

    void setCoverage(double coverage); //!< For use only from Layer::depositStruct/fillStruct

    double coverage() const { return m_coverage; }

    virtual const IParticle* particle() const { return m_particle.get(); }
    IParticle* particle() { return m_particle.get(); }
    void setParticle(std::unique_ptr<IParticle> particle);
    virtual void validate() const;

    //! Evaluates the scalar scattering for given diffuse element.
    virtual double scalarScattering(const DiffuseElement& ele) const = 0;

    //! Evaluates the polarized scattering for given diffuse element.
    virtual double polarizedScattering(const DiffuseElement& ele) const = 0;

protected:
    mutable bool m_validated{false};

    //! Sets coverage on destination clone. Call from subclass clone() methods.
    void instructClone(Struct* dest) const;

    std::unique_ptr<IParticle> m_particle;

private:
    double m_coverage; //!< Surface coverage (part of surface covered by structure)

#endif // SWIG
};

#endif // BORNAGAIN_SAMPLE_AGGREGATE_STRUCT_H
