using FLY.OBJComponents.Common;
using FObjBase;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.OBJComponents.IService
{
    /// <summary>
    /// 使用窗口式显示
    /// 每行数据都有 uint32 id.
    /// 每多一行 id+1
    /// id 最大值 为 uint32.MaxValue, 最小值 为 uint32.MinValue
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBuffer<T> : INotifyBufferChanged<T>, INotifyPropertyChanged
    {
        /// <summary>
        /// 最新ID
        /// </summary>
        int NewestID { get; }

        /// <summary>
        /// 当前总数量
        /// </summary>
        int Count { get; }

        /// <summary>
        /// 总容量，当总数量 大于等于 总容量的 100%， 前面的10%数据会被删除
        /// </summary>
        int Capacity { get; set; }
            
        /// <summary>
        /// 清空全部数据
        /// </summary>
        void Reset();

        /// <summary>
        /// 获取指定位置的N个数据
        /// </summary>
        /// <param name="last_id">最后的ID</param>
        /// <param name="count">数量</param>
        /// <param name="asyncDelegate">回调</param>
        /// <param name="asyncContext">回调里面的上下文</param>
        void GetRecord(int last_id, int count, AsyncCBHandler asyncDelegate, object asyncContext);

        /// <summary>
        /// 获取最新的N个数据
        /// </summary>
        /// <param name="count">数量</param>
        /// <param name="asyncDelegate">回调</param>
        /// <param name="asyncContext">回调里面的上下文</param>
        void GetRecord(int count, AsyncCBHandler asyncDelegate, object asyncContext);
    }
    public class GetRecordReponse<T>
    {
        public int LastID;
        public IList<T> Items;
    }

}
