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

namespace skyscraper5.Dvb
{
    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    public sealed class UserDefinedDescriptorAttribute : Attribute
    {
        public uint PrivateDataSpecifier { get; }
        public byte DescriptorId { get; }
        public string[] CompatibleTables { get; }

        public UserDefinedDescriptorAttribute(uint privateDataSpecifier, byte descriptorId, params string[] compatibleTables)
        {
            PrivateDataSpecifier = privateDataSpecifier;
            DescriptorId = descriptorId;
            CompatibleTables = compatibleTables;
        }

        public bool Matches(uint privateDataSpecifier, string table)
        {
            foreach (string compatibleTable in CompatibleTables)
            {
                if (compatibleTable == table && privateDataSpecifier == this.PrivateDataSpecifier)
                    return true;
            }

            return false;
        }
    }
}
