// Created with MonoDevelop
//
//    Copyright (C) 2018 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.Runtime.Serialization;


namespace Hiperscan.Spectroscopy
{
    [Serializable()]
    public class LinearDistortion : System.Runtime.Serialization.ISerializable
    {
        private double offset;
        private double factor;
        private DateTime date_time;

        public LinearDistortion(double offset, double factor)
        {
            this.offset = offset;
            this.factor = factor;
            this.date_time = DateTime.Now;
        }

        public LinearDistortion(LinearDistortion ld)
        {
            this.offset = ld.Offset;
            this.factor = ld.Factor;
            this.date_time = ld.DateTime;
        }

        private LinearDistortion(SerializationInfo info, StreamingContext context)
        {
            this.offset = (double)info.GetValue("Offset", typeof(double));
            this.factor = (double)info.GetValue("Factor", typeof(double));
            this.date_time = (DateTime)info.GetValue("DateTime", typeof(DateTime));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("Offset", this.offset);
            info.AddValue("Factor", this.factor);
            info.AddValue("DateTime", this.date_time);
        }

        public override string ToString()
        {
            return string.Format("[LinearDistortion: Offset={0}, Factor={1}, DateTime={2}]", Offset, Factor, DateTime);
        }

        public double Offset
        {
            get { return this.offset; }
        }

        public double Factor
        {
            get { return this.factor; }
        }

        public DateTime DateTime
        {
            get { return this.date_time; }
            set { this.date_time = value; }
        }
    }
}