﻿using PRPE.Configuration.DataSources;
using PRPE.Models.Base;

namespace PRPE.Configuration {
    /// <summary>
    ///     PatternRecognitionConfiguration class.
    /// </summary>
    /// <typeparam name="T">Type of the object which the datasource can contain.</typeparam>
    public class PatternRecognitionConfiguration<T> where T : PatternRecognitionEntityBase<T>, new() {
        /// <summary>
        ///     PatternRecognitionConfiguration constructor.
        /// </summary>
        public PatternRecognitionConfiguration() {}

        /// <summary>
        ///     PatternRecognitionConfiguration constructor.
        /// </summary>
        /// <param name="dataSource">The datasource used by the engine.</param>
        /// <param name="minimumSamples">Minimum samples to match against.</param>
        /// <param name="maximumSamples">Maximum samples to match against.</param>
        /// <param name="historySize">
        ///     Maximum history size used for matching, the bigger the history, the better the results will
        ///     be over time.
        /// </param>
        public PatternRecognitionConfiguration(MemoryDataSource<T> dataSource, int minimumSamples,
            int maximumSamples, int historySize) {
            DataSource = dataSource;
            MinimumSamples = minimumSamples;
            MaximumSamples = maximumSamples;
            HistorySize = historySize;
        }


        /// <summary>
        ///     PatternRecognitionConfiguration constructor.
        /// </summary>
        /// <param name="dataSource">The datasource used by the engine.</param>
        /// <param name="minimumSamples">Minimum samples to match against.</param>
        /// <param name="maximumSamples">Maximum samples to match against.</param>
        /// <param name="historySize">
        ///     Maximum history size used for matching, the bigger the history, the better the results will
        ///     be over time.
        /// </param>
        /// <param name="weightMargin">
        ///     Weight margin which is used internally to tweak the results based on BackPropagation
        ///     feedback.
        /// </param>
        public PatternRecognitionConfiguration(MemoryDataSource<T> dataSource, int minimumSamples,
            int maximumSamples, int historySize, int weightMargin) {
            DataSource = dataSource;
            MinimumSamples = minimumSamples;
            MaximumSamples = maximumSamples;
            HistorySize = historySize;
            WeightMargin = weightMargin;
        }

        /// <summary>
        ///     The current datasource.
        /// </summary>
        public MemoryDataSource<T> DataSource { get; set; }

        /// <summary>
        ///     Minimum samples to match against.
        /// </summary>
        public int MinimumSamples { get; set; }

        /// <summary>
        ///     Maximum samples to match against.
        /// </summary>
        public int MaximumSamples { get; set; }

        /// <summary>
        ///     Maximum history size used for matching, the bigger the history, the better the results will be over time.
        /// </summary>
        public int HistorySize { get; set; }

        /// <summary>
        ///     Weight margin which is used internally to tweak the results based on BackPropagation feedback.
        /// </summary>
        public int WeightMargin { get; set; }
    }
}