// Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo.
//
// See AUTHORS.md and LICENSE file in the project root for full license information.
//
// Kyoo is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// Kyoo is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see .
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Abstractions.Models.Exceptions;
namespace Kyoo.Abstractions.Controllers
{
///
/// A service to handle long running tasks.
///
/// The concurrent number of running tasks is implementation dependent.
public interface ITaskManager
{
///
/// Start a new task (or queue it).
///
///
/// The slug of the task to run.
///
///
/// A progress reporter to know the percentage of completion of the task.
///
///
/// A list of arguments to pass to the task. An automatic conversion will be made if arguments to not fit.
///
///
/// A custom cancellation token for the task.
///
///
/// If the number of arguments is invalid, if an argument can't be converted or if the task finds the argument
/// invalid.
///
///
/// The task could not be found.
///
void StartTask(string taskSlug,
[NotNull] IProgress progress,
Dictionary arguments = null,
CancellationToken? cancellationToken = null);
///
/// Start a new task (or queue it).
///
///
/// A progress reporter to know the percentage of completion of the task.
///
///
/// A list of arguments to pass to the task. An automatic conversion will be made if arguments to not fit.
///
///
/// The type of the task to start.
///
///
/// A custom cancellation token for the task.
///
///
/// If the number of arguments is invalid, if an argument can't be converted or if the task finds the argument
/// invalid.
///
///
/// The task could not be found.
///
void StartTask([NotNull] IProgress progress,
Dictionary arguments = null,
CancellationToken? cancellationToken = null)
where T : ITask;
///
/// Get all currently running tasks
///
/// A list of currently running tasks.
ICollection<(TaskMetadataAttribute, ITask)> GetRunningTasks();
///
/// Get all available tasks
///
/// A list of every tasks that this instance know.
ICollection GetAllTasks();
}
}