using System;
using System.Threading;
using System.Threading.Tasks;

namespace MainShell.Process
{
    public class PreparationAreaService
    {
        private readonly IChipPreparationService _innerService;

        public PreparationAreaService(IChipPreparationService innerService)
        {
            _innerService = innerService ?? throw new ArgumentNullException(nameof(innerService));
        }

        public IChipPreparationService InnerService
        {
            get { return _innerService; }
        }

        public ChipPreparationStatus CurrentStatus
        {
            get { return _innerService.Current.Status; }
        }

        public bool TryRequestPrepare(ChipPreparationRequest request, out string rejectReason)
        {
            return _innerService.TryRequestPrepare(request, out rejectReason);
        }

        public Task<ChipPreparationWaitResult> WaitUntilReadyAsync(TimeSpan timeout, CancellationToken cancellationToken)
        {
            return _innerService.WaitUntilReadyAsync(timeout, cancellationToken);
        }

        public Task<ChipPreparationWaitResult> WaitUntilLoadedAsync(TimeSpan timeout, CancellationToken cancellationToken)
        {
            return _innerService.WaitUntilLoadedAsync(timeout, cancellationToken);
        }

        public bool TryConsumeReady(out string rejectReason)
        {
            return _innerService.TryConsumeReady(out rejectReason);
        }

        public Task CancelAsync(CancellationToken cancellationToken)
        {
            return _innerService.CancelAsync(cancellationToken);
        }

        public void Pause()
        {
            _innerService.Pause();
        }

        public void Resume()
        {
            _innerService.Resume();
        }

        public bool TryMarkReady(string requestId, out string rejectReason)
        {
            return _innerService.TryMarkReady(requestId, out rejectReason);
        }

        public bool TryMarkFault(string errorMessage, out string rejectReason)
        {
            return _innerService.TryMarkFault(errorMessage, out rejectReason);
        }
    }
}