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

#ifndef BORNAGAIN_SAMPLE_INTERFACE_CROSSCORRELATIONMODELS_H
#define BORNAGAIN_SAMPLE_INTERFACE_CROSSCORRELATIONMODELS_H

#include "Base/Type/Cloneable.h"
#include <heinz/Vectors3D.h>

//! Base class for cross-correlation function models.
class CrosscorrelationModel : public Cloneable {
public:
#ifndef SWIG
    CrosscorrelationModel* clone() const override = 0;

    virtual void validate() const {}

protected:
    mutable bool m_validated{false};
#endif // SWIG
};

//! The crosscorrelation factor depends both on the distance between interfaces and the spatial
//! frequency of roughness.
class SpatialFrequencyCrosscorrelation : public CrosscorrelationModel {
public:
    SpatialFrequencyCrosscorrelation(double base_crosscorr_depth, double base_frequency,
                                     double power);

    double crosscorrSpectrum(double spectrum_up, double spectrum_low, double thickness,
                             double spatial_f) const;

#ifndef SWIG
    SpatialFrequencyCrosscorrelation* clone() const override;
    void validate() const override;

    double baseCrossCorrDepth() const { return m_base_crosscorr_depth; }
    double baseSpatialFrequency() const { return m_base_spatial_frequency; }
    double power() const { return m_power; }

protected:
    double m_base_crosscorr_depth;
    double m_base_spatial_frequency;
    double m_power;
#endif // SWIG
};

//! The crosscorrelation factor depends on the distance between interfaces and does not depend
//! on the spatial frequency of roughness.
class CommonDepthCrosscorrelation : public SpatialFrequencyCrosscorrelation {
public:
    CommonDepthCrosscorrelation(double cross_corr_depth);

#ifndef SWIG
    CommonDepthCrosscorrelation* clone() const override;

    double crossCorrDepth() const { return m_base_crosscorr_depth; }
#endif // SWIG
};

#endif // BORNAGAIN_SAMPLE_INTERFACE_CROSSCORRELATIONMODELS_H
