using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Edge.Core.Processor.Dispatcher
{
    public enum ProcessorTypeEnum { DeviceProcessor, AppProcessor }

    public enum ProcessorMetaPartsTypeEnum
    {
        /// <summary>
        /// the most outer processor, like GenericDeviceProcessor<TRaw, TMessage>, 
        ///     HalfDuplexActivePollingDeviceProcessor<TRaw, TMessage>
        /// </summary>
        DeviceProcessor,
        DeviceHandler,
        App,
        Parser,
        MessageCutter,
        Communicator,
        // most likey the byte[]
        RawMessageTypeStr,
        MessageTypeStr
    }

    public class ProcessorMetaConfig
    {
        public int Id { get; set; }
        public string SourceEndpointFullTypeStr { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public ProcessorTypeEnum Type { get; set; }

        public IEnumerable<ProcessorMetaPartsConfig> Parts { get; set; }
        public bool Activated { get; set; }
        //public DateTime TimeStamp { get; set; }
    }


    public class ProcessorMetaPartsConfig
    {
        public int Id { get; set; }

        //public int ProcessorMetaConfigId { get; set; }
        //public ProcessorMetaConfig ProcessorMetaConfig { get; set; }

        public ProcessorMetaPartsTypeEnum Type { get; set; }
        public string FullTypeString { get; set; }
        public string ParametersJsonArrayStr { get; set; }
    }

    /// <summary>
    /// Data structure for how construct a Processor instance.
    /// </summary>
    public class ProcessorMetaDescriptor
    {
        public string SourceEndpointFullTypeStr { get; set; }
        public string DisplayName { get; set; }
        public string Description { get; set; }
        public ProcessorTypeEnum Type { get; set; }
        public string[] Tags { get; set; }

        /// <summary>
        /// Gets or sets the MetaPartsGroupDescriptor, a processor is consist of several meta part.
        /// </summary>
        public IEnumerable<ProcessorMetaPartsGroupDescriptor> MetaPartsGroupDescriptors { get; set; }
        //public bool Activated { get; set; }
        //public DateTime TimeStamp { get; set; }
    }


    public class ProcessorMetaPartsGroupDescriptor
    {
        public ProcessorMetaPartsTypeEnum GroupType { get; set; }
        /// <summary>
        /// the available MetaParts list, when in real constructing, will only pick one.
        /// think about the case of a device support multiple communicator.
        /// </summary>
        public IEnumerable<ProcessorMetaPartsDescriptor> MetaPartsDescriptors { get; set; }
    }

    /// <summary>
    /// Data structure for how construct a MetaParts.
    /// </summary>
    public class ProcessorMetaPartsDescriptor
    {
        public string FullTypeString { get; set; }
        public string TypeString { get; set; }
        public string DisplayName { get; set; }
        public string Description { get; set; }
        public IEnumerable<List<string>> ParametersJsonSchemaStrings { get; set; }
    }
}
