// 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 Hiperscan.Spectroscopy;
using Hiperscan.Spectroscopy.Processing.Transformations;

namespace Hiperscan.Spectroscopy.Processing
{
    public class ProcessingResult
    {
        internal ProcessingResult(SpectrumProcessor spectrum_processor, Spectrum processed_spectrum, TimeSpan duration)
        {
            this.ProcessedSampleSpectrum = processed_spectrum;
            this.ProcessedReferences = spectrum_processor.Clone();
            this.ReferenceWheelVersion = spectrum_processor.ReferenceWheelVersion;
            this.HasWavelengthCorrection = spectrum_processor.WithWavelengthCorrection;
            this.HasForcedMasterOxidSpectrum = spectrum_processor.HasForcedMasterOxidReference;
            this.TransformationType = spectrum_processor.TransformationType;
            this.ExternalBackgroundType = spectrum_processor.ExternalBackgroundType;
            this.RawSpectrumLimitBandwidthMode = spectrum_processor.RawSpectrumLimitBandwidthMode;
            this.ProcessedSpectrumLimitBandwidthMode = spectrum_processor.ProcessedSpectrumLimitBandwidthMode;
            this.InstrumentReferenceSystem = spectrum_processor.InstrumentReferenceSystem;
            this.ProcessingDuration = duration;
            this.ExternalWhiteReferenceType = spectrum_processor.ExternalWhiteReferenceType;

            this.ProcessingTimestamp = DateTime.Now;
        }

        public Spectrum ProcessedSampleSpectrum { get; private set; }

        public DateTime ProcessingTimestamp { get; private set; }

        public TimeSpan ProcessingDuration { get; private set; }

        public ProcessingReferences ProcessedReferences { get; private set; }

        public ReferenceWheelVersion ReferenceWheelVersion { get; private set; }

        public bool HasWavelengthCorrection { get; private set; }

        public bool HasForcedMasterOxidSpectrum { get; private set; }

        public TransformationTypes TransformationType { get; private set; }

        public ExternalBackgroundType ExternalBackgroundType { get; private set; }

        public LimitBandwidthMode RawSpectrumLimitBandwidthMode { get; private set; }

        public LimitBandwidthMode ProcessedSpectrumLimitBandwidthMode { get; private set; }

        public ExternalWhiteReferenceType ExternalWhiteReferenceType { get; private set; }

        public InstrumentReferenceSystem InstrumentReferenceSystem { get; private set; }

        public static implicit operator Spectrum(ProcessingResult processing_set) => processing_set.ProcessedSampleSpectrum;
    }
}
