//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Aggregate/Struct.cpp
//! @brief     Implements 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)
//
//  ************************************************************************************************

#include "Sample/Aggregate/Struct.h"
#include "Base/Util/Assert.h"
#include "Sample/Particle/IParticle.h"

Struct::Struct(double coverage, const IParticle& particle)
    : m_particle(particle.clone())
    , m_coverage(coverage)
{
    ASSERT(0 <= coverage && coverage <= 1);
}

Struct::~Struct() = default;

void Struct::setCoverage(double coverage)
{
    ASSERT(m_coverage == 1); // only _one_ call is allowed
    ASSERT(0 <= coverage && coverage <= 1);
    m_coverage = coverage;
}

void Struct::setParticle(std::unique_ptr<IParticle> particle)
{
    m_particle = std::move(particle);
}

void Struct::validate() const
{
    ASSERT(m_particle);
    m_particle->validate();
}

void Struct::instructClone(Struct* dest) const
{
    dest->setCoverage(coverage());
}
