// Created with MonoDevelop
//
//    Copyright (C) 2024 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Reflection;
using System.Collections.Generic;

using Hiperscan.Unix;
using Hiperscan.Spectroscopy;

namespace Hiperscan.Spectroscopy.Processing
{
    public partial class SpectrumProcessor
    {
        protected Spectrum BlackReference
        {
            get
            {
                if (this.black_reference != null && this.recalc_black_reference)
                {
                    this.SetReferenceRawspectrumData(this.black_reference);
                    this.recalc_black_reference = false;
                }

                return this.black_reference;
            }
            set
            {
                this.black_reference = value?.Clone();

                if (this.black_reference != null)
                    this.recalc_black_reference = true;
                else
                    this.recalc_black_reference = false;
            }
        }

        protected Spectrum WhiteReference
        {
            get
            {
                if (this.white_reference != null && this.recalc_white_reference)
                {
                    this.SetReferenceRawspectrumData(this.white_reference);
                    this.recalc_white_reference = false;
                }

                return this.white_reference;
            }
            set
            {
                this.white_reference = value?.Clone();

                if (this.white_reference != null)
                    this.recalc_white_reference = true;
                else
                    this.recalc_white_reference = false;
            }
        }

        protected Spectrum SampleInsertWhiteReference
        {
            get
            {
                if (this.sample_insert_white_reference != null && this.recalc_sample_insert_white_reference)
                {
                    this.SetReferenceRawspectrumData(this.sample_insert_white_reference);
                    this.recalc_sample_insert_white_reference = false;
                }

                return this.sample_insert_white_reference;
            }
            set
            {
                this.sample_insert_white_reference = value?.Clone();

                if (this.sample_insert_white_reference != null)
                    this.recalc_sample_insert_white_reference = true;
                else
                    this.recalc_sample_insert_white_reference = false;
            }
        }

        protected Spectrum TransflectanceInsertReference
        {
            get
            {
                if (this.transflectance_insert_reference != null && this.recalc_transflectance_insert_reference)
                {
                    this.SetReferenceRawspectrumData(this.transflectance_insert_reference);
                    this.recalc_transflectance_insert_reference = false;
                }

                return this.transflectance_insert_reference;
            }
            set
            {
                this.transflectance_insert_reference = value?.Clone();

                if (this.transflectance_insert_reference != null)
                    this.recalc_transflectance_insert_reference = true;
                else
                    this.recalc_transflectance_insert_reference = false;
            }
        }
    }
}
