using Quadarax.Foundation.Core.Data;

namespace qdr.fnd.core.pqueue.Process
{
    public interface IPsProcessProvider : IDisposable
    {

        /// <summary>
        /// Collection (dictionary) of running arguments for the process.
        /// </summary>
        IDictionary<string, TypedArgument> Arguments { get; }
        /// <summary>
        /// Flag signalizes if the process is running.
        /// </summary>
        bool IsRunning { get; }
        /// <summary>
        /// Working/processing item identifier. Points to <see cref="PsQueueItem.Id"/>."/>
        /// </summary>
        string ItemId { get; }

        /// <summary>
        /// Gets information when the process started (by calling <see cref="Start"/> operation).
        /// If process haven't been started yet, returns null.
        /// </summary>
        DateTime? StartedTimestamp { get; }
        /// <summary>
        /// Gets information when the process was finished (by calling <see cref="Stop"/> operation or when operation regullary ends).
        /// If process haven't been finished yet, returns null.
        /// </summary>
        DateTime? FinishedTimestamp { get; }

        /// <summary>
        /// Validates the process arguments. Throws <see cref="PsProcessProviderException"/> if validation fails.
        /// </summary>
        void Validate();
        /// <summary>
        /// Starts the process. Throws <see cref="PsProcessProviderException"/> if the process is already running.
        /// </summary>
        void Start();

        /// <summary>
        /// Stops the process. Throws <see cref="PsProcessProviderException"/> if the process is not running.
        /// </summary>
        void Stop();

        /// <summary>
        /// Waits till <see cref="IsRunning"/> is false."/>
        /// </summary>
        void WaitToDone();

    }
}
