//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Lattice/SelectionRule.h
//! @brief     Defines classes SelectionRule, SimpleSelectionRule.
//!
//! @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_LATTICE_ISELECTIONRULE_H
#define BORNAGAIN_SAMPLE_LATTICE_ISELECTIONRULE_H

#include <heinz/Vectors3D.h>

//! Abstract base class for selection rules.

class SelectionRule {
public:
    virtual ~SelectionRule() = default;

#ifndef SWIG
    virtual SelectionRule* clone() const = 0;
#endif // SWIG

    virtual bool coordinateSelected(const I3& coordinate) const = 0;

    virtual bool isEqualTo(const SelectionRule& isr) const = 0;

    bool operator==(const SelectionRule&) const { return false; }
};

//! Selection rule (v*q)%modulus!=0, defined by vector v(a,b,c) and modulus.

class SimpleSelectionRule : public SelectionRule {
public:
    SimpleSelectionRule(int a, int b, int c, int modulus);
    ~SimpleSelectionRule() override = default;

#ifndef SWIG
    SimpleSelectionRule* clone() const override;
#endif // SWIG

    bool coordinateSelected(const I3& coordinate) const override;

    bool isEqualTo(const SelectionRule& isr) const override;

    bool operator==(const SimpleSelectionRule& other) const;

private:
    int m_a, m_b, m_c;
    int m_mod;
};

#endif // BORNAGAIN_SAMPLE_LATTICE_ISELECTIONRULE_H
