using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Dvb.DataBroadcasting.Biop;
using skyscraper5.Dvb.DataBroadcasting.Dsm;
using skyscraper5.Skyscraper.IO;

namespace skyscraper5.Dvb.DataBroadcasting
{
    class BiopProfileBody
    {
        public BiopProfileBody(byte[] buffer)
            : this(new MemoryStream(buffer, false))
        {

        }

        public BiopProfileBody(MemoryStream ms)
        {
            if (ms.ReadUInt8() != 0x00) //0x00 = big endian
                throw new NotImplementedException("little endian");

            byte LiteComponentsCount = ms.ReadUInt8();

            ObjectLocation = new ObjectLocation(ms);
            ConnBinder = new ConnBinder(ms);

            LiteComponents = new LiteComponent[LiteComponentsCount - 2];
            for (int n = 0; n < LiteComponentsCount - 2; n++)
            {
                LiteComponents[n] = new LiteComponent(ms);
            }
        }
        
        public ObjectLocation ObjectLocation { get; private set; }
        public ConnBinder ConnBinder { get; private set; }

        public LiteComponent[] LiteComponents { get; private set; }
    }
}
